You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

164 lines
3.6 KiB

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