Created
October 14, 2020 03:29
-
-
Save youz/7a9c2a2d5fad7680b1d98951d21302f9 to your computer and use it in GitHub Desktop.
penrose-tiling.ps
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| %! | |
| %%BoundingBox: 0 0 600 450 | |
| % ref. https://tartarus.org/~simon/20110412-penrose/penrose.xhtml | |
| /N 8 def | |
| /linecolor { 0 0.2 0.6 setrgbcolor } def | |
| /fillcolor { 0.8 0.9 1.0 setrgbcolor } def | |
| 0.5 setlinewidth | |
| 2 setlinejoin | |
| /invphi 2 5 sqrt 1 add div def | |
| /tan { dup sin exch cos div } def | |
| /divp { | |
| 4 dict begin | |
| [/qy /qx /py /px] {exch def} forall | |
| px 1 invphi sub mul qx invphi mul add | |
| py 1 invphi sub mul qy invphi mul add | |
| end | |
| } def | |
| /tiling { | |
| 12 dict begin | |
| [/ry /rx /qy /qx /py /px /t] {exch def} forall | |
| 1 sub /i exch def | |
| i 0 le { | |
| px py moveto qx qy lineto rx ry lineto closepath | |
| t 1 eq { gsave fillcolor fill grestore } if | |
| linecolor stroke | |
| } | |
| { | |
| px py qx qy divp /uy exch def /ux exch def | |
| px py rx ry divp /vy exch def /vx exch def | |
| t 0 eq | |
| { | |
| i 1 rx ry ux uy px py tiling | |
| i 0 rx ry ux uy qx qy tiling | |
| } | |
| { | |
| i 1 vx vy ux uy px py tiling | |
| i 0 vx vy ux uy qx qy tiling | |
| i 1 rx ry vx vy qx qy tiling | |
| } ifelse | |
| } ifelse | |
| end | |
| } def | |
| 50 50 translate 36 rotate | |
| N 1 0 0 300 36 tan 300 mul 600 0 tiling | |
| N 1 0 0 300 -36 tan 300 mul 600 0 tiling |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment