Skip to content

Instantly share code, notes, and snippets.

@youz
Created October 14, 2020 03:29
Show Gist options
  • Save youz/7a9c2a2d5fad7680b1d98951d21302f9 to your computer and use it in GitHub Desktop.
Save youz/7a9c2a2d5fad7680b1d98951d21302f9 to your computer and use it in GitHub Desktop.
penrose-tiling.ps
%!
%%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
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment