1 %!PS-Adobe-3.0 EPSF-3.0
2 %%BoundingBox: -40 -40 140 120
3 % Generates a koch snowflake, or crashes your pdf viewer, whichever you prefer.
7 % x1 y1 x2 y2 iterations koch x1 y1 ... x2 y2
17 /dist dx dx mul dy dy mul add sqrt def
18 /nx 0 dy sub dist div def
21 /xA dx 3 div x1 add def
22 /yA dy 3 div y1 add def
23 /xB dist 3 div nx mul dx 2 div add x1 add def
24 /yB dist 3 div ny mul dy 2 div add y1 add def
25 /xC dx 3 div 2 mul x1 add def
26 /yC dy 3 div 2 mul y1 add def
30 /next_iteration iteration 1 sub def
32 x1 y1 xA yA next_iteration koch
33 xA yA xB yB next_iteration koch
34 xB yB xC yC next_iteration koch
35 xC yC x2 y2 next_iteration koch
39 x1 y1 lineto x2 y2 lineto
45 /debug { moveto 20 string cvs show} bind def
46 /Coronet findfont 12 scalefont setfont % Fancy font!
50 /iterations 7 def % Define to the desired number of iterations to crash your pdf viewer
53 0 0 50 100 iterations koch
54 50 100 100 0 iterations koch
55 100 0 0 0 iterations koch closepath
58 % Draw some text and the initial triangle faintly
61 (Snowflake) 28 28 debug
63 0 0 moveto 50 100 lineto 100 0 lineto 0 0 lineto stroke