home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 344a.lha / Post_v.02 / examples / escher.ps < prev    next >
Encoding:
Text File  |  1990-01-28  |  10.9 KB  |  303 lines

  1. %!PS-Adobe-1.0
  2. %%Title:Square-recursion
  3. %%DocumentFonts: (atend)
  4. %%Creator: John Pratt and M.C.Escher
  5. %%CreationDate:25 November 1987
  6. %%Pages: (atend)
  7. %%EndComments
  8.  
  9. %%EndProlog
  10.  
  11. %%Page: 1 1
  12. /Helvetica-Bold findfont 0.5 scalefont setfont
  13. /level 1 def                            %control variable for recursion
  14. /maxlevel 2 def                         %Limit of recursion, 3 takes 25 min.
  15. /Down { /level level 1 add def }def
  16. /Up {/level level 1 sub def} def
  17.  
  18. /Colour  0 def %base colour variable
  19. /Parity 0 def           /Swap {/Parity 0.5 Parity sub def} def
  20. /Odd-colour {/Colour Parity def} def
  21. /Even-Colour {/Colour 0.5 Parity sub def} def
  22. /White {/Colour 1 def} def
  23. /Comp {Colour 1 ne {1 setgray} {0 setgray} ifelse} def
  24.  
  25. /cm {28.35 mul} def     /Root2 2 sqrt def       /Invr2 0.5 sqrt def
  26. /HeadMatrix matrix              %create matrix for head triangle
  27.         45 matrix rotate matrix concatmatrix
  28.         Invr2 neg Invr2 matrix scale  matrix concatmatrix
  29.         0 10 matrix translate matrix concatmatrix def
  30.                 %cf 0 10 translate Invr2 neg Invr2 scale 45 rotate
  31.  
  32. /UpheadMatrix HeadMatrix matrix invertmatrix def
  33.                 % cf -45 rotate Root2 neg Root2 scale 0 -10 translate
  34.  
  35. /TailMatrix matrix              %create matrix for tail triangle
  36.       -45 matrix rotate matrix concatmatrix
  37.         Invr2 neg Invr2 matrix scale  matrix concatmatrix
  38.         0 10 matrix translate matrix concatmatrix   def
  39.                 %cf {0 10 translate Invr2 neg Invr2 scale -45 rotate}
  40.  
  41. /UptailMatrix TailMatrix matrix invertmatrix def
  42.                         % cf 45 rotate Root2 neg Root2 scale 0 -10 translate
  43.  
  44. /Op1 matrix              %matrix for duple opposite
  45.         0 -10 matrix translate matrix concatmatrix
  46.         180 matrix rotate matrix concatmatrix
  47.         0 10 matrix translate matrix concatmatrix def
  48.  
  49. /Downhead {HeadMatrix concat} def               %apply to CTM
  50. /Uphead  {UpheadMatrix concat} def              %apply to CTM
  51. /Downtail {TailMatrix concat}  def              %apply to CTM
  52. /Uptail {UptailMatrix concat} def               %apply to CTM
  53. /Op {Op1 concat} def                            %apply to CTM
  54.  
  55. /DwnR {HeadMatrix transform} def        %applies Head matrix to point
  56. /UpR {UpheadMatrix transform} def       %applies UpHead matrix to point
  57. /DwnL {TailMatrix transform} def        %applies Tail matrix to point
  58. /UpL {UptailMatrix transform} def       %applies UpTail matrix to point
  59. /Opp {Op1 transform} def                %applies opposite matrix to point
  60.  
  61. /Qflip {exch neg exch} def              %Flip by X, X/Y point 180
  62. /Qrot90 {exch neg} def                  %rotate X/Y point   -90
  63. /Qrotm90 {neg exch } def                %rotate X/Y point 90
  64. /Qxtran {3 -1 roll add exch} def        %adds top to 3rd, X
  65.  
  66. /A {10 10} def          /A1 {9 8} def           /A2 {7.5 6.2} def
  67. /Ah {A -1 Qxtran -0.5 add } def
  68. /B {6 5.6} def          /B1 {4.8 5} def         /B2 {2.2 4.5} def
  69. /C {0 5} def            /C1 {-1.1 5.3} def      /C2 {-4.2 6} def
  70. /D {B Qrotm90} def      /D1 {A1 Qrotm90} def    /D2 {A2 Qrotm90} def
  71. /E {A Qrotm90} def      /E1 {A1 DwnL} def       /E2 {A2 DwnL} def
  72. /Eh {Ah Qflip} def
  73. /F {B DwnL} def         /F1 {F 2 Qxtran 2 sub} def      /F2 {-2 7} def
  74. /G {0 7.6} def          /G1 {2 8.2} def         /G2 {3.2 9.5 } def
  75. /Gt {G UpL} def
  76. /H {5.1 10} def         /H1 {6.5 10.5} def      /H2 {8 10.5} def
  77.                         /I1 {0 4} def           /I2  {0 2} def
  78. /J {0 0} def            /J1 {3 0} def           /J2 {3 0} def
  79. /K {C Qrot90} def
  80. /L {C DwnR} def         /L1 {C1 DwnR }def       /L2 {4.7 11} def
  81. /N {0 10.7} def         /N1 {I1 DwnR} def       /N2 {I2 DwnR} def
  82. /Nt {N UpL} def
  83. /P {L Qflip} def
  84.                         /Q1 {4.1 12.4} def      /Q2 {2 13.1} def
  85.  
  86. /a {A1 A2 B} def        /b {B1 B2 C} def
  87. /c {C1 C2 D} def
  88. /d {D2 D1 E} def        /e {E1 E2 F} def
  89. /f {F1 F2 G} def        /fr {F2 UpL F1 UpL F UpL} def
  90. /g {G1 G2 H} def
  91. /h {H1 H2 A} def        /hr {H2 H1 H} def
  92. /i {I1 I2 J } def       /j {J1 J2 K} def
  93. /k {C1 Qrot90 C2 Qrot90 B} def  % c with 90 rotate about O
  94. /l {L2 L1 L} def        /lr {L1 L2 H} def       %l reversed
  95. /n {N1 N2 N } def       /ns {I1 I2 N UpR} def   /nm (J M P) def
  96. /o {G} def              /ot {Gt} def            % straight line
  97. /p {I2  Qrot90 I1 Qrot90 C Qrot90} def %ie of tailfish
  98. /pr {I1 I2 Nt } def
  99. /q {Q1 Q2 G Opp} def    /s {Comp nm Pup} def
  100.  
  101. /Fr1 {                  %Fish righthand (convex side)
  102.         A  moveto  a  curveto b curveto  c curveto  d curveto
  103.       } def
  104.  
  105. /Fr2 {                  %Fish righthand for 45 deg angle
  106.         A  moveto  a  curveto b curveto
  107.         Uphead          %always used in head half
  108.                 lr curveto   h curveto
  109.         Downhead
  110.       } def
  111.  
  112. /Fl1 {                  %Fish lefthand (concave side)
  113.         e curveto f curveto   g curveto  h curveto
  114.       } def
  115.  
  116. /Fl2 {                  %Fish lefthand for duple
  117.         Op              %using opposite fish points
  118.                 hr curveto  q curveto
  119.         Op              %cancelling Op
  120.         g curveto  h curveto
  121.       } def
  122.  
  123. /Fc1 {                  %Fishcentre inside
  124.         Ah moveto   C C -0.6 Qxtran Eh curveto
  125.       } def
  126.  
  127. /Fc2 {                  %Fish centre outside and blunt ends
  128.         Eh -0.05 add lineto
  129.         C -0.25 add -0.6 Qxtran C -0.25 add Ah -0.05 add curveto
  130.         Ah lineto
  131.       } def
  132.  
  133. /Tailrib1 {newpath -6 9 moveto -5 8 -4 7.3 -2.4 6.9 curveto
  134.         stroke} def
  135. /Tailrib2 {newpath -5.5 6.7 moveto -4.5 6.3  -3.5 6.2 -2.3 6 curveto
  136.         stroke} def
  137. /Tailrib3 {newpath -2.2 7.1 moveto -2.4 6.7  -2.4 6.2 -2.2 5.8 curveto
  138.         stroke} def
  139. /Tailribs  {Tailrib1 Tailrib2 Tailrib3} def
  140.  
  141. /EyeshapeL {newpath -0.4 0.8 moveto 0.7 1.3 1.5 1.2 2.5 0.8 curveto
  142.         1.9  0   1.1 -0.4   0.1 -0.9 curveto
  143.         0  -0.2  -0.1 0.3  -0.4 0.8 curveto closepath} def
  144. /EyeL {gsave  5.6 8.9 translate EyeshapeL
  145.         Colour 1 ne {fill}{stroke} ifelse grestore} def
  146.  
  147. /EyePupL {   gsave 5.8 9 translate  0.4 0.4 scale  EyeshapeL
  148.         fill grestore } def
  149.  
  150. /EyeshapeR { newpath 0  0.8 moveto 1.4 1.6  1.9 1.6  2.6 1.5 curveto
  151.         2.4 0.8  1.6 0  0.1 -0.8 curveto
  152.         0.1 -0.3 0.1 0.3  0 0.8 curveto closepath } def
  153.  
  154. /EyeR {gsave 5.9 6.7 translate EyeshapeR
  155.         Colour 1 ne {fill}{stroke} ifelse grestore} def
  156.  
  157. /EyePupR {   gsave 6.1 6.7 translate  0.4 0.4 scale  EyeshapeR
  158.         fill grestore} def
  159.  
  160. /Pupcol {Colour 1 ne  {Colour setgray } if  } def
  161.  
  162. /Pup    {-3 0 moveto show} def
  163.  
  164. /FishMain {     Comp    %compliment colour
  165.         newpath  Fc1 Fc2  closepath  gsave fill grestore
  166.         Tailribs
  167.         0.01 setlinewidth  EyeR EyeL
  168.         Pupcol EyePupR EyePupL } def
  169.  
  170. /Fish { Colour setgray newpath   Fr1 Fl1  closepath  gsave fill grestore
  171.         FishMain } def
  172.  
  173. /Fishd { Colour setgray newpath  Fr1 Fl2  closepath  gsave fill grestore
  174.         FishMain} def
  175.  
  176. /Fish45r {Colour setgray newpath  Fr2 Fl1  closepath    gsave fill grestore
  177.         FishMain } def
  178.  
  179. /Fish45d { Colour setgray newpath  Fr2 Fl2  closepath   gsave fill grestore
  180.         FishMain} def
  181.  
  182. /Ribl {newpath H moveto l curveto  stroke } def
  183. /Ribk {newpath K moveto k curveto  stroke }def
  184. /Ribf {newpath Gt moveto fr curveto stroke } def
  185. /Ribb {newpath B moveto b curveto  stroke } def
  186. /Ribg {newpath G moveto g curveto stroke} def
  187.  
  188. /Wingribs %stack SideRib WingRib Translate-offset Translate-inc Y-Scale-inc
  189.         {4 copy 4 copy          %copy parameters given for 3 ribs
  190.         Comp    0.15 setlinewidth
  191.         0 1 2 {gsave                             %stack --Wr To Ti Sy Loopv
  192.                 dup dup 0.25 mul 0.75 exch sub   %stack ----Sy Lv Lv Sx
  193.                 exch 4 -1 roll mul 0.95 exch sub %stack ---To Ti Lv Sx Sy
  194.                         scale                    %stack --To Ti Lv
  195.                 mul add 0 exch  translate        %stack --Wr
  196.           cvx exec                      %execute WingRibxx
  197.                 grestore } for          %stack Sr
  198.           cvx exec } def                %execute Sideribxx
  199.  
  200. /QuadWing { Colour setgray newpath              %wing for quad
  201.         C moveto  i curveto  j curveto   k curveto  b curveto
  202.         closepath  fill
  203.         /Ribb /Ribk 0.5  0  0 Wingribs
  204.        } def
  205.  
  206. /TriWing1       { Colour setgray newpath        %wing on Hypoteneuse for triple
  207.         G moveto  g curveto  l curveto   n curveto  o lineto
  208.         closepath  fill
  209.         /Ribg /Ribl -0.5 0 0.04 Wingribs  } def
  210.  
  211. /TriWing2 { Colour setgray newpath              %wing on head side for triple
  212.         C moveto  ns curveto  p curveto  k curveto  b curveto
  213.         closepath  fill
  214.         /Ribb /Ribk 0.5 0.1 0 Wingribs  } def
  215.  
  216. /TriWing3 { Colour setgray  newpath             %wing on tail side for triple
  217.         C moveto  pr curveto   ot lineto   fr curveto  b curveto
  218.         closepath  fill
  219.         /Ribb /Ribf 0.8 0.6 0.03 Wingribs       }def
  220.  
  221. /DupleWing {  Colour setgray newpath            %wing for duple
  222.         G moveto  g curveto  q curveto o lineto
  223.         closepath  fill
  224.         /Ribg /Ribl -0.5 0 0.04 Wingribs }def
  225.  
  226. /Wings0 {QuadWing TriWing1} def
  227. /Wings1 {TriWing2 TriWing1} def
  228. /Wings2 {TriWing3 TriWing1} def
  229. /Wings3 {TriWing2 DupleWing} def
  230. /Wings4 {TriWing3 DupleWing} def
  231. /Wings5 {QuadWing DupleWing} def
  232.  
  233. /Headpair {Downhead
  234.                 Odd-colour Wings1 Fish45r       %fish Hh
  235.                   Down  Sextet   Up     % recurse to smaller level
  236.           -90 rotate                            %Uphead Downtail
  237.                  Even-Colour   Wings4 Fishd
  238.            Uptail                       %fish Ht
  239.         } def
  240. /Tailpair {Downhead
  241.                 White Wings3 Fish45d    %fish Th
  242.            -90 rotate                   %Uphead Downtail
  243.                 Odd-colour Wings2 Fish   %fish Tt
  244.                   Down  Sextet Up
  245.            Uptail } def
  246.  
  247. /Sextet {level maxlevel le {
  248.         Downhead
  249.                 White  Wings1 Fish45r           %fish H
  250.             Headpair
  251.         -90 rotate                              %Uphead+downtail
  252.                 Even-Colour  Wings2 Fish                %fish  T
  253.             Tailpair
  254.         Uptail
  255.      }if} def
  256.  
  257. /RCorner {level maxlevel le {
  258. 20 0 translate
  259.    Downtail
  260.         Downhead
  261.                  White  Wings5 Fish45d          %fish Th with S wing
  262.         -90 rotate                              %Uphead Downtail
  263.                  Odd-colour  Wings0 Fish                %fish Tt
  264.                 Down  Sextet RCorner Up
  265.         Uptail
  266.    Uptail
  267. -20 0 translate
  268.         }if } def
  269.  
  270. /LCorner {level maxlevel le {
  271. -20 0 translate
  272.    Downhead
  273.         Downtail
  274.                 Even-Colour Wings5 Fishd        %fish Ht with S wing
  275.         90 rotate                       %Uptail Downhead
  276.                 Odd-colour Wings0 Fish
  277.                 Down  Sextet  LCorner Up
  278.         Uphead
  279.    Uphead
  280. 20 0 translate
  281.         }if } def
  282.  
  283. /Centre {Odd-colour  Wings0 Fish} def
  284.  
  285. gsave
  286.   10 cm 15 cm translate
  287.   0.3 cm 0.3 cm scale 0.05 setlinewidth
  288.   1 setflat 1 setlinecap
  289.   150 45 {0.5 mul add} setscreen
  290. 4 {Centre Sextet RCorner LCorner Swap -90 rotate} repeat s
  291. grestore
  292. gsave
  293. 491 742 translate
  294. -90 rotate
  295. 0 0 moveto
  296. (lev 1 max 2 ) show
  297. grestore
  298. showpage
  299.  
  300. %%Trailer
  301. %%Pages: 1
  302. %%DocumentFonts: Helvetica-Bold
  303.