%!PS % Joseph O'Rourke % Random bow ties % Uses random numbers a bit... 2 setlinewidth % NB: I convert-to-integer with cvi because later I want to use mod /w 8.5 72 mul cvi def /h 11 72 mul cvi def % This procedure draws a horizontal bowtie about (x,y). % How to call: r g b x y length (x,y are center coordinates, length is end-to-end longer dimension in pts) /bowtie { 5 dict begin % 5 local vars /length exch def % Now x and y are on top of the stack gsave translate % origin now changed, x,y gone from stack /b exch def /g exch def /r exch def /x length 2 div def r g b x triangle % Now draw reflected triangle gsave -1 1 scale r g b x triangle grestore newpath x 3 div 0 moveto 0 0 x 3 div 0 360 arc gsave % Fill with complementary color 1 r sub 1 g sub 1 b sub setrgbcolor fill grestore 0 setgray stroke grestore end % dict } def % Draw one triangle % How to call: r g b xlength /triangle { 1 dict begin /x exch def newpath x x 2 div moveto 0 0 lineto x x 2 div neg lineto closepath gsave % note: r g b on top of stack setrgbcolor fill grestore 0 setgray stroke end % dict } def % Draw randomly placed bowties /n 100 def % start incr stop 1 1 n { /x rand w mod def /y rand h mod def 1 0 0 x y 100 bowtie } for showpage