Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
6581 leency 1
--PICTURE: Pattern - Sierpinsky triangle v1.0
2
--by Richard Fhager
3
--http://hem.fyristorg.com/dawnbringer/
4
-- Email: dawnbringer@hem.utfors.se
5
-- MSN:   annassar@hotmail.com
6
--
7
-- Copyright 2010 Richard Fhager
8
--
9
-- This program is free software; you can redistribute it and/or
10
-- modify it under the terms of the GNU General Public License
11
-- as published by the Free Software Foundation; version 2
12
-- of the License. See 
13
 
14
-- This script was adopted from Evalion, a Javascript codecrafting/imageprocessing project
15
-- http://goto.glocalnet.net/richard_fhager/evalion/evalion.html
16
--
17
 
18
frac = {{1,1},{1,0}}
19
 
20
iter = 15
21
 
22
--
23
function pattern(x,y,p,n,i) -- Fractal Pattern V1.0 by Richard Fhager (mod allows for wrapping)
24
 py = #p
25
 px = #p[1]
26
 while ((p[1+math.abs(math.floor(y*py))%py][1+math.abs(math.floor(x*px))%px]) == 1 and n
27
  x=x*px-math.floor(x*px);
28
  y=y*py-math.floor(y*py);
29
  n = n+1
30
 end
31
 return 1 - n/i;
32
end
33
--
34
 
35
w, h = getpicturesize()
36
 
37
rp,gp,bp = getcolor(getforecolor())
38
 
39
for y = 0, h - 1, 1 do
40
  for x = 0, w - 1, 1 do
41
 
42
    ox = x / w;
43
    oy = y / h;
44
 
45
    f = pattern(ox,oy,frac,0,iter);
46
 
47
    c = matchcolor(rp*f,gp*f,bp*f)
48
 
49
    putpicturepixel(x, y, c);
50
 
51
  end
52
  updatescreen()
53
  if (waitbreak(0)==1) then
54
    return
55
  end
56
end
57