%!PS-Adobe-2.0 %%Pages: 8 % --- Part 1. Make global definitions ------------------------------------------ % builds the path outlining a square with corners % (0, 0), (s, 0), (s, s), (0, s) /buildsquare { 0 0 moveto s 0 lineto s s lineto 0 s lineto closepath } def /a 3 def /b 4 def /c a dup mul b dup mul add sqrt def % find the vertex (x, y) /x a c div a mul def /y b c div a mul def % and some analgous ratios /X a c div b mul def /Y b c div b mul def /N 8 def /draw-page { gsave 72 dup scale 1 72 div setlinewidth 2.5 5.5 translate 0.6 dup scale % --- draw the three squares ------------------------------- /s c def gsave -90 rotate newpath buildsquare stroke grestore /s a def gsave b a atan rotate newpath buildsquare stroke grestore /s b def gsave c 0 translate b a atan rotate newpath buildsquare stroke grestore % --- the vertical line ------------------------------------------------ newpath x y moveto 0 y c add neg rlineto stroke % --- the red triangle ------------------------------------------------ gsave A rotate newpath 0 0 moveto x y lineto 0 c neg lineto closepath gsave 1 0 0 setrgbcolor fill grestore stroke grestore % --- the other triangles ------------------------------------------------ newpath 0 0 moveto y neg x lineto c 0 lineto closepath stroke newpath c 0 moveto c X add Y lineto 0 0 lineto closepath stroke newpath c 0 moveto x y lineto c c neg lineto closepath stroke grestore showpage /Helvetica-Bold findfont 16 scalefont setfont 20 100 moveto (Euclid's proof of Pythagoras' Theorem) show } def % --- Part 2. Draw, run the loop ------------------------------------------ /A 0 def /dA 90 N 1 sub div def %%Page: 1 1 /A 0 def draw-page %%Page: 2 2 /A dA def draw-page %%Page: 3 3 /A dA 2 mul def draw-page %%Page: 4 4 /A dA 3 mul def draw-page %%Page: 5 5 /A dA 4 mul def draw-page %%Page: 6 6 /A dA 5 mul def draw-page %%Page: 7 7 /A dA 6 mul def draw-page %%Page: 8 8 /A dA 7 mul def draw-page