%!PS-Adobe-2.0 %%BoundingBox: 0 0 612 792 %%Pages: 1 %%EndComments %%Page: 1 1 % leaf.ps - Don Yang (uguu.org) % % 07/16/01 % Constants /MINX 72 def /MAXX 540 def /MINY 72 def /MAXY 720 def /POINT_SIZE 1 def /DOT_COUNT 256 def /INIT_ITER_COUNT 20 def /ITERATION_COUNT 256 def % Fractal coefficients /Rules % b e a f c d [ [-0.0273 +0.4779 +0.0177 -0.1471 +0.6644 +0.0004] [+0.0648 +0.0420 +0.9054 +0.1623 +0.0735 +0.8363] [-0.4133 +0.3625 +0.2049 -0.0291 +0.2580 +0.2732] [+0.4081 +0.5902 -0.2312 +0.0291 +0.2372 +0.2372] ] def /RuleCount Rules length def % Draw point % IN: x y % OUT: x y /DrawPoint { 2 copy MAXY MINY sub mul MINY add exch % Translate Y MAXX MINX sub mul MINX add exch % Translate X newpath POINT_SIZE add moveto % (x, y+size) POINT_SIZE POINT_SIZE neg rlineto % (x+size, y) POINT_SIZE neg POINT_SIZE neg rlineto % (x, y-size) POINT_SIZE neg POINT_SIZE rlineto % (x-size, y) closepath fill } def % Move point % IN: x y % OUT: x y /Iterate { Rules rand RuleCount mod get aload pop % x y b e a f c d 6 index mul exch 7 index mul add add % x y b e a (c*x + d*y + f) 6 1 roll 5 4 roll % (c*x + d*y + f) y b e a x mul 4 2 roll mul add add % (c*x + d*y + f) (a*x + b*y + e) exch } def % Draw image % IN: - % OUT: - /Render { erasepage DOT_COUNT { rand 4095 and 4095 div % Initial x rand 4095 and 4095 div % Initial y INIT_ITER_COUNT { Iterate } repeat ITERATION_COUNT { Iterate DrawPoint } repeat pop pop } repeat } def realtime srand % btw: realtime is language level 2 Render showpage