Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
6581 leency 1
--BRUSH Scene: Sphere of pencolor v1.0
2
--by Richard Fhager
3
--http://hem.fyristorg.com/dawnbringer/
4
 
5
-- Copyright 2010 Richard Fhager
6
--
7
-- This program is free software; you can redistribute it and/or
8
-- modify it under the terms of the GNU General Public License
9
-- as published by the Free Software Foundation; version 2
10
-- of the License. See 
11
 
12
-- This script was adopted from Evalion, a Javascript codecrafting/imageprocessing project
13
--http://goto.glocalnet.net/richard_fhager/evalion/evalion.html
14
 
15
 
16
w, h = getbrushsize()
17
 
18
rp,gp,bp = getcolor(getforecolor())
19
 
20
for y = 0, h - 1, 1 do
21
  for x = 0, w - 1, 1 do
22
 
23
   -- Fractionalize image dimensions
24
   ox = x / w;
25
   oy = y / h;
26
 
27
   -- Sphere
28
   X = 0.5; Y = 0.5; Rd = 0.5
29
   a = math.sqrt(math.max(0,Rd*Rd - ((X-ox)*(X-ox)+(Y-oy)*(Y-oy)))) * 1/Rd
30
 
31
   r = rp * a
32
   g = gp * a
33
   b = bp * a
34
 
35
   putbrushpixel(x, y, matchcolor(r,g,b));
36
 
37
  end
38
end