The Program

Warning: I do not know how to program in postscript. So don't ask me any postscript programming questions. I found this program in a radio/electronics magazine in 1991 and have been tweaking it ever since

%!
/problistcreate {mark /counter 0 def probabilities {128 mul round cvi
{transforms counter get} repeat /counter counter 1 add def} forall
counttomark 128 sub neg dup 0 gt {[1 0 0 1 0 0] repeat} {pop} ifelse]
/problist exch def} bind def
%
/doit {problistcreate 1 1 20 {problist rand -24 bitshift get transform 2
copy moveto 0.001 10 rlineto} repeat newpath numdots {problist rand -24
bitshift get transform 2 copy moveto 0.001 0 rlineto stroke} repeat} bind def
%

6000 for numdots works okay for me. The bigger you make numdots, more dots are put down. It's that simple.

/numdots 6000 def

Here are where the transform matrices go. Put in as many matrices as you like. The ones here are for our old friend the Sierpinski triangle. The first four numbers are from the "distortion" matrix, the next two are the translation vector.

 
% /transforms[ 
[.5 0 0 .5 0 0] 
[.5 0 0 .5 4 0]
[.5 0 0 .5 2 4]
] def
%

This is the probability vector: there are as many numbers in this as there are vectors in transforms. They should be postive and add up to 1.

 
/probabilities [.33 .33 .34] def 
%
1 setlinecap 0 setlinewidth 200 300 translate 30 dup scale doit showpage
quit

And that's it. The whole shebang. If you figure stuff out, please mail me (campbelm@cims.nyu.edu). I _would_ like to know how to program a julia set or any general complex iterated function.