            Breaking Down Fractals With Postscript In this tutorial, we will use what we have learned in the previous tutorials to break down what is happening in a couple fractal files. A text editor will be used to write postscript (notepad is sufficient). GSview will also be used to view our files. What is a Fractal? We will use the following definition: Term coined by Benoit Mandelbrot in 1975, referring to objects built using recursion, where some aspect of the limiting object is infinite and another is finite, and where at any iteration, some piece of the object is a scaled down version of the previous iteration. Siepenski Triangle Lets start by viewing some code: %! % Sierpinski gasket % By John Fouhy. /maxdepth 10 def /length 500 def /xoff 60 def /yoff 300 def /root3 1.7320508 def % draw a (roughly) equilateral triangle /triangle { newpath x y moveto a 0 rlineto 120 rotate a 0 rlineto 240 rotate closepath stroke } def % usage: a x y depth rec % where a is the side length, (x,y) are the coords of the lower left corner, and depth is the recursion depth /rec { /depth exch def /y exch def /x exch def /a exch def triangle depth maxdepth lt { /newa a 2 div def /newdepth depth 1 add def newa x y newdepth newa x a 4 div add y root3 a mul 4 div add newdepth newa x newa add y newdepth rec rec rec } if } def 0 setlinewidth length xoff yoff 1 rec showpage The code is fairly straight-forward here. Fern This is a little more difficult to understand (Let me know what you figure out after you take linear algebra): %!PS-Adobe-1.0 %%Title:Random Fern %%Creator:Eric Wicklund % Last modified: MLO 02 Jan 1993 11:24:14 /m1 [ 0.00 0.00 0.00 0.16 0.00 0.00 ] def /m2 [ 0.85 -0.04 0.04 0.85 0.00 1.60 ] def /m3 [ 0.20 0.23 -0.26 0.22 0.00 1.60 ] def /m4 [ -0.15 0.26 0.28 0.24 0.00 0.44 ] def /point 72 def /length 0 def %%EndProlog %%Page: 1 1 /zzz save def % will draw inside a 8 inch square centered on 8.5 by 11 inch page 4.25 point mul 1.5 point mul translate 0.8 point mul dup scale % x coordinate ranges from -5 to 5 % y coordinate ranges from 0 to 10 1 setlinecap 0.005 setlinewidth % First point at origin 0 0 300000 { % Pick a transformation matrix probabilistically /r rand 100 mod def r 1 lt { /m m1 def } { r 86 lt { /m m2 def } { r 93 lt { /m m3 def } { /m m4 def } ifelse } ifelse } ifelse % Make a linear transformation, then % plot a point at current location m transform 2 copy moveto length length rlineto stroke } repeat showpage zzz restore %%Trailer That's all folks!            The PostScript Tutorial Concieved and Created by Dann Ormond & Will Munn. Inspired by Mike Grady PhD. Website Design by NiftySites.com.