More scripts from nitrofurano. Some of the previous ones may be replaced, but I'm going to write a page with info on all scripts and sort it all out from there.

git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1676 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
Adrien Destugues 2011-01-15 15:11:47 +00:00
parent 2801345545
commit c802a9acfd
8 changed files with 126 additions and 18 deletions

View File

@ -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 <http://www.gnu.org/licenses/>
-- 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 <http://www.gnu.org/licenses/>
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

View File

@ -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 <http://www.gnu.org/licenses/>
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 ikcnt<celcnt[i+1] then ikcnt=celcnt[i+1];ikattr=i;end;end
celcnt[ikattr+1]=0
for i=0,255,1 do
if pacnt<celcnt[i+1] then pacnt=celcnt[i+1];paattr=i;end;end
if grayscaleindexed(ikattr)>grayscaleindexed(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

View File

@ -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 <http://www.gnu.org/licenses/>
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

View File

@ -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 <http://www.gnu.org/licenses/>
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

View File

@ -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 <http://www.gnu.org/licenses/>
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

View File

@ -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 <http://www.gnu.org/licenses/>
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

View File

@ -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 <http://www.gnu.org/licenses/>
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

View File

@ -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 <http://www.gnu.org/licenses/>
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