%!ps % Initial Sierpinski Triangle attempt % ====================== % Copyright c 9/2017 by Don Lancaster & Synergetics, Box 809, Thatcher, AZ, 85552 % (928) 428-4073 Email: don@tinaja.com Website: http://www.tinaja.com % Consulting services available don@tinaja.com or http://www.tinaja.com/info01.html % All commercial rights and all electronic media rights ~fully~ reserved. % Linking usually welcome. Reposting expressly forbidden. Version 2.1 % Send code to Acrobat Distiller, preferably using Windows Command % mode and "//acrodist /F". % from gonzo /m {moveto} store /dot2 { currentpoint newpath 5 0 360 arc fill } def /mdot2 { m dot2} def /dot3 { currentpoint newpath 10 0 360 arc fill } def /mdot3 { m dot3} def /bkgcolor {gsave 0.5 0.5 0.5 setrgbcolor fill grestore } store /color1 {gsave 0.4 1 0.4 setrgbcolor fill grestore } store /color2 {gsave 0.4 1 1 setrgbcolor fill grestore } store /color3 {gsave 1 0.4 1 setrgbcolor fill grestore } store /color4 {gsave 1 0.4 0.4 setrgbcolor fill grestore } store /color5 {gsave 0.6 0.6 1 setrgbcolor fill grestore } store /color6 {gsave 1 1 0.4 setrgbcolor fill grestore } store /size 200 store /makeL1 {/L1 mark [0 0] ] store } store /makeL2 {/L2 mark L1 { dup 0 get /rx exch store 1 get /ry exch store [ rx size 0.5 mul neg sub ry] [ rx size 0.5 mul sub ry ] [ rx ry size 60 sin mul add ] } forall ] store } store /makeL3 {/L3 mark L2 { dup 0 get /rxx exch store 1 get /ryy exch store [ rxx size 0.25 mul add ryy ] [ rxx size 0.25 mul add neg ryy ] [ rxx ryy size 2 div 60 sin mul add ] } forall ] store } store /makeL4 {/L4 mark L3 { dup 0 get /rxx exch store 1 get /ryy exch store [ rxx size 0.125 mul add ryy ] [ rxx size 0.125 mul add neg ryy ] [ rxx ryy size 4 div 60 sin mul add ] } forall ] store } store /makeL5 {/L5 mark L4 { dup 0 get /rxx exch store 1 get /ryy exch store [ rxx size 16 div add ryy ] [ rxx size 16 div add neg ryy ] [ rxx ryy size 8 div 60 sin mul add ] } forall ] store } store /makeL6 {/L6 mark L5 { dup 0 get /rxx exch store 1 get /ryy exch store [ rxx size 32 div add ryy ] [ rxx size 32 div add neg ryy ] [ rxx ryy size 16 div 60 sin mul add ] } forall ] store } store makeL1 makeL2 makeL3 makeL4 makeL5 makeL6 L3 == % L1 == L2 == L3 == L4 == /showL1 { L1 { dup 0 get /x exch store 1 get /y exch store x y moveto size 2 div neg size 60 sin mul rlineto size 0 rlineto closepath color1 stroke } forall } store /showL2 { L2 { dup 0 get /xx exch store 1 get /yy exch store xx yy moveto size 4 div neg size 2 div 60 sin mul rlineto size 2 div 0 rlineto closepath color2 stroke } forall } store /showL3 { L3 { dup 0 get /xxx exch store 1 get /yyy exch store xxx yyy moveto size 8 div neg size 4 div 60 sin mul rlineto size 4 div 0 rlineto closepath color3 stroke } forall } store /showL4 { L4 { dup 0 get /xxx exch store 1 get /yyy exch store xxx yyy moveto size 16 div neg size 8 div 60 sin mul rlineto size 8 div 0 rlineto closepath color4 stroke } forall } store /showL5 { L5 { dup 0 get /xxx exch store 1 get /yyy exch store xxx yyy moveto size 32 div neg size 16 div 60 sin mul rlineto size 16 div 0 rlineto closepath color5 stroke } forall } store /showL6 { L6 { dup 0 get /xxx exch store 1 get /yyy exch store xxx yyy moveto size 64 div neg size 32 div 60 sin mul rlineto size 32 div 0 rlineto closepath color6 stroke } forall } store 300 200 translate % set bottom center 1 setlinewidth 1 setlinecap % L2 {aload pop mdot2 } forall % L3 {aload pop mdot2 } forall % L4 {aload pop mdot3} forall % L5 {aload pop mdot3} forall /showoutertriangle true store showoutertriangle { size neg 0 moveto size size 2 mul 60 sin mul rlineto size size 2 mul neg 60 sin mul rlineto closepath bkgcolor stroke } if showL6 % reverse order removes minor glitches showL5 showL4 showL3 showL2 showL1 showpage %EOF