Skip to content

Instantly share code, notes, and snippets.

@jgamble
Created June 19, 2018 21:03
Show Gist options
  • Select an option

  • Save jgamble/bbaff6f932adc21e804cdf43eaae308f to your computer and use it in GitHub Desktop.

Select an option

Save jgamble/bbaff6f932adc21e804cdf43eaae308f to your computer and use it in GitHub Desktop.
Impossible Triangle Illusion in Postscript, by Guy Shaw (circa 1990)
%!
% M. C. Escher style impossible triangle
% written by Guy Shaw
% Things that are easy to play with:
% Position on paper, overall size, and linewidth
/inch { 72 mul } bind def
2 inch dup translate
3 inch dup scale
1 3 inch div setlinewidth
% Thickness parameter:
% /Thick is the thickness of the structural members of the triange,
% as a fraction of the height of the triangle.
% Reasonable looking impossible triangles can be obtained with Thick <= 1/6.
% right at /Thick == 1/6, there is no space left inside the triangle.
% /Thick > 1/6 yields bizarre, but not very interesting results.
% /Thick < 1/20 is less interesting, because the "impossibility"
% is not so striking when the structural members are that thin.
% A good "standard" value is 1/8.
/Thick 1 8 div def
% You would not normally want to change anything that follows.
/Tall 1 def
/HalfThick Thick .5 mul def
newpath
HalfThick Thick moveto
Thick 0 lineto
1 Thick sub 0 lineto
1 HalfThick sub Thick lineto
.5 HalfThick add Tall Thick sub lineto
1 Thick sub 0 moveto
.5 HalfThick add Tall 3 Thick mul sub lineto
Thick 3 mul Thick 2 mul lineto
1 Thick 2.5 mul sub Thick moveto
.5 Tall Thick 4 mul sub lineto
stroke
newpath
HalfThick Thick moveto
1 Thick 2.5 mul sub Thick lineto
HalfThick neg Thick rlineto
Thick Thick add Thick Thick add lineto
.5 HalfThick add Tall Thick sub lineto
Thick neg 0 rlineto
closepath
fill
showpage
% --
% Guy Shaw
% Paralogics
% paralogics!shaw@uunet.uu.net or uunet!paralogics!shaw
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment