lines.ps 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. %!
  2. % Copyright (C) 1989, 1990, 1992, 1994, 1996 Aladdin Enterprises. All rights reserved.
  3. %
  4. % This file is part of AFPL Ghostscript.
  5. %
  6. % AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author or
  7. % distributor accepts any responsibility for the consequences of using it, or
  8. % for whether it serves any particular purpose or works at all, unless he or
  9. % she says so in writing. Refer to the Aladdin Free Public License (the
  10. % "License") for full details.
  11. %
  12. % Every copy of AFPL Ghostscript must include a copy of the License, normally
  13. % in a plain ASCII text file named PUBLIC. The License grants you the right
  14. % to copy, modify and redistribute AFPL Ghostscript, but only under certain
  15. % conditions described in the License. Among other things, the License
  16. % requires that the copyright notice and this notice be preserved on all
  17. % copies.
  18. % $Id: lines.ps,v 1.2 2000/09/19 18:29:11 lpd Exp $
  19. % Test line rendering (stroke).
  20. % Exercise the miter limit. The left column of lines should bevel at
  21. % 90 degrees, the right column at 60 degrees.
  22. gsave
  23. 1.8 setlinewidth
  24. 0 setgray
  25. 15 15 scale
  26. -5 5 translate
  27. [1.415 2.0]
  28. { setmiterlimit 12 0 translate 0 0 moveto
  29. 10 30 360
  30. { gsave 5 0 rlineto rotate 2.5 0 rlineto
  31. gsave 0 setlinewidth 1 0 0 setrgbcolor stroke grestore
  32. strokepath 0 setlinewidth stroke
  33. grestore
  34. 0 4 rmoveto
  35. } for
  36. } forall
  37. showpage
  38. grestore
  39. % Exercise all the combinations of cap and join styles
  40. % for one-line, two-line, and closed paths.
  41. gsave
  42. /drawlines {
  43. gsave
  44. 2.0 setmiterlimit
  45. 2.0 setlinewidth
  46. 6 6 scale
  47. 5 20 translate
  48. {0 1 2} % line cap
  49. { setlinecap gsave
  50. {0 1 2} % line join
  51. { setlinejoin gsave
  52. { {currentpoint lineto}
  53. {3 7 lineto}
  54. {3 7 lineto 5 1 lineto}
  55. {3 7 lineto 6 3 lineto closepath}
  56. }
  57. { gsave 0 0 moveto exec
  58. gsave stroke grestore
  59. 0.5 setlinewidth 1 0 0 setrgbcolor stroke
  60. grestore 8 0 translate
  61. } forall
  62. grestore 35 0 translate
  63. } forall
  64. grestore 0 20 translate
  65. } forall
  66. grestore
  67. } def
  68. /xflip
  69. { 8.5 72 mul 0 translate -1 1 scale
  70. } def
  71. /rot90
  72. { 90 rotate 0 -9.75 72 mul translate
  73. } def
  74. /rot180
  75. { rot90 rot90
  76. } def
  77. /rot270
  78. { rot180 rot90
  79. } def
  80. drawlines showpage
  81. gsave xflip drawlines grestore showpage
  82. gsave rot90 drawlines grestore showpage
  83. gsave rot90 xflip drawlines grestore showpage
  84. gsave drawlines rot180 showpage
  85. gsave rot180 xflip drawlines grestore showpage
  86. gsave rot270 drawlines grestore showpage
  87. gsave rot270 xflip drawlines grestore showpage
  88. grestore
  89. % Here are some boundary conditions, contributed by Mark Rawling.
  90. gsave
  91. 1 setlinecap
  92. 2.6 setmiterlimit
  93. 3.0 setlinewidth
  94. 5 5 scale
  95. 10 20 translate
  96. % [ 0.5 sqrt dup dup dup neg exch 0 0 ] concat % 45 rotate
  97. {0 1 2} % line join
  98. {
  99. setlinejoin gsave
  100. 0 0 moveto 0 10 lineto 10 0 lineto gsave stroke grestore
  101. 15 0 translate
  102. 0 0 moveto 0 10 lineto 10 20 lineto gsave stroke grestore
  103. 15 0 translate
  104. 10 0 moveto 10 10 lineto 0 20 lineto gsave stroke grestore
  105. 15 0 translate
  106. 10 0 moveto 10 10 lineto 0 0 lineto gsave stroke grestore
  107. grestore
  108. gsave
  109. 0 20 translate
  110. 0 20 moveto 0 10 lineto 10 20 lineto gsave stroke grestore
  111. 15 0 translate
  112. 0 20 moveto 0 10 lineto 10 0 lineto gsave stroke grestore
  113. 15 0 translate
  114. 10 20 moveto 10 10 lineto 0 0 lineto gsave stroke grestore
  115. 15 0 translate
  116. 10 20 moveto 10 10 lineto 0 20 lineto gsave stroke grestore
  117. grestore 60 0 translate
  118. } forall
  119. showpage
  120. grestore
  121. % Test narrow lines at a variety of angles.
  122. gsave
  123. /rad 120 def
  124. /ray { gsave rotate 0 0 moveto rad 0 rlineto stroke grestore } def
  125. /star
  126. { newpath gsave
  127. gsave 0.5 setgray 0 0 rad 0 360 arc stroke grestore
  128. 0 90 359
  129. { rotate
  130. 0 3 14 { ray } for
  131. 15 15 89 { ray } for
  132. } for
  133. grestore
  134. } def
  135. 0 setgray
  136. 150 150 translate
  137. [ [ 0 0.5 1 ] [ 1.5 2 2.5 ] [ 3 3.5 4 ] ]
  138. { gsave
  139. { setlinewidth star
  140. 250 0 translate
  141. } forall
  142. grestore 0 250 translate
  143. } forall
  144. grestore showpage
  145. % End
  146. quit