Aucun problème avec 300 frames de 30*40...
Pas de risque que l'utilisateur en entre de trop grandes, le nombre de caractères dans une variable du classeur étant assez limité (environ 3000-4000 pixels maximum) De plus, nSpaint ne permet pas de créer des images de plus de 3000 pixels.
Donc à moins de rentrer quelques milliers de frames (ce qui est très fastidieux) il n'y a pas de risque.
(WIP) Editeur d'images
38 posts
• Page 4 of 4 • 1, 2, 3, 4
Re: (WIP) Editeur d'images
Last edited by Chockosta on 30 Oct 2011, 18:39, edited 1 time in total.
Mes programmes en Lua pour TI-Nspire : Snake, Space invaders, Bobby Carrot, Minesweeper, Mazes 3D, nSpaint, FreeCell, Tiny3D-Viewer, CubeField
-
ChockostaPremium
Niveau 10: GR (Guide de Référence)- Posts: 213
- Joined: 24 Feb 2011, 00:00
- Gender:
- Calculator(s):→ MyCalcs profile
- Class: Math sup
Re: (WIP) Editeur d'images
Sur calculatrice on est bien d'accord ?
Travailler avec le logiciel Nspire PC n'est vraiment pas pratique pour ce rendre compte de ces problèmes.
Travailler avec le logiciel Nspire PC n'est vraiment pas pratique pour ce rendre compte de ces problèmes.
-
LevakAdmin
Niveau 14: CI (Calculateur de l'Infini)- Posts: 6414
- Images: 22
- Joined: 27 Nov 2008, 00:00
- Location: 0x1AACC355
- Gender:
- Calculator(s):→ MyCalcs profile
- Class: BAC+5: Epita (ING3)
Re: (WIP) Editeur d'images
Oui oui sur calculatrice...
Mes programmes en Lua pour TI-Nspire : Snake, Space invaders, Bobby Carrot, Minesweeper, Mazes 3D, nSpaint, FreeCell, Tiny3D-Viewer, CubeField
-
ChockostaPremium
Niveau 10: GR (Guide de Référence)- Posts: 213
- Joined: 24 Feb 2011, 00:00
- Gender:
- Calculator(s):→ MyCalcs profile
- Class: Math sup
Re: (WIP) Editeur d'images
Intéressant.
Essaye de sauver le document tns, et de le réouvrir ensuite ?
Essaye de sauver le document tns, et de le réouvrir ensuite ?
MyCalcs: Help the community's calculator documentations by filling out your calculators info!
MyCalcs: Aidez la communauté à documenter les calculatrices en donnant des infos sur vos calculatrices !
Inspired-Lua.org: All about TI-Nspire Lua programming (tutorials, wiki/docs...)My calculator programs
Mes programmes pour calculatrices
-
AdriwebAdmin
Niveau 16: CC2 (Commandeur des Calculatrices)- Posts: 14896
- Images: 1211
- Joined: 01 Jun 2007, 00:00
- Location: France
- Gender:
- Calculator(s):→ MyCalcs profile
- Twitter: adriweb
- GitHub: adriweb
Re: (WIP) Editeur d'images
J'ai essayé et ça marche, mais bon, il y a une seule variable image et un tableau contenant 300 fois son nom, donc ça ne prend pas tellement de place...
Pour bien faire, il faudrait que je fasse 300 images différentes mais j'ai pas le courage.
Pour bien faire, il faudrait que je fasse 300 images différentes mais j'ai pas le courage.
Mes programmes en Lua pour TI-Nspire : Snake, Space invaders, Bobby Carrot, Minesweeper, Mazes 3D, nSpaint, FreeCell, Tiny3D-Viewer, CubeField
-
ChockostaPremium
Niveau 10: GR (Guide de Référence)- Posts: 213
- Joined: 24 Feb 2011, 00:00
- Gender:
- Calculator(s):→ MyCalcs profile
- Class: Math sup
Re: (WIP) Editeur d'images
Up !
Nspaint 0.5 !
-Outil cercle
-Outil rectangle
-Outil ligne
-quelques optimisations
Télécharger !
code : (800 lignes
) :
[spoiler]actions.lua
Data.lua
imgTools.lua
Functions.lua
Drawing.lua
Events.lua
Nspaint 0.5 !
-Outil cercle
-Outil rectangle
-Outil ligne
-quelques optimisations
Télécharger !
code : (800 lignes

[spoiler]actions.lua
Show/Hide spoilerAfficher/Masquer le spoiler
- Code: Select all
--MISC ACTIONS
function menuAction(action)
if string.find("NOS",action) then
fileAction(action)
elseif string.find("+-",action) then
setZoom(action)
elseif string.find("defpclr",action) then
selectTool(action)
elseif string.find("hs",action) then
setColor(action)
end
refresh()
end
function fileAction(action)
if action=="N" then
status="requesting"
rqstr=""
requested="Image width"
elseif action=="O" then
status="requesting"
rqstr=""
requested="File name"
elseif action=="S" then
if not imgTable then
status="error"
errtype="No opened file"
else
status="requesting"
rqstr=imgName
requested="Save as"
end
end
end
function setColor(action)
if action=="h" then
status="requesting"
rqstr=""
requested="Hex code"
elseif action=="s" then
status="selectingColor"
selColor=1
newColor={math.floor(color[1]/5)*5,math.floor(color[2]/5)*5,math.floor(color[3]/5)*5}
end
end
function setZoom(action)
if action=="+" then --Zoom in
if imgZoom<8 then
xScroll=0
yScroll=0
imgZoom=imgZoom*2
end
elseif action=="-" then --Zoom out
if imgZoom>1 then
xScroll=0
yScroll=0
imgZoom=imgZoom/2
end
end
end
function selectTool(action)
toolStep=1
if action=="d" then
tool="draw"
elseif action=="e" then
tool="erase"
elseif action=="f" then
tool="fill"
elseif action=="p" then
tool="pick"
elseif action=="c" then
tool="circle"
elseif action=="l" then
tool="line"
elseif action=="r" then
tool="rect"
end
end
toolAction={}
function toolAction.draw()
imgTable[xPos][yPos]={1,math.floor(color[1]/8),math.floor(color[2]/8),math.floor(color[3]/8)}
changedMark="*"
end
function toolAction.erase()
imgTable[xPos][yPos][1]=0
changedMark="*"
end
function toolAction.pick()
if imgTable[xPos][yPos][1]==0 then
color={255,255,255}
else
color={imgTable[xPos][yPos][2]*8,imgTable[xPos][yPos][3]*8,imgTable[xPos][yPos][4]*8}
end
end
function toolAction.fill()
fillPixel(xPos,yPos)
end
function toolAction.rect()
if toolStep==1 then
toolStep=2
step1.x,step1.y=xPos,yPos
else
toolStep=1
drawRect(step1.x,step1.y,xPos,yPos)
end
end
function toolAction.circle()
if toolStep==1 then
toolStep=2
step1.x,step1.y=xPos,yPos
else
toolStep=1
drawCircle(step1.x,step1.y,xPos,yPos)
end
end
function toolAction.line()
if toolStep==1 then
toolStep=2
step1.x,step1.y=xPos,yPos
else
toolStep=1
drawLine(step1.x,step1.y,xPos,yPos)
end
end
function requestAction()
if requested=="Hex code" then
loadHexColor()
elseif requested=="Image width" then
if tonumber(rqstr) and tonumber(rqstr)~=0 then
tempVarWidth=tonumber(rqstr)
status="requesting"
requested="Image height"
rqstr=""
else
status="error"
errtype="Invalid number"
end
elseif requested=="Image height" then
if tonumber(rqstr) and tonumber(rqstr)~=0 then
if tonumber(rqstr)*tempVarWidth>3000 then
status="error"
errtype="Overflow (3000 px max)"
else
file.new()
end
else
status="error"
errtype="Invalid number"
end
elseif requested=="File name" then
rqstr=string.lower(rqstr)
file.load()
elseif requested=="Save as" then
rqstr=string.lower(rqstr)
file.save()
end
end
Data.lua
Show/Hide spoilerAfficher/Masquer le spoiler
- Code: Select all
--DATA
--drawing
status="drawing"
tool=nil
xPos=1
yPos=1
xScroll=0
yScroll=0
color={225,170,0}
changedMark=""
--image
imgString=nil
imgTable=nil
imgZoom=1
imgName=""
--color select
newColor={200,100,255}
selColor=1
--text request
requested=""
rqstr=""
--error
errtype=""
--tools
toolStep=1
step1={x=1,y=1}
--tools sprites - 1:move 2:draw 3:erase 4:pick 5:fill 6:circle 7:line 8:rect
toolsSprites={}
toolsSprites.move=image.new("\020\000\000\000\020\000\000\000\000\000\000\000(\000\000\000\016\000\001\000\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128_\202\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\000\128_\202_\202_\202\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\000\128\000\128\000\128_\202\000\128\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128_\202\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\000\128\255\255\255\255\255\255\000\128_\202\000\128\255\255\255\255\255\255\000\128\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\000\128\000\128\255\255\255\255\255\255\000\128_\202\000\128\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\000\128\000\128\255\255\000\128_\202\000\128\000\128\000\128\000\128\000\128_\202\000\128\000\128\000\128\000\128\000\128_\202\000\128\255\255\255\255\000\128\000\128\000\128_\202_\202_\202_\202_\202_\202_\202_\202_\202_\202_\202_\202_\202_\202_\202\000\128\255\255\000\128\000\128\255\255\000\128_\202\000\128\000\128\000\128\000\128\000\128_\202\000\128\000\128\000\128\000\128\000\128_\202\000\128\255\255\255\255\000\128\000\128\255\255\255\255\000\128\000\128\255\255\255\255\255\255\000\128_\202\000\128\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\000\128\255\255\255\255\255\255\000\128_\202\000\128\255\255\255\255\255\255\000\128\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128_\202\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\000\128\000\128\000\128_\202\000\128\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\000\128_\202_\202_\202\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128_\202\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128")
toolsSprites.draw=image.new("\020\000\000\000\020\000\000\000\000\000\000\000(\000\000\000\016\000\001\000\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\011\202N\218-\214-\210\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\167\193p\230Z\255\148\254h\225e\185\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\234\197\145\222Y\255\148\254\140\253\164\240\001\173\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\167\189L\214\024\227\247\226\173\249\132\252$\209\012\202\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\168\193(\214\206\238h\230\213\218\239\229\226\208\234\197\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\168\193\008\210\238\238g\234#\226*\210\202\209\200\193\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\200\193\231\205\238\242h\234$\226\162\201B\185\168\193\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\200\193\231\205\238\242\136\234#\226\162\201\034\185\201\197\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\168\193\231\205\238\242\136\234#\226\162\201!\181\234\197\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\167\193\007\210\238\242\136\234#\226\162\201!\181\011\202\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\167\189(\214\238\238\136\234$\226\162\201!\181\011\202\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\012\202)\210\204\238g\234$\226\162\201!\181\235\201\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\134\189\240\230u\243\170\234\130\197B\185\202\197\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\232\201\016\235S\243\016\239A\185\168\193\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\012\202\144\214\208\230\008\210#\181\234\197\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\168\193\167\193e\185O\210\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\000\128\255\255\255\255\000\128\255\255\255\255\000\128\255\255\255\255\000\128\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128")
toolsSprites.erase=image.new("\020\000\000\000\020\000\000\000\000\000\000\000(\000\000\000\016\000\001\000\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255y\182\215\157\215\157\214\157\214\157\214\157\214\157\214\157\181\157\180\153z\190\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255y\186\215\157\028\215\219\206\219\202\219\202\219\202\219\202\219\202\219\202\219\202/\149Y\182\255\255\000\128\000\128\255\255\255\255\255\255\219\202\215\157<\219\187\198\187\198\187\198\187\198\187\198\187\198\187\198\186\198\028\215\154\190Q\149\255\255\000\128\000\128\255\255\255\255\255\255P\149<\219\219\202\187\198\187\198\187\198\187\198\187\198\187\198\187\198\187\198\028\215\024\170Q\149\255\255\000\128\000\128\255\255\255\255P\149<\219<\219\180\238\180\238\180\242\180\242\180\242\180\242\180\242\147\242\028\215\187\198\024\170Q\149\255\255\000\128\000\128\255\255\255\255\173\245\023\247\180\242\180\242\180\242\180\242\180\242\180\242\180\242\147\242\180\242\023\243r\242\024\170Q\149\255\255\000\128\000\128\255\255\238\245r\246\214\242\180\238\180\242\180\242\180\242\180\242\180\242\180\242\147\242\213\242\147\246r\242Q\149\255\255\255\255\000\128\000\128\255\255Q\246\024\247\180\242\180\242\180\242\148\242\148\242\148\242\147\242\147\242\180\242\246\242r\242\015\242Q\149\255\255\255\255\000\128\000\128\255\255\239\245\246\242\180\242\180\242\180\242\180\242\148\242\147\242\148\246\147\246\181\246\214\246r\246\198\248\255\255\255\255\255\255\000\128\000\128\255\255\238\2459\2478\2518\2518\2518\2518\2518\2518\2518\251\023\251R\250\173\245)\237\255\255\255\255\255\255\000\128\000\128\255\255\140\245\016\254\207\253\239\253\239\253\239\253\239\253\239\253\239\253\239\253\206\253\206\249\231\244\255\255\255\255\255\255\255\255\000\128\000\128\255\255k\245R\2501\2501\2501\2501\2501\2501\2501\2501\2501\250\140\249(\233\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\198\248\166\248\198\248\198\248\198\248\198\248\198\248\198\248\198\248\198\248\198\244\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128")
toolsSprites.pick=image.new("\020\000\000\000\020\000\000\000\000\000\000\000(\000\000\000\016\000\001\000\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\232\148.\153+\157k\173\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\198\148r\153O\153\232\148\166\148\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\2550\194J\169m\165\010\149O\153\199\148\198\148\165\144\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\007\161r\149\199\148\199\148\165\144\008\157\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255r\206\189\247)\161\198\148\199\152\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\147\210Z\235\157\239:\227\231\152\231\152\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\180\2149\231\190\243\249\2181\198\255\255)\161\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\180\214\182\206<\223\151\202R\202\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\180\2144\186\215\161r\149\017\190\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\179\214U\186\247\161\147\1532\194\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\147\210V\190\214\161\147\1532\194\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\015\194\182\157\148\1531\194\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255r\206\026\223\240\1891\194\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\210\169\240\185\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\2551\198\212\165n\161\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\018\1867\178n\161\175\173\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\2552\194\217\206X\182\246\169\011\153\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\2552\1947\178X\178\147\157L\161\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128")
toolsSprites.fill=image.new("\020\000\000\000\020\000\000\000\000\000\000\000(\000\000\000\016\000\001\000\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\147\210Q\202\146\210r\2060\198\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\246\222Q\202\255\255\255\255\255\255\255\255\173\181\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\245\222\139\177Q\202R\202\180\214\255\255\139\177\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\2557\231\172\1811\198\156\243\223\255\206\185\255\255\139\177\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255Q\206\239\189\148\210R\202Z\235{\239Y\231Q\202\140\177\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\246\222\173\181\247\222\255\255\214\2181\198Z\235\024\227\222\251\016\194\139\177\255\255\255\255\255\255\000\128\000\128\255\255\000\240\000\2401\242\016\190\255\255\255\255\222\251\148\2100\198Z\2359\231Z\235\189\247k\173\255\255\255\255\255\255\000\128\000\1281\2421\242\206\1859\231\255\255\222\251\255\255\247\222\140\177\140\177\148\2109\231\024\227\189\247\147\206\212\218\255\255\255\255\000\128\000\128\000\2401\242\023\227\222\251{\239\189\247\189\247\173\181\016\194R\202\173\181\247\222Z\2359\231\222\251\015\190\255\255\255\255\000\128\000\128\000\2401\242\015\194\156\243{\239\156\243\156\243\173\181R\202\148\210\206\185\024\227Z\2359\231{\2398\231Q\202\255\255\000\128\000\128\000\2401\242\212\218s\206\189\247Z\235\156\243\246\218\206\185\206\185\148\210{\239{\239Z\2359\231\156\243r\206\245\222\000\128\000\128\000\2401\242\255\255\238\189\156\243{\239{\239\189\247{\239{\239\156\243\156\243{\239Z\2359\231Z\235Y\231\172\181\000\128\000\128\000\2401\242\255\255\255\255\239\189\255\255Z\235\156\243\255\255\255\255\222\251\189\247\156\243{\239Z\235\189\2479\231j\173\000\128\000\128\000\2401\242\255\255\255\255P\1989\231\156\243{\239\189\247\255\255\222\251\189\247\156\243\156\243\255\255\247\222\206\185\255\255\000\128\000\128\000\240\255\255\255\255\255\255\255\255\173\181\255\255Z\235\156\243\222\251\255\255\222\251\222\251\189\247\238\189\146\210\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\179\214\214\218\189\247{\239\189\247\255\255\222\251\181\214\238\189\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\205\185\156\243\156\243\156\2439\231\239\189\146\210\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255s\206\255\255\148\210\205\185\180\214\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128")
toolsSprites.circle=image.new("\020\000\000\000\020\000\000\000\000\000\000\000(\000\000\000\016\000\001\000\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\031\130\031\130\031\130\031\130\031\130\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\031\130\031\130\255\255\255\255\255\255\255\255\255\255\031\130\031\130\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\031\130\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\031\130\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\031\130\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\031\130\255\255\255\255\255\255\000\128\000\128\255\255\255\255\031\130\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\031\130\255\255\255\255\255\255\000\128\000\128\255\255\031\130\255\255\255\255\255\255\255\255\255\255\255\255\000\128\255\255\255\255\255\255\255\255\255\255\255\255\031\130\255\255\255\255\000\128\000\128\255\255\031\130\255\255\255\255\255\255\255\255\255\255\255\255\000\128\255\255\255\255\255\255\255\255\255\255\255\255\031\130\255\255\255\255\000\128\000\128\255\255\031\130\255\255\255\255\255\255\255\255\000\128\000\128\000\128\000\128\000\128\255\255\255\255\255\255\255\255\031\130\255\255\255\255\000\128\000\128\255\255\031\130\255\255\255\255\255\255\255\255\255\255\255\255\000\128\255\255\255\255\255\255\255\255\255\255\255\255\031\130\255\255\255\255\000\128\000\128\255\255\031\130\255\255\255\255\255\255\255\255\255\255\255\255\000\128\255\255\255\255\255\255\255\255\255\255\255\255\031\130\255\255\255\255\000\128\000\128\255\255\255\255\031\130\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\031\130\255\255\255\255\255\255\000\128\000\128\255\255\255\255\031\130\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\031\130\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\031\130\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\031\130\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\031\130\031\130\255\255\255\255\255\255\255\255\255\255\031\130\031\130\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\031\130\031\130\031\130\031\130\031\130\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128")
toolsSprites.line=image.new("\020\000\000\000\020\000\000\000\000\000\000\000(\000\000\000\016\000\001\000\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\000\128\000\128\000\128\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\000\128\031\130\031\130\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\000\128\255\255\031\130\031\130\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\031\130\031\130\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\031\130\031\130\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\031\130\031\130\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\031\130\031\130\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\031\130\031\130\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\031\130\031\130\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\031\130\031\130\000\128\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\031\130\000\128\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\000\128\000\128\000\128\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128")
toolsSprites.rect=image.new("\020\000\000\000\020\000\000\000\000\000\000\000(\000\000\000\016\000\001\000\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\000\128\000\128\000\128\000\128\000\128\031\130\031\130\031\130\031\130\031\130\031\130\031\130\031\130\031\130\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\031\130\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\031\130\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\031\130\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\031\130\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\031\130\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\031\130\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\031\130\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\031\130\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\031\130\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\031\130\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\031\130\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\031\130\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\031\130\031\130\031\130\031\130\031\130\031\130\031\130\031\130\031\130\000\128\000\128\000\128\000\128\000\128\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128")
--MENU
menu={
{"File",
{"New (Shift+n)",function() menuAction("N") end},
{"Open (Shift+o)",function() menuAction("O") end},
{"Save (Shift+s)",function() menuAction("S") end}
},
{"Edit",
{"Zoom in (+)",function() menuAction("+") end},
{"Zoom out (-)",function() menuAction("-") end}
},
{"Tools",
{"Draw (d)",function() menuAction("d") end},
{"Erase (e)",function() menuAction("e") end},
{"Fill (f)",function() menuAction("f") end},
{"Color Pick (p)",function() menuAction("p") end},
{"Circle (c)",function() menuAction("c") end},
{"Line (l)",function() menuAction("l") end},
{"Rectangle (r)",function() menuAction("r") end}
},
{"Color",
{"Hexadecimal (h)",function() menuAction("h") end},
{"Select (s)",function() menuAction("s") end}
}}
toolpalette.register(menu)
imgTools.lua
Show/Hide spoilerAfficher/Masquer le spoiler
- Code: Select all
imgTools={}
function imgTools.getPixel(byte1,byte2)
local str2
str2=imgTools.addZeros(mathTools.base10to2(tonumber(byte2)),8)..imgTools.addZeros(mathTools.base10to2(tonumber(byte1)),8)
return {tonumber(string.sub(str2,1,1)),mathTools.base2to10(string.sub(str2,2,6)),mathTools.base2to10(string.sub(str2,7,11)),mathTools.base2to10(string.sub(str2,12,16))}
end
function imgTools.getSize(img)
imgWidth=mathTools.base2to10(mathTools.base10to2(tonumber(string.sub(img,10,12)..string.sub(img,7,9)..string.sub(img,4,6)..string.sub(img,1,3))))
imgHeight=mathTools.base2to10(mathTools.base10to2(tonumber(string.sub(img,22,24)..string.sub(img,19,21)..string.sub(img,16,18)..string.sub(img,13,15))))
end
function imgTools.addZeros(str,strSize)
return string.rep("0",strSize-string.len(str))..str
end
function imgTools.convertChars(img)
local finished,img2,index
index=1
img2=""
finished=nil
while not finished do
if string.sub(img,index,index)~=[[\]] then
img2=img2..imgTools.addZeros(tostring(string.byte(string.sub(img,index,index))),3)
index=index+1
else
img2=img2..string.sub(img,index+1,index+3)
index=index+4
end
if index>string.len(img) then
finished=1
end
end
return img2
end
function imgTools.generateHeader()
local binaryHeader,header
binaryHeader={}
binaryHeader[1]=imgTools.addZeros(mathTools.base10to2(imgWidth),32)
binaryHeader[2]=imgTools.addZeros(mathTools.base10to2(imgHeight),32)
binaryHeader[3]=imgTools.addZeros(mathTools.base10to2(imgWidth*2),32)
header={"","",""}
for i=1,3 do
for j=3,0,-1 do
header[i]=header[i]..imgTools.addZeros(tostring(mathTools.base2to10(string.sub(binaryHeader[i],8*j+1,8*(j+1)))),3)
end
end
return header[1]..header[2].."000000000000"..header[3].."016000001000"
end
function imgTools.convertPixel(pixel)
local str
str=tostring(pixel[1])..imgTools.addZeros(mathTools.base10to2(pixel[2]),5)..imgTools.addZeros(mathTools.base10to2(pixel[3]),5)..imgTools.addZeros(mathTools.base10to2(pixel[4]),5)
return imgTools.addZeros(tostring(mathTools.base2to10(string.sub(str,9,16))),3)..imgTools.addZeros(tostring(mathTools.base2to10(string.sub(str,1,8))),3)
end
function imgTools.addSlashes(str)
local finished,str2,index
finished=nil
str2=[[\]]..str
index=1
while not finished do
index=index+4
if index>string.len(str2) then
finished=1
else
str2=string.sub(str2,1,index-1)..[[\]]..string.sub(str2,index)
end
end
return str2
end
function imgTools.img2table(str)
local index
str2=imgTools.convertChars(str)
imgTable={}
imgTools.getSize(str2)
for i=1,imgWidth do
imgTable[i]={}
for j=1,imgHeight do
index=(i-1)*6+61+(j-1)*6*imgWidth
imgTable[i][j]=imgTools.getPixel(string.sub(str2,index,index+2),string.sub(str2,index+3,index+5))
end
end
end
function imgTools.drawTable(gc,x,y)
gc:setColorRGB(0,0,0)
gc:setPen("thin","dashed")
gc:drawRect(x-1,y-1,imgWidth*imgZoom+1,imgHeight*imgZoom+1)
gc:setPen("thin","smooth")
for i=1,imgWidth do
for j=1,imgHeight do
if imgTable[i][j][1]==1 then
gc:setColorRGB(imgTable[i][j][2]*8,imgTable[i][j][3]*8,imgTable[i][j][4]*8)
gc:fillRect((i-1)*imgZoom+x,(j-1)*imgZoom+y,imgZoom,imgZoom)
else
gc:setColorRGB(175,175,175)
for k=0,imgZoom-1 do
gc:fillRect((i-1)*imgZoom+x+k,(j-1)*imgZoom+y+k,1,1)
end
end
end
end
end
function imgTools.table2img()
local imgStr
imgStr=imgTools.generateHeader()
for i=1,imgHeight do
for j=1,imgWidth do
imgStr=imgStr..imgTools.convertPixel(imgTable[j][i])
end
end
return imgTools.addSlashes(imgStr)
end
Functions.lua
Show/Hide spoilerAfficher/Masquer le spoiler
- Code: Select all
--MATHTOOLS
mathTools={}
function mathTools.base10to2(n)
local str
str=""
if n~=0 then
while n~=1 do
str=str..tostring(n%2)
n=math.floor(n/2)
end
str=str..tostring(n%2)
return string.reverse(str)
else
return "0"
end
end
function mathTools.base2to10(n)
local num = 0
local ex = string.len(n) - 1
local l = 0
l = ex + 1
for i = 1, l do
b = string.sub(n, i, i)
if b == "1" then
num = num + 2^ex
end
ex = ex - 1
end
return num
end
function mathTools.int2Hex(int)
if int<10 then
return tostring(int)
else
if int==10 then return "A"
elseif int==11 then return "B"
elseif int==12 then return "C"
elseif int==13 then return "D"
elseif int==14 then return "E"
elseif int==15 then return "F"
end
end
end
--FILE
file={}
function file.save()
if rqstr=="" then
status="error"
errtype="Please type a name"
elseif string.find("0123456789",string.sub(rqstr,1,1)) then
status="error"
errtype="Invalid name"
else
imgString=imgTools.table2img()
var.store(rqstr,imgString)
imgName=rqstr
changedMark=""
end
end
function file.load()
local test
test=var.recall(rqstr)
if not test then
status="error"
errtype="File does not exist"
elseif type(test)~="string" then
status="error"
errtype="Invalid file"
else
imgZoom=1
xPos=1
yPos=1
xScroll=0
yScroll=0
tool=nil
changedMark=""
imgString=test
imgTools.img2table(imgString)
imgName=rqstr
end
end
function file.new()
imgWidth=tempVarWidth
imgHeight=tonumber(rqstr)
imgZoom=1
xPos=1
yPos=1
xScroll=0
yScroll=0
tool=nil
changedMark=""
imgName="unsaved"
imgTable={}
for i=1,imgWidth do
imgTable[i]={}
for j=1,imgHeight do
imgTable[i][j]={0,0,0,0}
end
end
end
--MISCELLANEOUS
function width()
return platform.window:width()
end
function height()
return platform.window:height()
end
function refresh()
platform.window:invalidate()
end
function copyTable(t)
local t2 = {}
for k,v in pairs(t) do
t2[k] = v
end
return t2
end
function samePixels(px1,px2)
if (px1[1]==px2[1] and px1[2]==px2[2] and px1[3]==px2[3] and px1[4]==px2[4]) or (px1[1]==0 and px2[1]==0) then
return 1
else
return nil
end
end
function fillPixel(x,y)
local previousPixel,xTest,yTest
previousPixel=copyTable(imgTable[x][y])
if not samePixels(previousPixel,{1,math.floor(color[1]/8),math.floor(color[2]/8),math.floor(color[3]/8)}) then
changedMark="*"
imgTable[x][y]={1,math.floor(color[1]/8),math.floor(color[2]/8),math.floor(color[3]/8)}
for i=1,4 do
xTest=math.floor(i/2)-1+x
yTest=(i==3 and 1 or 0)-(i==2 and 1 or 0)+y
if xTest>0 and xTest<imgWidth+1 and yTest>0 and yTest<imgHeight+1 then
if samePixels(previousPixel,imgTable[xTest][yTest]) then
fillPixel(xTest,yTest)
end
end
end
end
end
function setPixel(x,y)
if x>=1 and x<=imgWidth and y>=1 and y<=imgHeight then
imgTable[x][y]={1,math.floor(color[1]/8),math.floor(color[2]/8),math.floor(color[3]/8)}
end
end
function drawCircle(x1,y1,x2,y2)
local rayon=math.floor(math.sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)))
local x,y,m
x=0
y=rayon
m=5-4*rayon
while x<=y do
setPixel(x+x1,y+y1)
setPixel(y+x1,x+y1)
setPixel(-x+x1,y+y1)
setPixel(-y+x1,x+y1)
setPixel(x+x1,-y+y1)
setPixel(y+x1,-x+y1)
setPixel(-x+x1,-y+y1)
setPixel(-y+x1,-x+y1)
if m>0 then
y=y-1
m=m-8*y
end
x=x+1
m=m+8*x+4
end
end
function round(nb)
if nb>math.floor(nb)+0.5 then
return math.floor(nb)+1
else
return math.floor(nb)
end
end
function drawLine(x1,y1,x2,y2)
local reversed=nil
if x1>x2 then
x1,x2=x2,x1
reversed=not reversed
end
if y1>y2 then
y1,y2=y2,y1
reversed=not reversed
end
local size=x2-x1>y2-y1 and x2-x1 or y2-y1
for i=0,size do
if reversed then
setPixel(x1+(x2-x1)-round((i/size)*(x2-x1)),y1+round((i/size)*(y2-y1)))
else
setPixel(x1+round((i/size)*(x2-x1)),y1+round((i/size)*(y2-y1)))
end
end
end
function drawRect(x1,y1,x2,y2)
if x1>x2 then
x1,x2=x2,x1
end
if y1>y2 then
y1,y2=y2,y1
end
for i=x1,x2 do
setPixel(i,y1)
setPixel(i,y2)
end
for i=y1,y2 do
setPixel(x1,i)
setPixel(x2,i)
end
end
function loadHexColor()
local isHex,tmptable
isHex=1
tmptable={}
if string.len(rqstr)==6 then
for i=1,6,1 do
currentch=string.sub(rqstr,i,i)
tmptable[i]=tonumber(currentch,16)
if not tmptable[i] then
isHex=nil
end
end
else isHex=nil
end
if isHex then
color={tmptable[1]*16+tmptable[2],tmptable[3]*16+tmptable[4],tmptable[5]*16+tmptable[6]}
else
status="error"
errtype="Invalid hexadecimal"
end
end
Drawing.lua
Show/Hide spoilerAfficher/Masquer le spoiler
- Code: Select all
--DRAWING
function drawColorSelect(gc)
gc:setColorRGB(200,200,255)
gc:fillRect(width()/2-75,height()/2-50,150,100)
gc:setColorRGB(0,0,0)
gc:fillRect(width()/2-75,height()/2-50,150,15)
gc:setPen("thin","smooth")
gc:drawRect(width()/2-75,height()/2-50,150,100)
gc:setFont("sansserif","r",10)
gc:setColorRGB(255,255,255)
gc:drawString("Select your color",width()/2-73,height()/2-53,"top")
gc:setColorRGB(0,0,0)
gc:drawString("Red :",width()/2-73,height()/2-35,"top")
gc:drawString("Green :",width()/2-73,height()/2-20,"top")
gc:drawString("Blue :",width()/2-73,height()/2-5,"top")
for i=0,63 do
gc:setColorRGB(i*4,newColor[2],newColor[3])
gc:fillRect(width()/2-23+i,height()/2-30,1,10)
gc:setColorRGB(newColor[1],i*4,newColor[3])
gc:fillRect(width()/2-23+i,height()/2-15,1,10)
gc:setColorRGB(newColor[1],newColor[2],i*4)
gc:fillRect(width()/2-23+i,height()/2,1,10)
end
gc:setColorRGB(0,0,0)
gc:drawRect(width()/2-23,height()/2-46+selColor*15,64,11)
for i=1,3 do
gc:drawString(tostring(newColor[i]),width()/2+52,height()/2-50+i*15,"top")
gc:fillRect(width()/2-24+newColor[i]/4,height()/2-47+i*15,3,14)
end
gc:setColorRGB(color[1],color[2],color[3])
gc:fillRect(width()/2-70,height()/2+20,30,20)
gc:setColorRGB(newColor[1],newColor[2],newColor[3])
gc:fillRect(width()/2-28,height()/2+20,30,20)
gc:setColorRGB(0,0,0)
gc:drawRect(width()/2-70,height()/2+20,30,20)
gc:drawRect(width()/2-28,height()/2+20,30,20)
gc:drawString(mathTools.int2Hex(math.floor(newColor[1]/16))..mathTools.int2Hex(newColor[1]%16)..mathTools.int2Hex(math.floor(newColor[2]/16))..mathTools.int2Hex(newColor[2]%16)..mathTools.int2Hex(math.floor(newColor[3]/16))..mathTools.int2Hex(newColor[3]%16),width()/2+20,height()/2+20,"top")
gc:drawString("Old New",width()/2-65,height()/2+21,"top")
end
function drawRequest(gc,msg)
gc:setColorRGB(200,200,255)
gc:fillRect(width()/2-75,height()/2-25,150,50)
gc:setColorRGB(0,0,0)
gc:setPen("thin","smooth")
gc:drawRect(width()/2-75,height()/2-25,150,50)
gc:fillRect(width()/2-75,height()/2-25,150,15)
gc:setFont("sansserif","r",10)
gc:setColorRGB(255,255,255)
gc:drawString(msg,width()/2-70,height()/2-28,"top")
gc:setColorRGB(0,0,0)
gc:drawRect(width()/2-70,height()/2,140,20)
gc:drawString(rqstr,width()/2-65,height()/2,"top")
end
function drawError(gc)
gc:setColorRGB(200,200,255)
gc:fillRect(width()/2-75,height()/2-20,150,40)
gc:setColorRGB(0,0,0)
gc:setPen("thin","smooth")
gc:drawRect(width()/2-75,height()/2-20,150,40)
gc:fillRect(width()/2-75,height()/2-20,150,15)
gc:setFont("sansserif","r",10)
gc:setColorRGB(255,255,255)
gc:drawString("Error",width()/2-73,height()/2-23,"top")
gc:setColorRGB(0,0,0)
gc:drawString(errtype,width()/2-70,height()/2-5,"top")
end
function drawCursor(gc)
gc:setColorRGB(0,0,0)
gc:setPen("thin","smooth")
gc:drawRect((xPos-1)*imgZoom+29-xScroll*imgZoom,(yPos-1)*imgZoom+29-yScroll*imgZoom,imgZoom+1,imgZoom+1)
gc:setColorRGB(255,255,255)
gc:drawRect((xPos-1)*imgZoom+30-xScroll*imgZoom,(yPos-1)*imgZoom+30-yScroll*imgZoom,imgZoom-1,imgZoom-1)
end
function drawTool(gc)
local id=tool
if not id then
id="move"
end
gc:drawImage(toolsSprites[id],0,15)
end
drawStep1={}
function drawStep1.circle(gc)
local rayon=math.sqrt((xPos-step1.x)*(xPos-step1.x)+(yPos-step1.y)*(yPos-step1.y))
local startX,startY,size
startX,startY=(step1.x-rayon-0.6)*imgZoom+30-xScroll*imgZoom,(step1.y-rayon-0.6)*imgZoom+30-yScroll*imgZoom
size=2*rayon*imgZoom
gc:setColorRGB(255,255,255)
gc:drawArc(startX-1,startY-1,size,size,0,360)
gc:setColorRGB(0,0,0)
gc:drawArc(startX,startY,size,size,0,360)
end
function drawStep1.line(gc)
gc:setColorRGB(255,255,255)
gc:drawLine((step1.x-0.6)*imgZoom+30-xScroll*imgZoom,(step1.y-0.6)*imgZoom+30-yScroll*imgZoom,(xPos-0.6)*imgZoom+30-xScroll*imgZoom,(yPos-0.6)*imgZoom+30-yScroll*imgZoom)
gc:setColorRGB(0,0,0)
gc:drawLine((step1.x-0.6)*imgZoom+29-xScroll*imgZoom,(step1.y-0.6)*imgZoom+29-yScroll*imgZoom,(xPos-0.6)*imgZoom+29-xScroll*imgZoom,(yPos-0.6)*imgZoom+29-yScroll*imgZoom)
end
function drawStep1.rect(gc)
local startX,startY,sizeX,sizeY,lowerY,higherY
lowerX,lowerY=xPos<step1.x and xPos or step1.x,yPos<step1.y and yPos or step1.y
startX,startY=(lowerX-0.6)*imgZoom+30-xScroll*imgZoom,(lowerY-0.6)*imgZoom+30-yScroll*imgZoom
sizeX,sizeY=math.abs((xPos-step1.x)*imgZoom),math.abs((yPos-step1.y)*imgZoom)
gc:setColorRGB(255,255,255)
gc:drawRect(startX-1,startY-1,sizeX,sizeY)
gc:setColorRGB(0,0,0)
gc:drawRect(startX,startY,sizeX,sizeY)
end
function drawStep1.start(gc)
local x,y=(step1.x-1)*imgZoom+29-xScroll*imgZoom,(step1.y-1)*imgZoom+29-yScroll*imgZoom
gc:setColorRGB(255,255,255)
gc:drawLine(x-1,y,x+imgZoom-1,y+imgZoom)
gc:drawLine(x+imgZoom-1,y,x-1,y+imgZoom)
gc:setColorRGB(0,0,0)
gc:drawLine(x,y,x+imgZoom,y+imgZoom)
gc:drawLine(x+imgZoom,y,x,y+imgZoom)
end
function on.paint(gc)
if imgTable then
imgTools.drawTable(gc,30-xScroll*imgZoom,30-yScroll*imgZoom)
if tool then
drawCursor(gc)
if toolStep==2 then
drawStep1[tool](gc)
drawStep1.start(gc)
end
end
end
gc:setColorRGB(color[1],color[2],color[3])
gc:fillRect(0,0,20,15)
gc:setColorRGB(0,0,0)
gc:setPen("thin","smooth")
gc:drawRect(0,0,19,15)
drawTool(gc)
gc:setFont("sansserif","r",10)
if imgTable then
gc:drawString(changedMark..imgName.." - "..tostring(imgWidth).."x"..tostring(imgHeight).." ("..tostring(imgZoom*100).."%)",25,0,"top")
else
gc:drawString("Open or create a file",25,0,"top")
end
if status=="selectingColor" then
drawColorSelect(gc)
elseif status=="requesting" then
drawRequest(gc,requested)
elseif status=="error" then
drawError(gc)
end
gc:setColorRGB(0,0,0)
gc:setFont("sansserif","r",8)
gc:drawString("Lua nSpaint - Par LP",10,height()-12,"top")
end
Events.lua
Show/Hide spoilerAfficher/Masquer le spoiler
- Code: Select all
--EVENTS
function on.backspaceKey()
if status=="requesting" then
rqstr=string.sub(rqstr,1,string.len(rqstr)-1)
platform.window:invalidate()
end
end
function on.charIn(ch)
if status=="drawing" then
if string.find("NOS+-defphsclr",ch) then
menuAction(ch)
end
elseif status=="requesting" and string.len(rqstr)<10 and string.find("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",ch) then
rqstr=rqstr..ch
end
refresh()
end
function on.escapeKey()
if status=="drawing" then
tool=nil
else
status="drawing"
end
refresh()
end
function on.enterKey()
if status=="drawing" and tool and imgTable then
toolAction[tool]()
elseif status=="selectingColor" then
color=newColor
status="drawing"
elseif status=="requesting" then
status="drawing"
requestAction()
elseif status=="error" then
status="drawing"
end
refresh()
end
function on.arrowKey(ar)
if status=="drawing" and imgTable then
if tool then
if ar=="up" and yPos>1 then yPos=yPos-1 end
if ar=="down" and yPos<imgHeight then yPos=yPos+1 end
if ar=="left" and xPos>1 then xPos=xPos-1 end
if ar=="right" and xPos<imgWidth then xPos=xPos+1 end
else
if ar=="down" and (imgHeight-yScroll)*imgZoom>height()-45 then yScroll=yScroll+1 end
if ar=="up" and yScroll>0 then yScroll=yScroll-1 end
if ar=="right" and (imgWidth-xScroll)*imgZoom>width()-45 then xScroll=xScroll+1 end
if ar=="left" and xScroll>0 then xScroll=xScroll-1 end
end
elseif status=="selectingColor" then
if ar=="up" then
selColor=selColor-1
elseif ar=="down" then
selColor=selColor+1
elseif ar=="right" and newColor[selColor]<251 then
newColor[selColor]=newColor[selColor]+5
elseif ar=="left" and newColor[selColor]>4 then
newColor[selColor]=newColor[selColor]-5
end
if selColor>3 then
selColor=1
elseif selColor<1 then
selColor=3
end
end
refresh()
end
function on.resize()
xScroll=0
yScroll=0
end
Last edited by Chockosta on 23 Jul 2015, 19:19, edited 1 time in total.
-
ChockostaPremium
Niveau 10: GR (Guide de Référence)- Posts: 213
- Joined: 24 Feb 2011, 00:00
- Gender:
- Calculator(s):→ MyCalcs profile
- Class: Math sup
Re: (WIP) Editeur d'images
80% du temps pour les 20 premiers pourcents des choses à faire, 20% du temps pour faire les 80% restants 
Ajouter les outils va normalement te prendre que très peu de temps, mais il y en aura pas mal, bon courage

Ajouter les outils va normalement te prendre que très peu de temps, mais il y en aura pas mal, bon courage

-
LevakAdmin
Niveau 14: CI (Calculateur de l'Infini)- Posts: 6414
- Images: 22
- Joined: 27 Nov 2008, 00:00
- Location: 0x1AACC355
- Gender:
- Calculator(s):→ MyCalcs profile
- Class: BAC+5: Epita (ING3)
Re: (WIP) Editeur d'images
Mise à jour !
(Ca faisait un moment que je ne m'occupais plus de ce projet)
Nspaint 0.6
-Outil rectangle plein
-Outil cercle plein
-inverser l'image (verticalement ou horizontalement)
-tourner l'image (90° dans le sens des aiguilles d'une montre et inversement)
-apparition des filtres !
-filtre inversant les couleurs
-filtres générant une image aléatoire
DOWNLOAD
Code : (maintenant 1000 lines)
actions.lua
Data.lua
Drawing.lua
Events.lua
ImgTools.lua
Filters.lua
Functions.lua
(Ca faisait un moment que je ne m'occupais plus de ce projet)
Nspaint 0.6
-Outil rectangle plein
-Outil cercle plein
-inverser l'image (verticalement ou horizontalement)
-tourner l'image (90° dans le sens des aiguilles d'une montre et inversement)
-apparition des filtres !
-filtre inversant les couleurs
-filtres générant une image aléatoire
DOWNLOAD
Code : (maintenant 1000 lines)
actions.lua
Show/Hide spoilerAfficher/Masquer le spoiler
- Code: Select all
--MISC ACTIONS
function menuShortcut(action)
if string.find("NOS",action) then
fileAction(action)
elseif string.find("+-",action) then
setZoom(action)
elseif string.find("defpclr",action) then
selectTool(action)
elseif string.find("hs",action) then
setColor(action)
end
refresh()
end
function fileAction(action)
if action=="N" then
status="requesting"
rqstr=""
requested="Image width"
elseif action=="O" then
status="requesting"
rqstr=""
requested="File name"
elseif action=="S" then
if not imgTable then
status="error"
errtype="No opened file"
else
status="requesting"
rqstr=imgName
requested="Save as"
end
end
refresh()
end
function setColor(action)
if action=="h" then
status="requesting"
rqstr=""
requested="Hex code"
elseif action=="s" then
status="selectingColor"
selColor=1
newColor={math.floor(color[1]/5)*5,math.floor(color[2]/5)*5,math.floor(color[3]/5)*5}
end
refresh()
end
function setZoom(action)
if action=="+" then --Zoom in
if imgZoom<8 then
xScroll=0
yScroll=0
imgZoom=imgZoom*2
end
elseif action=="-" then --Zoom out
if imgZoom>1 then
xScroll=0
yScroll=0
imgZoom=imgZoom/2
end
end
refresh()
end
function applyFilter(filterID)
end
function selectTool(toolID)
toolStep=1
if toolID=="d" then
tool="draw"
elseif toolID=="e" then
tool="erase"
elseif toolID=="f" then
tool="fill"
elseif toolID=="p" then
tool="pick"
elseif toolID=="c" then
tool="circle"
elseif toolID=="l" then
tool="line"
elseif toolID=="r" then
tool="rect"
elseif toolID=="fr" then
tool="frect"
elseif toolID=="fc" then
tool="fcircle"
end
refresh()
end
toolAction={}
function toolAction.draw()
imgTable[xPos][yPos]={1,math.floor(color[1]/8),math.floor(color[2]/8),math.floor(color[3]/8)}
changedMark="*"
end
function toolAction.erase()
imgTable[xPos][yPos][1]=0
changedMark="*"
end
function toolAction.pick()
if imgTable[xPos][yPos][1]==0 then
color={255,255,255}
else
color={imgTable[xPos][yPos][2]*8,imgTable[xPos][yPos][3]*8,imgTable[xPos][yPos][4]*8}
end
end
function toolAction.fill()
fillPixel(xPos,yPos)
end
function toolAction.rect()
if toolStep==1 then
toolStep=2
step1.x,step1.y=xPos,yPos
else
toolStep=1
drawRect(step1.x,step1.y,xPos,yPos)
end
end
function toolAction.circle()
if toolStep==1 then
toolStep=2
step1.x,step1.y=xPos,yPos
else
toolStep=1
drawCircle(step1.x,step1.y,xPos,yPos)
end
end
function toolAction.line()
if toolStep==1 then
toolStep=2
step1.x,step1.y=xPos,yPos
else
toolStep=1
drawLine(step1.x,step1.y,xPos,yPos)
end
end
function toolAction.frect()
if toolStep==1 then
toolStep=2
step1.x,step1.y=xPos,yPos
else
toolStep=1
fillRect(step1.x,step1.y,xPos,yPos)
end
end
function toolAction.fcircle()
if toolStep==1 then
toolStep=2
step1.x,step1.y=xPos,yPos
else
toolStep=1
fillCircle(step1.x,step1.y,xPos,yPos)
end
end
function requestAction()
if requested=="Hex code" then
loadHexColor()
elseif requested=="Image width" then
if tonumber(rqstr) and tonumber(rqstr)~=0 then
tempVarWidth=tonumber(rqstr)
status="requesting"
requested="Image height"
rqstr=""
else
status="error"
errtype="Invalid number"
end
elseif requested=="Image height" then
if tonumber(rqstr) and tonumber(rqstr)~=0 then
if tonumber(rqstr)*tempVarWidth>3000 then
status="error"
errtype="Overflow (3000 px max)"
else
file.new()
end
else
status="error"
errtype="Invalid number"
end
elseif requested=="File name" then
rqstr=string.lower(rqstr)
file.load()
elseif requested=="Save as" then
rqstr=string.lower(rqstr)
file.save()
end
end
Data.lua
Show/Hide spoilerAfficher/Masquer le spoiler
- Code: Select all
--DATA
--drawing
status="drawing"
tool=nil
xPos=1
yPos=1
xScroll=0
yScroll=0
color={225,170,0}
changedMark=""
--image
imgString=nil
imgTable=nil
imgZoom=1
imgName=""
--color select
newColor={200,100,255}
selColor=1
--text request
requested=""
rqstr=""
--error
errtype=""
--tools
toolStep=1
step1={x=1,y=1}
--tools sprites
toolsSprites={}
toolsSprites.move=image.new("\020\000\000\000\020\000\000\000\000\000\000\000(\000\000\000\016\000\001\000\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128_\202\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\000\128_\202_\202_\202\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\000\128\000\128\000\128_\202\000\128\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128_\202\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\000\128\255\255\255\255\255\255\000\128_\202\000\128\255\255\255\255\255\255\000\128\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\000\128\000\128\255\255\255\255\255\255\000\128_\202\000\128\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\000\128\000\128\255\255\000\128_\202\000\128\000\128\000\128\000\128\000\128_\202\000\128\000\128\000\128\000\128\000\128_\202\000\128\255\255\255\255\000\128\000\128\000\128_\202_\202_\202_\202_\202_\202_\202_\202_\202_\202_\202_\202_\202_\202_\202\000\128\255\255\000\128\000\128\255\255\000\128_\202\000\128\000\128\000\128\000\128\000\128_\202\000\128\000\128\000\128\000\128\000\128_\202\000\128\255\255\255\255\000\128\000\128\255\255\255\255\000\128\000\128\255\255\255\255\255\255\000\128_\202\000\128\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\000\128\255\255\255\255\255\255\000\128_\202\000\128\255\255\255\255\255\255\000\128\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128_\202\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\000\128\000\128\000\128_\202\000\128\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\000\128_\202_\202_\202\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128_\202\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128")
toolsSprites.draw=image.new("\020\000\000\000\020\000\000\000\000\000\000\000(\000\000\000\016\000\001\000\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\011\202N\218-\214-\210\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\167\193p\230Z\255\148\254h\225e\185\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\234\197\145\222Y\255\148\254\140\253\164\240\001\173\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\167\189L\214\024\227\247\226\173\249\132\252$\209\012\202\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\168\193(\214\206\238h\230\213\218\239\229\226\208\234\197\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\168\193\008\210\238\238g\234#\226*\210\202\209\200\193\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\200\193\231\205\238\242h\234$\226\162\201B\185\168\193\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\200\193\231\205\238\242\136\234#\226\162\201\034\185\201\197\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\168\193\231\205\238\242\136\234#\226\162\201!\181\234\197\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\167\193\007\210\238\242\136\234#\226\162\201!\181\011\202\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\167\189(\214\238\238\136\234$\226\162\201!\181\011\202\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\012\202)\210\204\238g\234$\226\162\201!\181\235\201\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\134\189\240\230u\243\170\234\130\197B\185\202\197\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\232\201\016\235S\243\016\239A\185\168\193\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\012\202\144\214\208\230\008\210#\181\234\197\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\168\193\167\193e\185O\210\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\000\128\255\255\255\255\000\128\255\255\255\255\000\128\255\255\255\255\000\128\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128")
toolsSprites.erase=image.new("\020\000\000\000\020\000\000\000\000\000\000\000(\000\000\000\016\000\001\000\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255y\182\215\157\215\157\214\157\214\157\214\157\214\157\214\157\181\157\180\153z\190\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255y\186\215\157\028\215\219\206\219\202\219\202\219\202\219\202\219\202\219\202\219\202/\149Y\182\255\255\000\128\000\128\255\255\255\255\255\255\219\202\215\157<\219\187\198\187\198\187\198\187\198\187\198\187\198\187\198\186\198\028\215\154\190Q\149\255\255\000\128\000\128\255\255\255\255\255\255P\149<\219\219\202\187\198\187\198\187\198\187\198\187\198\187\198\187\198\187\198\028\215\024\170Q\149\255\255\000\128\000\128\255\255\255\255P\149<\219<\219\180\238\180\238\180\242\180\242\180\242\180\242\180\242\147\242\028\215\187\198\024\170Q\149\255\255\000\128\000\128\255\255\255\255\173\245\023\247\180\242\180\242\180\242\180\242\180\242\180\242\180\242\147\242\180\242\023\243r\242\024\170Q\149\255\255\000\128\000\128\255\255\238\245r\246\214\242\180\238\180\242\180\242\180\242\180\242\180\242\180\242\147\242\213\242\147\246r\242Q\149\255\255\255\255\000\128\000\128\255\255Q\246\024\247\180\242\180\242\180\242\148\242\148\242\148\242\147\242\147\242\180\242\246\242r\242\015\242Q\149\255\255\255\255\000\128\000\128\255\255\239\245\246\242\180\242\180\242\180\242\180\242\148\242\147\242\148\246\147\246\181\246\214\246r\246\198\248\255\255\255\255\255\255\000\128\000\128\255\255\238\2459\2478\2518\2518\2518\2518\2518\2518\2518\251\023\251R\250\173\245)\237\255\255\255\255\255\255\000\128\000\128\255\255\140\245\016\254\207\253\239\253\239\253\239\253\239\253\239\253\239\253\239\253\206\253\206\249\231\244\255\255\255\255\255\255\255\255\000\128\000\128\255\255k\245R\2501\2501\2501\2501\2501\2501\2501\2501\2501\250\140\249(\233\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\198\248\166\248\198\248\198\248\198\248\198\248\198\248\198\248\198\248\198\248\198\244\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128")
toolsSprites.pick=image.new("\020\000\000\000\020\000\000\000\000\000\000\000(\000\000\000\016\000\001\000\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\232\148.\153+\157k\173\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\198\148r\153O\153\232\148\166\148\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\2550\194J\169m\165\010\149O\153\199\148\198\148\165\144\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\007\161r\149\199\148\199\148\165\144\008\157\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255r\206\189\247)\161\198\148\199\152\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\147\210Z\235\157\239:\227\231\152\231\152\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\180\2149\231\190\243\249\2181\198\255\255)\161\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\180\214\182\206<\223\151\202R\202\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\180\2144\186\215\161r\149\017\190\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\179\214U\186\247\161\147\1532\194\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\147\210V\190\214\161\147\1532\194\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\015\194\182\157\148\1531\194\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255r\206\026\223\240\1891\194\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\210\169\240\185\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\2551\198\212\165n\161\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\018\1867\178n\161\175\173\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\2552\194\217\206X\182\246\169\011\153\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\2552\1947\178X\178\147\157L\161\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128")
toolsSprites.fill=image.new("\020\000\000\000\020\000\000\000\000\000\000\000(\000\000\000\016\000\001\000\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\147\210Q\202\146\210r\2060\198\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\246\222Q\202\255\255\255\255\255\255\255\255\173\181\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\245\222\139\177Q\202R\202\180\214\255\255\139\177\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\2557\231\172\1811\198\156\243\223\255\206\185\255\255\139\177\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255Q\206\239\189\148\210R\202Z\235{\239Y\231Q\202\140\177\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\246\222\173\181\247\222\255\255\214\2181\198Z\235\024\227\222\251\016\194\139\177\255\255\255\255\255\255\000\128\000\128\255\255\000\240\000\2401\242\016\190\255\255\255\255\222\251\148\2100\198Z\2359\231Z\235\189\247k\173\255\255\255\255\255\255\000\128\000\1281\2421\242\206\1859\231\255\255\222\251\255\255\247\222\140\177\140\177\148\2109\231\024\227\189\247\147\206\212\218\255\255\255\255\000\128\000\128\000\2401\242\023\227\222\251{\239\189\247\189\247\173\181\016\194R\202\173\181\247\222Z\2359\231\222\251\015\190\255\255\255\255\000\128\000\128\000\2401\242\015\194\156\243{\239\156\243\156\243\173\181R\202\148\210\206\185\024\227Z\2359\231{\2398\231Q\202\255\255\000\128\000\128\000\2401\242\212\218s\206\189\247Z\235\156\243\246\218\206\185\206\185\148\210{\239{\239Z\2359\231\156\243r\206\245\222\000\128\000\128\000\2401\242\255\255\238\189\156\243{\239{\239\189\247{\239{\239\156\243\156\243{\239Z\2359\231Z\235Y\231\172\181\000\128\000\128\000\2401\242\255\255\255\255\239\189\255\255Z\235\156\243\255\255\255\255\222\251\189\247\156\243{\239Z\235\189\2479\231j\173\000\128\000\128\000\2401\242\255\255\255\255P\1989\231\156\243{\239\189\247\255\255\222\251\189\247\156\243\156\243\255\255\247\222\206\185\255\255\000\128\000\128\000\240\255\255\255\255\255\255\255\255\173\181\255\255Z\235\156\243\222\251\255\255\222\251\222\251\189\247\238\189\146\210\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\179\214\214\218\189\247{\239\189\247\255\255\222\251\181\214\238\189\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\205\185\156\243\156\243\156\2439\231\239\189\146\210\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255s\206\255\255\148\210\205\185\180\214\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128")
toolsSprites.circle=image.new("\020\000\000\000\020\000\000\000\000\000\000\000(\000\000\000\016\000\001\000\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\031\130\031\130\031\130\031\130\031\130\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\031\130\031\130\255\255\255\255\255\255\255\255\255\255\031\130\031\130\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\031\130\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\031\130\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\031\130\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\031\130\255\255\255\255\255\255\000\128\000\128\255\255\255\255\031\130\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\031\130\255\255\255\255\255\255\000\128\000\128\255\255\031\130\255\255\255\255\255\255\255\255\255\255\255\255\000\128\255\255\255\255\255\255\255\255\255\255\255\255\031\130\255\255\255\255\000\128\000\128\255\255\031\130\255\255\255\255\255\255\255\255\255\255\255\255\000\128\255\255\255\255\255\255\255\255\255\255\255\255\031\130\255\255\255\255\000\128\000\128\255\255\031\130\255\255\255\255\255\255\255\255\000\128\000\128\000\128\000\128\000\128\255\255\255\255\255\255\255\255\031\130\255\255\255\255\000\128\000\128\255\255\031\130\255\255\255\255\255\255\255\255\255\255\255\255\000\128\255\255\255\255\255\255\255\255\255\255\255\255\031\130\255\255\255\255\000\128\000\128\255\255\031\130\255\255\255\255\255\255\255\255\255\255\255\255\000\128\255\255\255\255\255\255\255\255\255\255\255\255\031\130\255\255\255\255\000\128\000\128\255\255\255\255\031\130\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\031\130\255\255\255\255\255\255\000\128\000\128\255\255\255\255\031\130\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\031\130\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\031\130\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\031\130\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\031\130\031\130\255\255\255\255\255\255\255\255\255\255\031\130\031\130\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\031\130\031\130\031\130\031\130\031\130\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128")
toolsSprites.line=image.new("\020\000\000\000\020\000\000\000\000\000\000\000(\000\000\000\016\000\001\000\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\000\128\000\128\000\128\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\000\128\031\130\031\130\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\000\128\255\255\031\130\031\130\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\031\130\031\130\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\031\130\031\130\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\031\130\031\130\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\031\130\031\130\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\031\130\031\130\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\031\130\031\130\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\031\130\031\130\000\128\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\031\130\000\128\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\000\128\000\128\000\128\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128")
toolsSprites.rect=image.new("\020\000\000\000\020\000\000\000\000\000\000\000(\000\000\000\016\000\001\000\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\000\128\000\128\000\128\000\128\000\128\031\130\031\130\031\130\031\130\031\130\031\130\031\130\031\130\031\130\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\031\130\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\031\130\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\031\130\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\031\130\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\031\130\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\031\130\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\031\130\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\031\130\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\031\130\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\031\130\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\031\130\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\031\130\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\031\130\031\130\031\130\031\130\031\130\031\130\031\130\031\130\031\130\000\128\000\128\000\128\000\128\000\128\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128")
toolsSprites.frect=image.new("\020\000\000\000\020\000\000\000\000\000\000\000(\000\000\000\016\000\001\000\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\000\128\000\128\000\128\000\128\000\128\031\130\031\130\031\130\031\130\031\130\031\130\031\130\031\130\031\130\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\000\128\241\199\241\199\241\199\241\199\241\199\241\199\241\199\241\199\241\199\241\199\031\130\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\000\128\241\199\241\199\241\199\241\199\241\199\241\199\241\199\241\199\241\199\241\199\031\130\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\031\130\241\199\241\199\241\199\241\199\241\199\241\199\241\199\241\199\241\199\241\199\031\130\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\031\130\241\199\241\199\241\199\241\199\241\199\241\199\241\199\241\199\241\199\241\199\031\130\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\031\130\241\199\241\199\241\199\241\199\241\199\241\199\241\199\241\199\241\199\241\199\031\130\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\031\130\241\199\241\199\241\199\241\199\241\199\241\199\241\199\241\199\241\199\241\199\031\130\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\031\130\241\199\241\199\241\199\241\199\241\199\241\199\241\199\241\199\241\199\241\199\000\128\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\031\130\241\199\241\199\241\199\241\199\241\199\241\199\241\199\241\199\241\199\241\199\000\128\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\031\130\031\130\031\130\031\130\031\130\031\130\031\130\031\130\031\130\000\128\000\128\000\128\000\128\000\128\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128")
toolsSprites.fcircle=image.new("\020\000\000\000\020\000\000\000\000\000\000\000(\000\000\000\016\000\001\000\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\031\130\031\130\031\130\031\130\031\130\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\031\130\031\130\241\199\241\199\241\199\241\199\241\199\031\130\031\130\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\031\130\241\199\241\199\241\199\241\199\241\199\241\199\241\199\241\199\241\199\031\130\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\031\130\241\199\241\199\241\199\241\199\241\199\241\199\241\199\241\199\241\199\241\199\241\199\031\130\255\255\255\255\255\255\000\128\000\128\255\255\255\255\031\130\241\199\241\199\241\199\241\199\241\199\241\199\241\199\241\199\241\199\241\199\241\199\031\130\255\255\255\255\255\255\000\128\000\128\255\255\031\130\241\199\241\199\241\199\241\199\241\199\241\199\000\128\241\199\241\199\241\199\241\199\241\199\241\199\031\130\255\255\255\255\000\128\000\128\255\255\031\130\241\199\241\199\241\199\241\199\241\199\241\199\000\128\241\199\241\199\241\199\241\199\241\199\241\199\031\130\255\255\255\255\000\128\000\128\255\255\031\130\241\199\241\199\241\199\241\199\000\128\000\128\000\128\000\128\000\128\241\199\241\199\241\199\241\199\031\130\255\255\255\255\000\128\000\128\255\255\031\130\241\199\241\199\241\199\241\199\241\199\241\199\000\128\241\199\241\199\241\199\241\199\241\199\241\199\031\130\255\255\255\255\000\128\000\128\255\255\031\130\241\199\241\199\241\199\241\199\241\199\241\199\000\128\241\199\241\199\241\199\241\199\241\199\241\199\031\130\255\255\255\255\000\128\000\128\255\255\255\255\031\130\241\199\241\199\241\199\241\199\241\199\241\199\241\199\241\199\241\199\241\199\241\199\031\130\255\255\255\255\255\255\000\128\000\128\255\255\255\255\031\130\241\199\241\199\241\199\241\199\241\199\241\199\241\199\241\199\241\199\241\199\241\199\031\130\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\031\130\241\199\241\199\241\199\241\199\241\199\241\199\241\199\241\199\241\199\031\130\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\031\130\031\130\241\199\241\199\241\199\241\199\241\199\031\130\031\130\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\031\130\031\130\031\130\031\130\031\130\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128")
--MENU
menu={
{"File",
{"New (Shift+n)",function() fileAction("N") end},
{"Open (Shift+o)",function() fileAction("O") end},
{"Save (Shift+s)",function() fileAction("S") end}
},
{"Edit",
{"Zoom in (+)",function() setZoom("+") end},
{"Zoom out (-)",function() setZoom("-") end},
{"Erase all",function() eraseImg() end}
},
{"Tools",
{"Draw (d)",function() selectTool("d") end},
{"Erase (e)",function() selectTool("e") end},
{"Fill (f)",function() selectTool("f") end},
{"Color Pick (p)",function() selectTool("p") end},
{"Circle (c)",function() selectTool("c") end},
{"Line (l)",function() selectTool("l") end},
{"Rectangle (r)",function() selectTool("r") end},
{"Fill rectangle",function() selectTool("fr") end},
{"Fill circle",function() selectTool("fc") end}
},
{"Color",
{"Hexadecimal (h)",function() setColor("h") end},
{"Select (s)",function() setColor("s") end}
},
{"Image",
{"Flip vertically",function() flipV() end},
{"Flip horizontally",function() flipH() end},
{"Rotate 90° clockwise",function() rotateImg("c") end},
{"Rotate 90° counter-clockwise",function() rotateImg("cc") end}
},
{"Filters",
{"Invert colors",function() applyFilter("i") end},
{"Random image", function() applyFilter("r") end}
}}
toolpalette.register(menu)
Drawing.lua
Show/Hide spoilerAfficher/Masquer le spoiler
- Code: Select all
--DRAWING
function drawColorSelect(gc)
gc:setColorRGB(200,200,255)
gc:fillRect(width()/2-75,height()/2-50,150,100)
gc:setColorRGB(0,0,0)
gc:fillRect(width()/2-75,height()/2-50,150,15)
gc:setPen("thin","smooth")
gc:drawRect(width()/2-75,height()/2-50,150,100)
gc:setFont("sansserif","r",10)
gc:setColorRGB(255,255,255)
gc:drawString("Select your color",width()/2-73,height()/2-53,"top")
gc:setColorRGB(0,0,0)
gc:drawString("Red :",width()/2-73,height()/2-35,"top")
gc:drawString("Green :",width()/2-73,height()/2-20,"top")
gc:drawString("Blue :",width()/2-73,height()/2-5,"top")
for i=0,63 do
gc:setColorRGB(i*4,newColor[2],newColor[3])
gc:fillRect(width()/2-23+i,height()/2-30,1,10)
gc:setColorRGB(newColor[1],i*4,newColor[3])
gc:fillRect(width()/2-23+i,height()/2-15,1,10)
gc:setColorRGB(newColor[1],newColor[2],i*4)
gc:fillRect(width()/2-23+i,height()/2,1,10)
end
gc:setColorRGB(0,0,0)
gc:drawRect(width()/2-23,height()/2-46+selColor*15,64,11)
for i=1,3 do
gc:drawString(tostring(newColor[i]),width()/2+52,height()/2-50+i*15,"top")
gc:fillRect(width()/2-24+newColor[i]/4,height()/2-47+i*15,3,14)
end
gc:setColorRGB(color[1],color[2],color[3])
gc:fillRect(width()/2-70,height()/2+20,30,20)
gc:setColorRGB(newColor[1],newColor[2],newColor[3])
gc:fillRect(width()/2-28,height()/2+20,30,20)
gc:setColorRGB(0,0,0)
gc:drawRect(width()/2-70,height()/2+20,30,20)
gc:drawRect(width()/2-28,height()/2+20,30,20)
gc:drawString(mathTools.int2Hex(math.floor(newColor[1]/16))..mathTools.int2Hex(newColor[1]%16)..mathTools.int2Hex(math.floor(newColor[2]/16))..mathTools.int2Hex(newColor[2]%16)..mathTools.int2Hex(math.floor(newColor[3]/16))..mathTools.int2Hex(newColor[3]%16),width()/2+20,height()/2+20,"top")
gc:drawString("Old New",width()/2-65,height()/2+21,"top")
end
function drawRequest(gc,msg)
gc:setColorRGB(200,200,255)
gc:fillRect(width()/2-75,height()/2-25,150,50)
gc:setColorRGB(0,0,0)
gc:setPen("thin","smooth")
gc:drawRect(width()/2-75,height()/2-25,150,50)
gc:fillRect(width()/2-75,height()/2-25,150,15)
gc:setFont("sansserif","r",10)
gc:setColorRGB(255,255,255)
gc:drawString(msg,width()/2-70,height()/2-28,"top")
gc:setColorRGB(0,0,0)
gc:drawRect(width()/2-70,height()/2,140,20)
gc:drawString(rqstr,width()/2-65,height()/2,"top")
end
function drawError(gc)
gc:setColorRGB(200,200,255)
gc:fillRect(width()/2-75,height()/2-20,150,40)
gc:setColorRGB(0,0,0)
gc:setPen("thin","smooth")
gc:drawRect(width()/2-75,height()/2-20,150,40)
gc:fillRect(width()/2-75,height()/2-20,150,15)
gc:setFont("sansserif","r",10)
gc:setColorRGB(255,255,255)
gc:drawString("Error",width()/2-73,height()/2-23,"top")
gc:setColorRGB(0,0,0)
gc:drawString(errtype,width()/2-70,height()/2-5,"top")
end
function drawCursor(gc)
gc:setColorRGB(0,0,0)
gc:setPen("thin","smooth")
gc:drawRect((xPos-1)*imgZoom+29-xScroll*imgZoom,(yPos-1)*imgZoom+29-yScroll*imgZoom,imgZoom+1,imgZoom+1)
gc:setColorRGB(255,255,255)
gc:drawRect((xPos-1)*imgZoom+30-xScroll*imgZoom,(yPos-1)*imgZoom+30-yScroll*imgZoom,imgZoom-1,imgZoom-1)
end
function drawTool(gc)
local id=tool
if not id then
id="move"
end
gc:drawImage(toolsSprites[id],0,15)
end
drawStep1={}
function drawStep1.circle(gc)
local rayon=math.sqrt((xPos-step1.x)*(xPos-step1.x)+(yPos-step1.y)*(yPos-step1.y))
local startX,startY,size
startX,startY=(step1.x-rayon-0.6)*imgZoom+30-xScroll*imgZoom,(step1.y-rayon-0.6)*imgZoom+30-yScroll*imgZoom
size=2*rayon*imgZoom
gc:setColorRGB(255,255,255)
gc:drawArc(startX-1,startY-1,size,size,0,360)
gc:setColorRGB(0,0,0)
gc:drawArc(startX,startY,size,size,0,360)
end
function drawStep1.line(gc)
gc:setColorRGB(255,255,255)
gc:drawLine((step1.x-0.6)*imgZoom+30-xScroll*imgZoom,(step1.y-0.6)*imgZoom+30-yScroll*imgZoom,(xPos-0.6)*imgZoom+30-xScroll*imgZoom,(yPos-0.6)*imgZoom+30-yScroll*imgZoom)
gc:setColorRGB(0,0,0)
gc:drawLine((step1.x-0.6)*imgZoom+29-xScroll*imgZoom,(step1.y-0.6)*imgZoom+29-yScroll*imgZoom,(xPos-0.6)*imgZoom+29-xScroll*imgZoom,(yPos-0.6)*imgZoom+29-yScroll*imgZoom)
end
function drawStep1.rect(gc)
local startX,startY,sizeX,sizeY,lowerY,higherY
lowerX,lowerY=xPos<step1.x and xPos or step1.x,yPos<step1.y and yPos or step1.y
startX,startY=(lowerX-0.6)*imgZoom+30-xScroll*imgZoom,(lowerY-0.6)*imgZoom+30-yScroll*imgZoom
sizeX,sizeY=math.abs((xPos-step1.x)*imgZoom),math.abs((yPos-step1.y)*imgZoom)
gc:setColorRGB(255,255,255)
gc:drawRect(startX-1,startY-1,sizeX,sizeY)
gc:setColorRGB(0,0,0)
gc:drawRect(startX,startY,sizeX,sizeY)
end
function drawStep1.frect(gc)
drawStep1.rect(gc)
end
function drawStep1.fcircle(gc)
drawStep1.circle(gc)
end
function drawStep1.start(gc)
local x,y=(step1.x-1)*imgZoom+29-xScroll*imgZoom,(step1.y-1)*imgZoom+29-yScroll*imgZoom
gc:setColorRGB(255,255,255)
gc:drawLine(x-1,y,x+imgZoom-1,y+imgZoom)
gc:drawLine(x+imgZoom-1,y,x-1,y+imgZoom)
gc:setColorRGB(0,0,0)
gc:drawLine(x,y,x+imgZoom,y+imgZoom)
gc:drawLine(x+imgZoom,y,x,y+imgZoom)
end
function on.paint(gc)
if imgTable then
imgTools.drawTable(gc,30-xScroll*imgZoom,30-yScroll*imgZoom)
if tool then
drawCursor(gc)
if toolStep==2 then
drawStep1[tool](gc)
drawStep1.start(gc)
end
end
end
gc:setColorRGB(color[1],color[2],color[3])
gc:fillRect(0,0,20,15)
gc:setColorRGB(0,0,0)
gc:setPen("thin","smooth")
gc:drawRect(0,0,19,15)
drawTool(gc)
gc:setFont("sansserif","r",10)
if imgTable then
gc:drawString(changedMark..imgName.." - "..tostring(imgWidth).."x"..tostring(imgHeight).." ("..tostring(imgZoom*100).."%)",25,0,"top")
else
gc:drawString("Open or create a file",25,0,"top")
end
if status=="selectingColor" then
drawColorSelect(gc)
elseif status=="requesting" then
drawRequest(gc,requested)
elseif status=="error" then
drawError(gc)
end
gc:setColorRGB(0,0,0)
gc:setFont("sansserif","r",8)
gc:drawString("Lua nSpaint - Par LP",10,height()-12,"top")
end
Events.lua
Show/Hide spoilerAfficher/Masquer le spoiler
- Code: Select all
--EVENTS
function on.backspaceKey()
if status=="requesting" then
rqstr=string.sub(rqstr,1,string.len(rqstr)-1)
refresh()
end
end
function on.charIn(ch)
ch=ch=="(" and " " or ch --avoid patterns
if status=="drawing" then
if string.find("NOS+-defphsclr",ch) then
menuShortcut(ch)
end
elseif status=="requesting" and string.len(rqstr)<10 and string.find("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",ch) then
rqstr=rqstr..ch
end
refresh()
end
function on.escapeKey()
if status=="drawing" then
tool=nil
else
status="drawing"
end
refresh()
end
function on.enterKey()
if status=="drawing" and tool and imgTable then
toolAction[tool]()
elseif status=="selectingColor" then
color=newColor
status="drawing"
elseif status=="requesting" then
status="drawing"
requestAction()
elseif status=="error" then
status="drawing"
end
refresh()
end
function on.arrowKey(ar)
if status=="drawing" and imgTable then
if tool then
if ar=="up" and yPos>1 then yPos=yPos-1 end
if ar=="down" and yPos<imgHeight then yPos=yPos+1 end
if ar=="left" and xPos>1 then xPos=xPos-1 end
if ar=="right" and xPos<imgWidth then xPos=xPos+1 end
else
if ar=="down" and (imgHeight-yScroll)*imgZoom>height()-45 then yScroll=yScroll+1 end
if ar=="up" and yScroll>0 then yScroll=yScroll-1 end
if ar=="right" and (imgWidth-xScroll)*imgZoom>width()-45 then xScroll=xScroll+1 end
if ar=="left" and xScroll>0 then xScroll=xScroll-1 end
end
elseif status=="selectingColor" then
if ar=="up" then
selColor=selColor-1
elseif ar=="down" then
selColor=selColor+1
elseif ar=="right" and newColor[selColor]<251 then
newColor[selColor]=newColor[selColor]+5
elseif ar=="left" and newColor[selColor]>4 then
newColor[selColor]=newColor[selColor]-5
end
if selColor>3 then
selColor=1
elseif selColor<1 then
selColor=3
end
end
refresh()
end
function on.resize()
xScroll=0
yScroll=0
end
ImgTools.lua
Show/Hide spoilerAfficher/Masquer le spoiler
- Code: Select all
imgTools={}
function imgTools.getPixel(byte1,byte2)
local str2
str2=imgTools.addZeros(mathTools.base10to2(tonumber(byte2)),8)..imgTools.addZeros(mathTools.base10to2(tonumber(byte1)),8)
return {tonumber(string.sub(str2,1,1)),mathTools.base2to10(string.sub(str2,2,6)),mathTools.base2to10(string.sub(str2,7,11)),mathTools.base2to10(string.sub(str2,12,16))}
end
function imgTools.getSize(img)
imgWidth=mathTools.base2to10(mathTools.base10to2(tonumber(string.sub(img,10,12)..string.sub(img,7,9)..string.sub(img,4,6)..string.sub(img,1,3))))
imgHeight=mathTools.base2to10(mathTools.base10to2(tonumber(string.sub(img,22,24)..string.sub(img,19,21)..string.sub(img,16,18)..string.sub(img,13,15))))
end
function imgTools.addZeros(str,strSize)
return string.rep("0",strSize-string.len(str))..str
end
function imgTools.convertChars(img)
local finished,img2,index
index=1
img2=""
finished=nil
while not finished do
if string.sub(img,index,index)~=[[\]] then
img2=img2..imgTools.addZeros(tostring(string.byte(string.sub(img,index,index))),3)
index=index+1
else
img2=img2..string.sub(img,index+1,index+3)
index=index+4
end
if index>string.len(img) then
finished=1
end
end
return img2
end
function imgTools.generateHeader()
local binaryHeader,header
binaryHeader={}
binaryHeader[1]=imgTools.addZeros(mathTools.base10to2(imgWidth),32)
binaryHeader[2]=imgTools.addZeros(mathTools.base10to2(imgHeight),32)
binaryHeader[3]=imgTools.addZeros(mathTools.base10to2(imgWidth*2),32)
header={"","",""}
for i=1,3 do
for j=3,0,-1 do
header[i]=header[i]..imgTools.addZeros(tostring(mathTools.base2to10(string.sub(binaryHeader[i],8*j+1,8*(j+1)))),3)
end
end
return header[1]..header[2].."000000000000"..header[3].."016000001000"
end
function imgTools.convertPixel(pixel)
local str
str=tostring(pixel[1])..imgTools.addZeros(mathTools.base10to2(pixel[2]),5)..imgTools.addZeros(mathTools.base10to2(pixel[3]),5)..imgTools.addZeros(mathTools.base10to2(pixel[4]),5)
return imgTools.addZeros(tostring(mathTools.base2to10(string.sub(str,9,16))),3)..imgTools.addZeros(tostring(mathTools.base2to10(string.sub(str,1,8))),3)
end
function imgTools.addSlashes(str)
local finished,str2,index
finished=nil
str2=[[\]]..str
index=1
while not finished do
index=index+4
if index>string.len(str2) then
finished=1
else
str2=string.sub(str2,1,index-1)..[[\]]..string.sub(str2,index)
end
end
return str2
end
function imgTools.img2table(str)
local index
str2=imgTools.convertChars(str)
imgTable={}
imgTools.getSize(str2)
for i=1,imgWidth do
imgTable[i]={}
for j=1,imgHeight do
index=(i-1)*6+61+(j-1)*6*imgWidth
imgTable[i][j]=imgTools.getPixel(string.sub(str2,index,index+2),string.sub(str2,index+3,index+5))
end
end
end
function imgTools.drawTable(gc,x,y)
gc:setColorRGB(0,0,0)
gc:setPen("thin","dashed")
gc:drawRect(x-1,y-1,imgWidth*imgZoom+1,imgHeight*imgZoom+1)
gc:setPen("thin","smooth")
for i=1,imgWidth do
for j=1,imgHeight do
if imgTable[i][j][1]==1 then
gc:setColorRGB(math.floor(imgTable[i][j][2]*255/31),math.floor(imgTable[i][j][3]*255/31),math.floor(imgTable[i][j][4]*255/31))
gc:fillRect((i-1)*imgZoom+x,(j-1)*imgZoom+y,imgZoom,imgZoom)
else
gc:setColorRGB(175,175,175)
for k=0,imgZoom-1 do
gc:fillRect((i-1)*imgZoom+x+k,(j-1)*imgZoom+y+k,1,1)
end
end
end
end
end
function imgTools.table2img()
local imgStr
imgStr=imgTools.generateHeader()
for i=1,imgHeight do
for j=1,imgWidth do
imgStr=imgStr..imgTools.convertPixel(imgTable[j][i])
end
end
return imgTools.addSlashes(imgStr)
end
Filters.lua
Show/Hide spoilerAfficher/Masquer le spoiler
- Code: Select all
function applyFilter(filterID)
if imgTable then
if filterID=="i" then
filters.invertColors()
elseif filterID=="r" then
filters.randomImg()
end
changedMark="*"
refresh()
end
end
filters={}
function filters.invertColors()
for i=1,imgWidth do
for j=1,imgHeight do
local previous=copyTable(imgTable[i][j])
imgTable[i][j]={previous[1],31-previous[2],31-previous[3],31-previous[4]}
end
end
end
function filters.randomImg()
for i=1,imgWidth do
for j=1,imgHeight do
local previous=copyTable(imgTable[i][j])
imgTable[i][j]={1,math.random(0,31),math.random(0,31),math.random(0,31)}
end
end
end
Functions.lua
Show/Hide spoilerAfficher/Masquer le spoiler
- Code: Select all
--MATHTOOLS
mathTools={}
function mathTools.base10to2(n)
local str
str=""
if n~=0 then
while n~=1 do
str=str..tostring(n%2)
n=math.floor(n/2)
end
str=str..tostring(n%2)
return string.reverse(str)
else
return "0"
end
end
function mathTools.base2to10(n)
local num = 0
local ex = string.len(n) - 1
local l = 0
l = ex + 1
for i = 1, l do
b = string.sub(n, i, i)
if b == "1" then
num = num + 2^ex
end
ex = ex - 1
end
return num
end
function mathTools.int2Hex(int)
if int<10 then
return tostring(int)
else
if int==10 then return "A"
elseif int==11 then return "B"
elseif int==12 then return "C"
elseif int==13 then return "D"
elseif int==14 then return "E"
elseif int==15 then return "F"
end
end
end
--FILE
file={}
function file.save()
if rqstr=="" then
status="error"
errtype="Please type a name"
elseif string.find("0123456789",string.sub(rqstr,1,1)) then
status="error"
errtype="Invalid name"
else
imgString=imgTools.table2img()
var.store(rqstr,imgString)
imgName=rqstr
changedMark=""
end
end
function file.load()
local test
test=var.recall(rqstr)
if not test then
status="error"
errtype="File does not exist"
elseif type(test)~="string" then
status="error"
errtype="Invalid file"
else
imgZoom=1
xPos=1
yPos=1
xScroll=0
yScroll=0
tool=nil
changedMark=""
imgString=test
imgTools.img2table(imgString)
imgName=rqstr
end
end
function file.new()
imgWidth=tempVarWidth
imgHeight=tonumber(rqstr)
imgZoom=1
xPos=1
yPos=1
xScroll=0
yScroll=0
tool=nil
changedMark=""
imgName="unsaved"
imgTable={}
for i=1,imgWidth do
imgTable[i]={}
for j=1,imgHeight do
imgTable[i][j]={0,0,0,0}
end
end
end
--MISCELLANEOUS
function width()
return platform.window:width()
end
function height()
return platform.window:height()
end
function refresh()
platform.window:invalidate()
end
function copyTable(t)
local t2 = {}
for k,v in pairs(t) do
t2[k] = v
end
return t2
end
function samePixels(px1,px2)
if (px1[1]==px2[1] and px1[2]==px2[2] and px1[3]==px2[3] and px1[4]==px2[4]) or (px1[1]==0 and px2[1]==0) then
return 1
else
return nil
end
end
function fillPixel(x,y)
local previousPixel,xTest,yTest
previousPixel=copyTable(imgTable[x][y])
if not samePixels(previousPixel,{1,math.floor(color[1]*31/255),math.floor(color[2]*31/255),math.floor(color[3]*31/255)}) then
changedMark="*"
imgTable[x][y]={1,math.floor(color[1]*31/255),math.floor(color[2]*31/255),math.floor(color[3]*31/255)}
for i=1,4 do
xTest=math.floor(i/2)-1+x
yTest=(i==3 and 1 or 0)-(i==2 and 1 or 0)+y
if xTest>0 and xTest<imgWidth+1 and yTest>0 and yTest<imgHeight+1 then
if samePixels(previousPixel,imgTable[xTest][yTest]) then
fillPixel(xTest,yTest)
end
end
end
end
end
function setPixel(x,y)
if x>=1 and x<=imgWidth and y>=1 and y<=imgHeight then
imgTable[x][y]={1,math.floor(color[1]*31/255),math.floor(color[2]*31/255),math.floor(color[3]*31/255)}
end
end
function drawCircle(x1,y1,x2,y2)
local rayon=math.floor(math.sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1))+0.01)
local x,y,m
x=0
y=rayon
m=5-4*rayon
while x<=y do
setPixel(x+x1,y+y1)
setPixel(y+x1,x+y1)
setPixel(-x+x1,y+y1)
setPixel(-y+x1,x+y1)
setPixel(x+x1,-y+y1)
setPixel(y+x1,-x+y1)
setPixel(-x+x1,-y+y1)
setPixel(-y+x1,-x+y1)
if m>0 then
y=y-1
m=m-8*y
end
x=x+1
m=m+8*x+4
end
changedMark="*"
end
function round(nb)
if nb>math.floor(nb)+0.5 then
return math.floor(nb)+1
else
return math.floor(nb)
end
end
function drawLine(x1,y1,x2,y2)
local reversed=nil
if x1>x2 then
x1,x2=x2,x1
reversed=not reversed
end
if y1>y2 then
y1,y2=y2,y1
reversed=not reversed
end
local size=x2-x1>y2-y1 and x2-x1 or y2-y1
for i=0,size do
if reversed then
setPixel(x1+(x2-x1)-round((i/size)*(x2-x1)),y1+round((i/size)*(y2-y1)))
else
setPixel(x1+round((i/size)*(x2-x1)),y1+round((i/size)*(y2-y1)))
end
end
changedMark="*"
end
function drawRect(x1,y1,x2,y2)
if x1>x2 then
x1,x2=x2,x1
end
if y1>y2 then
y1,y2=y2,y1
end
for i=x1,x2 do
setPixel(i,y1)
setPixel(i,y2)
end
for i=y1,y2 do
setPixel(x1,i)
setPixel(x2,i)
end
changedMark="*"
end
function fillRect(x1,y1,x2,y2)
if x1>x2 then
x1,x2=x2,x1
end
if y1>y2 then
y1,y2=y2,y1
end
for i=x1,x2 do
for j=y1,y2 do
setPixel(i,j)
end
end
changedMark="*"
end
function fillCircle(x1,y1,x2,y2)
local rayon=math.floor(math.sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1))+0.5)
local startX,endX,startY,endY
startX=x1-rayon
endX=x1+rayon
startY=y1-rayon
endY=y1+rayon
for i=startX,endX do
for j=startY,endY do
if (x1-i)*(x1-i)+(y1-j)*(y1-j)-(rayon+1)/2<=rayon*rayon then
setPixel(i,j)
end
end
end
changedMark="*"
end
function loadHexColor()
local isHex,tmptable
isHex=1
tmptable={}
if string.len(rqstr)==6 then
for i=1,6,1 do
currentch=string.sub(rqstr,i,i)
tmptable[i]=tonumber(currentch,16)
if not tmptable[i] then
isHex=nil
end
end
else isHex=nil
end
if isHex then
color={tmptable[1]*16+tmptable[2],tmptable[3]*16+tmptable[4],tmptable[5]*16+tmptable[6]}
else
status="error"
errtype="Invalid hexadecimal"
end
end
function eraseImg()
if imgTable then
for i=1,imgWidth do
for j=1,imgHeight do
imgTable[i][j][1]=0
end
end
changedMark="*"
refresh()
end
end
function flipH()
if imgTable then
local newImg={}
for i=1,imgWidth do
newImg[i]={}
for j=1,imgHeight do
newImg[i][j]=copyTable(imgTable[imgWidth-i+1][j])
end
end
imgTable=newImg
changedMark="*"
refresh()
end
end
function flipV()
if imgTable then
local newImg={}
for i=1,imgWidth do
newImg[i]={}
for j=1,imgHeight do
newImg[i][j]=copyTable(imgTable[i][imgHeight-j+1])
end
end
imgTable=newImg
changedMark="*"
refresh()
end
end
function rotateImg(mode)
if imgTable then
xScroll,yScroll=0,0
xPos,yPos=1,1
local newImg={}
for i=1,imgHeight do
newImg[i]={}
for j=1,imgWidth do
if mode=="c" then
newImg[i][j]=copyTable(imgTable[j][imgHeight-i+1])
else
newImg[i][j]=copyTable(imgTable[imgWidth-j+1][i])
end
end
end
imgWidth,imgHeight=imgHeight,imgWidth
imgTable=newImg
changedMark="*"
refresh()
end
end
-
ChockostaPremium
Niveau 10: GR (Guide de Référence)- Posts: 213
- Joined: 24 Feb 2011, 00:00
- Gender:
- Calculator(s):→ MyCalcs profile
- Class: Math sup
38 posts
• Page 4 of 4 • 1, 2, 3, 4
Who is online
Users browsing this forum: ClaudeBot [spider] and 0 guests