Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. --PICTURE: Pattern - Sierpinsky carpet 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 <http://www.gnu.org/licenses/>
  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},{1,0,1},{1,1,1}}
  19.  
  20. iter = 6
  21.  
  22.  
  23. --
  24. function pattern(x,y,p,n,i) -- Fractal Pattern V1.0 by Richard Fhager (mod allows for wrapping)
  25.  py = #p
  26.  px = #p[1]
  27.  while ((p[1+math.abs(math.floor(y*py))%py][1+math.abs(math.floor(x*px))%px]) == 1 and n<i) do
  28.   x=x*px-math.floor(x*px);
  29.   y=y*py-math.floor(y*py);
  30.   n = n+1
  31.  end
  32.  return 1 - n/i;
  33. end
  34. --
  35.  
  36. w, h = getpicturesize()
  37.  
  38. rp,gp,bp = getcolor(getforecolor())
  39.  
  40.  
  41. for y = 0, h - 1, 1 do
  42.   for x = 0, w - 1, 1 do
  43.  
  44.     ox = x / w;
  45.     oy = y / h;
  46.  
  47.     f = pattern(ox,oy,frac,0,iter);
  48.  
  49.     c = matchcolor(rp*f,gp*f,bp*f)
  50.  
  51.     putpicturepixel(x, y, c);
  52.   end
  53.   updatescreen()
  54.   if (waitbreak(0)==1) then
  55.     return
  56.   end
  57.  
  58. end
  59.  
  60.