Reorganized scripts, fixed 'memory' not working with subdirectories
git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1765 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
12
share/grafx2/scripts/samples_2.3/picture/GlassGridFilter.lua
Normal file
12
share/grafx2/scripts/samples_2.3/picture/GlassGridFilter.lua
Normal file
@@ -0,0 +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/>
|
||||
w,h=getpicturesize();
|
||||
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
|
||||
@@ -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
|
||||
87
share/grafx2/scripts/samples_2.3/picture/Pic2isometric.lua
Normal file
87
share/grafx2/scripts/samples_2.3/picture/Pic2isometric.lua
Normal file
@@ -0,0 +1,87 @@
|
||||
--PICTURE (part of): 2 Isometric v0.1b
|
||||
--by Richard Fhager
|
||||
--http://hem.fyristorg.com/dawnbringer/
|
||||
-- Email: dawnbringer@hem.utfors.se
|
||||
-- MSN: annassar@hotmail.com
|
||||
--
|
||||
-- Copyright 2010 Richard Fhager
|
||||
--
|
||||
-- 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/>
|
||||
|
||||
|
||||
-- Color 0 is assumed to be the background
|
||||
--
|
||||
|
||||
iso = {{0, 0, 1, 1, 1, 1, 0, 0},
|
||||
{1, 1, 1, 1, 1, 1, 1, 1},
|
||||
{2, 2, 1, 1, 1, 1, 3, 3},
|
||||
{2, 2, 2, 2, 3, 3, 3, 3},
|
||||
{2, 2, 2, 2, 3, 3, 3, 3},
|
||||
{2, 2, 2, 2, 3, 3, 3, 3},
|
||||
{0, 0, 2, 2, 3, 3, 0, 0}}
|
||||
|
||||
isowidth = 8
|
||||
isoheight = 7
|
||||
|
||||
xoff = 0.5
|
||||
yoff = 0
|
||||
|
||||
xstep = 4
|
||||
ystep = 2
|
||||
zstep = 4
|
||||
|
||||
-- Part of screen from top-left (4 = 1/4)
|
||||
xsize = 5
|
||||
ysize = 4
|
||||
|
||||
|
||||
w, h = getpicturesize()
|
||||
|
||||
xo = math.floor(w * xoff)
|
||||
|
||||
-- just don't render more than can be fittted right now
|
||||
w = math.floor(w / xsize)
|
||||
h = math.floor(h / ysize)
|
||||
|
||||
|
||||
|
||||
for y = 0, h - 1, 1 do
|
||||
for x = 0, w - 1, 1 do
|
||||
|
||||
isox = x * xstep - y * xstep
|
||||
isoy = y * ystep + x * ystep
|
||||
|
||||
cb = getbackuppixel(x,y)
|
||||
|
||||
--
|
||||
if cb ~= 0 then
|
||||
|
||||
r,g,b = getbackupcolor(cb);
|
||||
c1 = matchcolor(r,g,b);
|
||||
c2 = matchcolor(r+64, g+64, b+64);
|
||||
c3 = matchcolor(r-64, g-64, b-64);
|
||||
|
||||
cols = {0,c1,c2,c3}
|
||||
|
||||
for iy = 1, isoheight, 1 do
|
||||
for ix = 1, isowidth, 1 do
|
||||
|
||||
i = iso[iy][ix]
|
||||
c = cols[i+1]
|
||||
if i ~= 0 then putpicturepixel(xo + isox+ix-1, isoy+iy-1, c); end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
--
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
--PICTURE: Rainbow - Dark to Bright
|
||||
--by Richard Fhager
|
||||
--http://hem.fyristorg.com/dawnbringer/
|
||||
-- Email: dawnbringer@hem.utfors.se
|
||||
-- MSN: annassar@hotmail.com
|
||||
--
|
||||
-- Copyright 2010 Richard Fhager
|
||||
--
|
||||
-- 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/>
|
||||
|
||||
-- This script was adopted from Evalion, a Javascript codecrafting/imageprocessing project
|
||||
-- http://goto.glocalnet.net/richard_fhager/evalion/evalion.html
|
||||
--
|
||||
|
||||
--
|
||||
function shiftHUE(r,g,b,deg) -- V1.3 R.Fhager 2007, adopted from Evalion
|
||||
local c,h,mi,mx,d,s,p,i,f,q,t
|
||||
c = {g,b,r}
|
||||
mi = math.min(r,g,b)
|
||||
mx = math.max(r,g,b); v = mx;
|
||||
d = mx - mi;
|
||||
s = 0; if mx ~= 0 then s = d/mx; end
|
||||
p = 1; if g ~= mx then p = 2; if b ~= mx then p = 0; end; end
|
||||
|
||||
if s~=0 then
|
||||
h=(deg/60+(6+p*2+(c[1+p]-c[1+(p+1)%3])/d))%6;
|
||||
i=math.floor(h);
|
||||
f=h-i;
|
||||
p=v*(1-s);
|
||||
q=v*(1-s*f);
|
||||
t=v*(1-s*(1-f));
|
||||
c={v,q,p,p,t,v}
|
||||
r = c[1+i]
|
||||
g = c[1+(i+4)%6]
|
||||
b = c[1+(i+2)%6]
|
||||
end
|
||||
|
||||
return r,g,b
|
||||
end
|
||||
--
|
||||
|
||||
|
||||
w, h = getpicturesize()
|
||||
|
||||
for y = 0, h - 1, 1 do
|
||||
for x = 0, w - 1, 1 do
|
||||
|
||||
-- Fractionalize image dimensions
|
||||
ox = x / w;
|
||||
oy = y / h;
|
||||
|
||||
r = 255 * math.sin(oy * 2)
|
||||
g = (oy-0.5)*512 * oy
|
||||
b = (oy-0.5)*512 * oy
|
||||
|
||||
r, g, b = shiftHUE(r,g,b,ox * 360);
|
||||
|
||||
c = matchcolor(math.max(0,math.min(255,r)),math.max(0,math.min(255,g)),math.max(0,math.min(255,b)))
|
||||
|
||||
putpicturepixel(x, y, c);
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
50
share/grafx2/scripts/samples_2.3/picture/RemapImage2RGB.lua
Normal file
50
share/grafx2/scripts/samples_2.3/picture/RemapImage2RGB.lua
Normal file
@@ -0,0 +1,50 @@
|
||||
--SCENE: Remap pic to RGB, diag.dith
|
||||
--by Richard Fhager
|
||||
--http://hem.fyristorg.com/dawnbringer/
|
||||
|
||||
-- Copyright 2010 Richard Fhager
|
||||
--
|
||||
-- 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/>
|
||||
|
||||
-- Set Palette (to a predefined one)
|
||||
|
||||
colors = {{ 0, 0, 0},
|
||||
{255, 0, 0},
|
||||
{ 0,255, 0},
|
||||
{ 0, 0,255}
|
||||
}
|
||||
|
||||
|
||||
chm = {1,0,0}
|
||||
|
||||
for c = 1, #colors, 1 do
|
||||
setcolor(c-1,colors[c][1],colors[c][2],colors[c][3])
|
||||
end
|
||||
|
||||
for c = #colors, 255, 1 do
|
||||
setcolor(c,0,0,0)
|
||||
end
|
||||
|
||||
|
||||
|
||||
w, h = getpicturesize()
|
||||
|
||||
for y = 0, h - 1, 1 do
|
||||
|
||||
for x = 0, w - 1, 1 do
|
||||
|
||||
r,g,b = getbackupcolor(getbackuppixel(x,y));
|
||||
|
||||
rn = r * chm[1+(y+0+x)%3]
|
||||
gn = g * chm[1+(y+1+x)%3]
|
||||
bn = b * chm[1+(y+2+x)%3]
|
||||
|
||||
n = matchcolor(rn,gn,bn);
|
||||
|
||||
putpicturepixel(x, y, n);
|
||||
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,69 @@
|
||||
--SCENE: Remap pic 2 RGB, 1lineED-dith. (Same line simple error-diffusion dither)
|
||||
--by Richard Fhager
|
||||
--http://hem.fyristorg.com/dawnbringer/
|
||||
|
||||
-- Copyright 2010 Richard Fhager
|
||||
--
|
||||
-- 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/>
|
||||
|
||||
|
||||
power = 0.615
|
||||
|
||||
c1 = 0.8 -- Error weight (white is green)
|
||||
c2 = 0.2 -- RGB weight (white is r+g+b)
|
||||
|
||||
-- Set Palette (to a predefined one)
|
||||
|
||||
colors = {{ 0, 0, 0},
|
||||
{255, 0, 0},
|
||||
{ 0,255, 0},
|
||||
{ 0, 0,255}
|
||||
}
|
||||
|
||||
|
||||
chm = {1,0,0}
|
||||
|
||||
for c = 1, #colors, 1 do
|
||||
setcolor(c-1,colors[c][1],colors[c][2],colors[c][3])
|
||||
end
|
||||
|
||||
for c = #colors, 255, 1 do
|
||||
setcolor(c,0,0,0)
|
||||
end
|
||||
|
||||
|
||||
|
||||
w, h = getpicturesize()
|
||||
|
||||
for y = 0, h - 1, 1 do
|
||||
|
||||
re = 0
|
||||
ge = 0
|
||||
be = 0
|
||||
|
||||
for x = (y%2), w - 1, 1 do
|
||||
|
||||
r,g,b = getbackupcolor(getbackuppixel(x,y));
|
||||
|
||||
rn = re * c1 + r * chm[1+(y+0+x)%3] * c2
|
||||
gn = ge * c1 + g * chm[1+(y+1+x)%3] * c2
|
||||
bn = be * c1 + b * chm[1+(y+2+x)%3] * c2
|
||||
|
||||
n = matchcolor(rn,gn,bn);
|
||||
|
||||
putpicturepixel(x, y, n);
|
||||
|
||||
|
||||
rn,gn,bn = getcolor(getpicturepixel(x,y));
|
||||
|
||||
re = (re + (r - rn)) * power
|
||||
ge = (ge + (g - gn)) * power
|
||||
be = (be + (b - bn)) * power
|
||||
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,80 @@
|
||||
--SCENE: Remap pic to 3bit, LineEDdith. (Same line simple error-diffusion dither)
|
||||
--by Richard Fhager
|
||||
--http://hem.fyristorg.com/dawnbringer/
|
||||
|
||||
-- Copyright 2010 Richard Fhager
|
||||
--
|
||||
-- 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/>
|
||||
|
||||
--
|
||||
-- Just a demonstration.
|
||||
--
|
||||
|
||||
|
||||
|
||||
power = 0.6
|
||||
|
||||
-- Channel shades (shades = 2 ^ bit-depth)
|
||||
shades = 2
|
||||
|
||||
mult = 255 / (shades-1)
|
||||
|
||||
|
||||
colors = {}
|
||||
col = 0
|
||||
for r = 0, shades-1, 1 do
|
||||
for g = 0, shades-1, 1 do
|
||||
for b = 0, shades-1, 1 do
|
||||
col = col + 1
|
||||
colors[col] = { r*mult, g*mult, b*mult }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
for c = 1, #colors, 1 do
|
||||
|
||||
setcolor(c-1,colors[c][1],colors[c][2],colors[c][3])
|
||||
|
||||
end
|
||||
|
||||
|
||||
for c = #colors, 255, 1 do
|
||||
setcolor(c,0,0,0)
|
||||
end
|
||||
|
||||
|
||||
|
||||
w, h = getpicturesize()
|
||||
|
||||
for y = 0, h - 1, 1 do
|
||||
|
||||
re = 0
|
||||
ge = 0
|
||||
be = 0
|
||||
|
||||
for x = (y%2), w - 1, 1 do
|
||||
|
||||
r,g,b = getbackupcolor(getbackuppixel(x,y));
|
||||
|
||||
rn = re + r
|
||||
gn = ge + g
|
||||
bn = be + b
|
||||
|
||||
n = matchcolor(rn,gn,bn);
|
||||
|
||||
putpicturepixel(x, y, n);
|
||||
|
||||
|
||||
rn,gn,bn = getcolor(getpicturepixel(x,y));
|
||||
|
||||
re = (re + (r - rn)) * power
|
||||
ge = (ge + (g - gn)) * power
|
||||
be = (be + (b - bn)) * power
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user