lines.ps 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. %!
  2. % Copyright (C) 1989, 1990, 1992, 1994, 1996 Aladdin Enterprises. All rights reserved.
  3. %
  4. % This software is provided AS-IS with no warranty, either express or
  5. % implied.
  6. %
  7. % This software is distributed under license and may not be copied,
  8. % modified or distributed except as expressly authorized under the terms
  9. % of the license contained in the file LICENSE in this distribution.
  10. %
  11. % For more information about licensing, please refer to
  12. % http://www.ghostscript.com/licensing/. For information on
  13. % commercial licensing, go to http://www.artifex.com/licensing/ or
  14. % contact Artifex Software, Inc., 101 Lucas Valley Road #110,
  15. % San Rafael, CA 94903, U.S.A., +1(415)492-9861.
  16. % $Id: lines.ps,v 1.4 2002/02/21 21:49:28 giles Exp $
  17. % Test line rendering (stroke).
  18. % Exercise the miter limit. The left column of lines should bevel at
  19. % 90 degrees, the right column at 60 degrees.
  20. gsave
  21. 1.8 setlinewidth
  22. 0 setgray
  23. 15 15 scale
  24. -5 5 translate
  25. [1.415 2.0]
  26. { setmiterlimit 12 0 translate 0 0 moveto
  27. 10 30 360
  28. { gsave 5 0 rlineto rotate 2.5 0 rlineto
  29. gsave 0 setlinewidth 1 0 0 setrgbcolor stroke grestore
  30. strokepath 0 setlinewidth stroke
  31. grestore
  32. 0 4 rmoveto
  33. } for
  34. } forall
  35. showpage
  36. grestore
  37. % Exercise all the combinations of cap and join styles
  38. % for one-line, two-line, and closed paths.
  39. gsave
  40. /drawlines {
  41. gsave
  42. 2.0 setmiterlimit
  43. 2.0 setlinewidth
  44. 6 6 scale
  45. 5 20 translate
  46. {0 1 2} % line cap
  47. { setlinecap gsave
  48. {0 1 2} % line join
  49. { setlinejoin gsave
  50. { {currentpoint lineto}
  51. {3 7 lineto}
  52. {3 7 lineto 5 1 lineto}
  53. {3 7 lineto 6 3 lineto closepath}
  54. }
  55. { gsave 0 0 moveto exec
  56. gsave stroke grestore
  57. 0.5 setlinewidth 1 0 0 setrgbcolor stroke
  58. grestore 8 0 translate
  59. } forall
  60. grestore 35 0 translate
  61. } forall
  62. grestore 0 20 translate
  63. } forall
  64. grestore
  65. } def
  66. /xflip
  67. { 8.5 72 mul 0 translate -1 1 scale
  68. } def
  69. /rot90
  70. { 90 rotate 0 -9.75 72 mul translate
  71. } def
  72. /rot180
  73. { rot90 rot90
  74. } def
  75. /rot270
  76. { rot180 rot90
  77. } def
  78. drawlines showpage
  79. gsave xflip drawlines grestore showpage
  80. gsave rot90 drawlines grestore showpage
  81. gsave rot90 xflip drawlines grestore showpage
  82. gsave drawlines rot180 showpage
  83. gsave rot180 xflip drawlines grestore showpage
  84. gsave rot270 drawlines grestore showpage
  85. gsave rot270 xflip drawlines grestore showpage
  86. grestore
  87. % Here are some boundary conditions, contributed by Mark Rawling.
  88. gsave
  89. 1 setlinecap
  90. 2.6 setmiterlimit
  91. 3.0 setlinewidth
  92. 5 5 scale
  93. 10 20 translate
  94. % [ 0.5 sqrt dup dup dup neg exch 0 0 ] concat % 45 rotate
  95. {0 1 2} % line join
  96. {
  97. setlinejoin gsave
  98. 0 0 moveto 0 10 lineto 10 0 lineto gsave stroke grestore
  99. 15 0 translate
  100. 0 0 moveto 0 10 lineto 10 20 lineto gsave stroke grestore
  101. 15 0 translate
  102. 10 0 moveto 10 10 lineto 0 20 lineto gsave stroke grestore
  103. 15 0 translate
  104. 10 0 moveto 10 10 lineto 0 0 lineto gsave stroke grestore
  105. grestore
  106. gsave
  107. 0 20 translate
  108. 0 20 moveto 0 10 lineto 10 20 lineto gsave stroke grestore
  109. 15 0 translate
  110. 0 20 moveto 0 10 lineto 10 0 lineto gsave stroke grestore
  111. 15 0 translate
  112. 10 20 moveto 10 10 lineto 0 0 lineto gsave stroke grestore
  113. 15 0 translate
  114. 10 20 moveto 10 10 lineto 0 20 lineto gsave stroke grestore
  115. grestore 60 0 translate
  116. } forall
  117. showpage
  118. grestore
  119. % Test narrow lines at a variety of angles.
  120. gsave
  121. /rad 120 def
  122. /ray { gsave rotate 0 0 moveto rad 0 rlineto stroke grestore } def
  123. /star
  124. { newpath gsave
  125. gsave 0.5 setgray 0 0 rad 0 360 arc stroke grestore
  126. 0 90 359
  127. { rotate
  128. 0 3 14 { ray } for
  129. 15 15 89 { ray } for
  130. } for
  131. grestore
  132. } def
  133. 0 setgray
  134. 150 150 translate
  135. [ [ 0 0.5 1 ] [ 1.5 2 2.5 ] [ 3 3.5 4 ] ]
  136. { gsave
  137. { setlinewidth star
  138. 250 0 translate
  139. } forall
  140. grestore 0 250 translate
  141. } forall
  142. grestore showpage
  143. % End
  144. quit