32 lines
655 B
Lua
32 lines
655 B
Lua
--BRUSH Scene: Sphere of pencolor v1.0
|
|
--by Richard Fhager
|
|
--http://hem.fyristorg.com/dawnbringer/
|
|
|
|
-- 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
|