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:
Yves Rizoud
2011-04-03 16:45:10 +00:00
parent 0129bb3590
commit 27e8d15971
38 changed files with 28 additions and 24 deletions

View File

@@ -0,0 +1,57 @@
--BRUSH Scene: Amigaball 1.0
--
--Draws the famous 'Amiga ball' in the brush.
--
--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/>
-- This script was adopted from Evalion, a Javascript codecrafting/imageprocessing project
--http://goto.glocalnet.net/richard_fhager/evalion/evalion.html
w, h = getbrushsize()
if (w<64 or h<64) then
setbrushsize(64,64)
w=64
h=64
end
for y = 0, h - 1, 1 do
for x = 0, w - 1, 1 do
-- Fractionalize image dimensions
ox = x / w;
oy = y / h;
-- Ball
Xr = ox-0.5; Yr = oy-0.5;
W = (1 - 2*math.sqrt(Xr*Xr + Yr*Yr));
-- 'FishEye' distortion / Fake 3D
F = (math.cos((ox-0.5)*math.pi)*math.cos((oy-0.5)*math.pi))*0.65;
ox = ox - (ox-0.5)*F;
oy = oy - (oy-0.5)*F;
-- Checkers
V = ((math.floor(0.25+ox*10)+math.floor(1+oy*10)) % 2) * 255 * W;
-- Specularities
SPEC1 = math.max(0,(1-5*math.sqrt((ox-0.45)*(ox-0.45)+(oy-0.45)*(oy-0.45)))*112);
SPEC2 = math.max(0,(1-15*math.sqrt((ox-0.49)*(ox-0.49)+(oy-0.48)*(oy-0.48)))*255);
r = W * 255 + SPEC1 + SPEC2
g = V + SPEC1 + SPEC2
b = V + SPEC1 + SPEC2
putbrushpixel(x, y, matchcolor(r,g,b));
end
end

View File

@@ -0,0 +1,38 @@
--BRUSH Scene: Sphere of pencolor v1.0
--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/>
-- This script was adopted from Evalion, a Javascript codecrafting/imageprocessing project
--http://goto.glocalnet.net/richard_fhager/evalion/evalion.html
w, h = getbrushsize()
rp,gp,bp = getcolor(getforecolor())
for y = 0, h - 1, 1 do
for x = 0, w - 1, 1 do
-- Fractionalize image dimensions
ox = x / w;
oy = y / h;
-- Sphere
X = 0.5; Y = 0.5; Rd = 0.5
a = math.sqrt(math.max(0,Rd*Rd - ((X-ox)*(X-ox)+(Y-oy)*(Y-oy)))) * 1/Rd
r = rp * a
g = gp * a
b = bp * a
putbrushpixel(x, y, matchcolor(r,g,b));
end
end

View File

@@ -0,0 +1,100 @@
--BRUSH: Find AA-colors from pencolors
--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/>
cellw = 8
cellh = 4
colors = 256
setbrushsize(cellw * 3, cellh * 3)
--
function makePalList(cols)
pal = {}
for n = 0, cols-1, 1 do
r,g,b = getcolor(n)
pal[n+1] = {r,g,b}
end
return pal
end
--
--
function getBestPalMatchHYBRID(rgb,pal,briweight)
local diff,diffC,diffB,best,bestcol,cols,n,c,r,g,b,p,obri,pbri
cols = #pal
bestcol = 0
best = 9e99
r = rgb[1]
g = rgb[2]
b = rgb[3]
obri = math.pow(r*9,2)+math.pow(g*16,2)+math.pow(b*8,2)
for n=0, cols-1, 1 do
p = pal[n+1]
pbri = math.pow(p[1]*9,2)+math.pow(p[2]*16,2)+math.pow(p[3]*8,2)
diffB = math.abs(obri - pbri)
diffC = (math.pow(r-p[1],2)+math.pow(g-p[2],2)+math.pow(b-p[3],2)) * 400
--diff = diffB + diffC
diff = briweight * (diffB - diffC) + diffC
if diff <= best then bestcol = n; best = diff; end
end
return bestcol
end
--
--
function drawRectangle(x1,y1,w,h,c)
for y = y1, y1+h, 1 do
for x = x1, x1+w, 1 do
putbrushpixel(x,y,c);
end
end
end
--
palList = makePalList(colors)
cf = getforecolor()
cb = getbackcolor()
rf,gf,bf = getcolor(cf)
rb,gb,bb = getcolor(cb)
ra = (rf + rb) / 2
ga = (gf + gb) / 2
ba = (bf + bb) / 2
rgb1 = {ra,ga,ba}
c1 = getBestPalMatchHYBRID(rgb1,palList,0.0)
c2 = getBestPalMatchHYBRID(rgb1,palList,0.75)
c3 = getBestPalMatchHYBRID(rgb1,palList,0.99)
q = {{cf,c1,cb},
{cf,c2,cb},
{cf,c3,cb}}
for y = 0, #q-1, 1 do
for x = 0, #q[1]-1, 1 do
drawRectangle(x*cellw,y*cellh,cellw,cellh,q[y+1][x+1])
end
end

View File

@@ -0,0 +1,64 @@
--BRUSH Scene: Mandelbrot fractal v0.5
--
--Draws a Mandelbrot fractal in the current brush.
--
--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/>
-- This script was adopted from Evalion, a Javascript codecrafting/imageprocessing project
--http://goto.glocalnet.net/richard_fhager/evalion/evalion.html
colors = 64
x0 = -1.7
x1 = 0.7
ym = 0
iter = 64
ok, x0, x1, ym, iter = inputbox("Fractal data",
"X0", x0, -2, 2,4,
"X1", x1, -2, 2,4,
"midY", ym, -2, 2,4,
"Iter", iter, 1, 2048,0
);
-- -0.831116819,-0.831116815,0.2292112435,192
function mandel(x,y,l,r,o,i) -- pos. as fraction of 1, left coord, right coord, y coord, iterations
local w,s,a,p,q,n,v,w
s=math.abs(r-l);
a = l + s*x;
p = a;
b = o - s*(y-0.5);
q = b;
n = 1;
v = 0;
w = 0;
while (v+w<4 and n<i) do n=n+1; v=p*p; w=q*q; q=2*p*q+b; p=v-w+a; end;
return n
end
w, h = getbrushsize()
for x = 0, w - 1, 1 do
for y = 0, h - 1, 1 do
q = mandel(x/w,y/h,x0,x1,ym,iter) % colors;
putbrushpixel(x, y, q);
end
end