diff --git a/share/grafx2/scripts/pic_ni_GlassGridFilter.lua b/share/grafx2/scripts/pic_ni_GlassGridFilter.lua index 0dbdca3b..3aa7e22e 100644 --- a/share/grafx2/scripts/pic_ni_GlassGridFilter.lua +++ b/share/grafx2/scripts/pic_ni_GlassGridFilter.lua @@ -1,19 +1,12 @@ --- Glass grid filter - --- Copyright 2010 Paulo Silva --- --- This program is free software; you can redistribute it and/or --- modify it under the terms of the GNU General Public License --- as published by the Free Software Foundation; version 2 --- of the License. See - +-- Glass grid filter - Copyright 2010 Paulo Silva +-- This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. See w,h=getpicturesize(); -for y1=0,h-1,8 do - for x1=0,w-1,8 do - for y2=0,3,1 do - for x2=0,7,1 do - c1=getpicturepixel(x1+x2,y1+y2) - c2=getpicturepixel(x1+7-x2,y1+7-y2) - putpicturepixel(x1+x2,y1+y2,c2) - putpicturepixel(x1+7-x2,y1+7-y2,c1) - end;end;end;end +ok,xsiz,ysiz=inputbox("message","xsize",8,0,64,5,"ysize",8,0,64,6); +if ok==true then + for y1=0,h-1,xsiz do + for x1=0,w-1,ysiz do + for y2=0,(ysiz/2)-1,1 do + for x2=0,xsiz-1,1 do + c1=getpicturepixel(x1+x2,y1+y2);c2=getpicturepixel(x1+(xsiz-1)-x2,y1+(ysiz-1)-y2) + putpicturepixel(x1+x2,y1+y2,c2);putpicturepixel(x1+(xsiz-1)-x2,y1+(ysiz-1)-y2,c1) + end;end;end;end;end diff --git a/share/grafx2/scripts/pic_ni_cellcolourreducer.lua b/share/grafx2/scripts/pic_ni_cellcolourreducer.lua new file mode 100644 index 00000000..3f97a8c0 --- /dev/null +++ b/share/grafx2/scripts/pic_ni_cellcolourreducer.lua @@ -0,0 +1,37 @@ +-- cell colour reducer - jan'11, from Paulo Silva, with help from people from GrafX2 google group (DawnBringer, Adrien Destugues (PulkoMandy), and Yves Rizoud) +-- This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. See +w,h=getpicturesize() +ok,xcell,ycell=inputbox("Modify cell pixel size","xcell",8,1,16,4,"ycell",8,1,16,4); +if ok==true then + function grayscaleindexed(c) + r,g,b=getcolor(c);return math.floor((b*11+r*30+g*59)/100);end + celcnt={};for n=0,255,1 do celcnt[n+1]=0;end -- Arraycounter must have initial value + for y1=0,h-1,ycell do + for x1=0,w-1,xcell do + for i=0,255,1 do + celcnt[i+1]=0;end + for y2=0,ycell-1,1 do + for x2=0,xcell-1,1 do + x=x1+x2;y=y1+y2;u=getpicturepixel(x,y) + celcnt[u+1]=celcnt[u+1]+(1000*xcell*ycell)+math.random(0,950);end;end + ikattr=0;paattr=0;ikcnt=0;pacnt=0 + for i=0,255,1 do + if ikcntgrayscaleindexed(paattr) then tmpr=ikattr;ikattr=paattr;paattr=tmpr;end + wmid=math.floor((grayscaleindexed(paattr)+grayscaleindexed(ikattr))/2) + for y2=0,ycell-1,1 do + for x2=0,xcell-1,1 do + x=x1+x2;y=y1+y2;u=getpicturepixel(x,y) + if u==ikattr then + idou=ikattr + elseif u==paattr then + idou=paattr + else + idou=ikattr + if grayscaleindexed(u)>wmid then idou=paattr;end + end + putpicturepixel(x,y,idou) + end;end;end;end;end diff --git a/share/grafx2/scripts/pic_ni_drawgridisometric.lua b/share/grafx2/scripts/pic_ni_drawgridisometric.lua new file mode 100644 index 00000000..1dd304db --- /dev/null +++ b/share/grafx2/scripts/pic_ni_drawgridisometric.lua @@ -0,0 +1,13 @@ +-- Draw isometric grid - Copyright 2010 Paulo Silva +-- This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. See +w,h=getpicturesize(); +ok,gsiz,ik=inputbox("draw isometric grid","size",16,0,128,5,"colour",1,0,255,6); +if ok==true then + for y=0,h-1,gsiz do + for x=0,w-1,1 do + putpicturepixel(x,y+(x/2)%gsiz,ik); + end;end + for y=0,h-1,gsiz do + for x=0,w-1,1 do + putpicturepixel(x+((gsiz/2)-1),y+(gsiz-1)-((x/2)%gsiz),ik); + end;end;end diff --git a/share/grafx2/scripts/pic_ni_drawgridorthogonal_indexedcolour.lua b/share/grafx2/scripts/pic_ni_drawgridorthogonal_indexedcolour.lua new file mode 100644 index 00000000..7f4aafcd --- /dev/null +++ b/share/grafx2/scripts/pic_ni_drawgridorthogonal_indexedcolour.lua @@ -0,0 +1,11 @@ +-- draw grid - indexed colour - Copyright 2010 Paulo Silva +-- This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. See +w,h=getpicturesize(); +ok,xsiz,ysiz,c=inputbox("draw grid - indexed colour)","x size",8,1,64,5,"y size",8,1,64,6,"colour id",0,0,255,6); +if ok==true then + for y=0,h-1,1 do + for x=0,w-1,xsiz do + putpicturepixel(x,y,c);end;end + for y=0,h-1,ysiz do + for x=0,w-1,1 do + putpicturepixel(x,y,c);end;end;end diff --git a/share/grafx2/scripts/pic_ni_drawgridorthogonal_rgbmatchcolor.lua b/share/grafx2/scripts/pic_ni_drawgridorthogonal_rgbmatchcolor.lua new file mode 100644 index 00000000..729243fc --- /dev/null +++ b/share/grafx2/scripts/pic_ni_drawgridorthogonal_rgbmatchcolor.lua @@ -0,0 +1,14 @@ +-- draw grid - rgb (matchcolor) - Copyright 2010 Paulo Silva +-- This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. See +w,h=getpicturesize() +ok,xsiz,ysiz,r,g,b=inputbox("draw grid - rgb (matchcolor)","x size",8,1,64,5,"y size",8,1,64,6,"r",128,0,255,6,"g",128,0,255,6,"b",128,0,255,6); +if ok==true then + c=matchcolor(r,g,b) + for y=0,h-1,1 do + for x=0,w-1,xsiz do + putpicturepixel(x,y,c); + end;end + for y=0,h-1,ysiz do + for x=0,w-1,1 do + putpicturepixel(x,y,c); + end;end;end diff --git a/share/grafx2/scripts/pic_ni_flippicture.lua b/share/grafx2/scripts/pic_ni_flippicture.lua new file mode 100644 index 00000000..3c1a4d62 --- /dev/null +++ b/share/grafx2/scripts/pic_ni_flippicture.lua @@ -0,0 +1,17 @@ +-- flip picture - Copyright 2010 Paulo Silva +-- This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. See +w,h=getpicturesize(); +ok,flipx,flipy=inputbox("flip picture","flip x",1,0,1,-1,"flip y",0,0,1,-1); +if ok==true then + if flipx==1 then + for y=0,h-1,1 do + for x=0,w/2,1 do + c1=getpicturepixel(x,y);c2=getpicturepixel(w-x-1,y) + putpicturepixel(x,y,c2);putpicturepixel(w-x-1,y,c1) + end;end + else + for y=0,h/2,1 do + for x=0,w-1,1 do + c1=getpicturepixel(x,y);c2=getpicturepixel(x,h-y-1) + putpicturepixel(x,y,c2);putpicturepixel(x,h-y-1,c1) + end;end;end;end diff --git a/share/grafx2/scripts/pic_ni_palettetopicture.lua b/share/grafx2/scripts/pic_ni_palettetopicture.lua new file mode 100644 index 00000000..a645fd34 --- /dev/null +++ b/share/grafx2/scripts/pic_ni_palettetopicture.lua @@ -0,0 +1,11 @@ +-- palette to picture - Copyright 2010 Paulo Silva +-- This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. See +w,h=getpicturesize(); +ok,xsiz,ysiz=inputbox("palette to picture","x size",8,1,16,5,"y size",8,1,16,6); +if ok==true then + for y1=0,7,1 do + for x1=0,31,1 do + for y2=0,ysiz-1,1 do + for x2=0,xsiz-1,1 do + putpicturepixel(x1*xsiz+x2,y1*ysiz+y2,y1+x1*8) + end;end;end;end;end diff --git a/share/grafx2/scripts/pic_ni_xbitcolourspacefrompalette.lua b/share/grafx2/scripts/pic_ni_xbitcolourspacefrompalette.lua new file mode 100644 index 00000000..444e62fa --- /dev/null +++ b/share/grafx2/scripts/pic_ni_xbitcolourspacefrompalette.lua @@ -0,0 +1,12 @@ +-- Copyright 2010 Paulo Silva +-- This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. See +w,h=getpicturesize(); +ok,bitd=inputbox("colourspace from palette","bitdepth:",4,1,8,5); +if ok==true then + bitd3=(2^bitd);bitd8=(2^(math.floor(bitd/2)));bitd9=(2^((math.floor((bitd-1)/2))+1)) + for y1=0,(bitd8-1),1 do + for x1=0,(bitd9-1),1 do + for y2=0,(bitd3-1),1 do + for x2=0,(bitd3-1),1 do + putpicturepixel(x1*bitd3+x2,y1*bitd3+y2,matchcolor((y2*255)/(bitd3-1),((y1*8+x1)*255)/(bitd3-1),(x2*255)/(bitd3-1))) + end;end;end;end;end