home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / Examples / AppKit / Draw / drawWraps.psw < prev    next >
Text File  |  1996-04-05  |  1KB  |  76 lines

  1. #import <string.h>
  2.  
  3. defineps PSInit()
  4.  
  5. /oval {
  6. % w h x y
  7.     translate scale newpath .5 .5 .5 0 360 arc closepath
  8. } def
  9.  
  10. /line {
  11. % w h x y
  12.     moveto rlineto stroke
  13. } def
  14.  
  15. /setup {
  16. % linejoin lincap linewidth
  17.     setlinewidth
  18.     setlinecap
  19.     setlinejoin
  20.     gsave
  21. } def
  22.  
  23. /arrow {
  24. % angle x y
  25.     newpath
  26.     moveto
  27.     dup rotate
  28.     -13 6 rlineto
  29.     4 -6 rlineto
  30.     -4 -6 rlineto
  31.     closepath
  32.     gsave
  33.     0 setlinejoin
  34.     stroke
  35.     grestore
  36.     fill
  37.     neg rotate
  38. } def
  39.  
  40. endps
  41.  
  42. /*
  43.  * The following proc has an interesting feature.  Since we draw an oval by
  44.  * drawing a unit circle, then scaling it in both directions, we run into the
  45.  * problem that the linewidth also gets scaled!  We avoid this by reverting
  46.  * to the device matrix (the non-scaled matrix) just before stroking the line.
  47.  * This works because the path is built up with the scaled matrix, but the
  48.  * stroke is done with the unscaled one.  Neat, huh?
  49.  */
  50.  
  51. defineps PSFramedOval(float x, y, w, h)
  52.     matrix currentmatrix
  53.     w h x y oval
  54.     setmatrix stroke
  55. endps
  56.  
  57. defineps PSFilledOval(float x, y, w, h)
  58.     w h x y oval fill
  59. endps
  60.  
  61. defineps PSLine(float x, y, w, h)
  62.     w h x y line
  63. endps
  64.  
  65. defineps PSCurve(float x0, y0, x1, y1, x2, y2, x3, y3)
  66.     x0 y0 moveto x1 y1 x2 y2 x3 y3 curveto stroke
  67. endps
  68.  
  69. defineps PSArrow(float x, y, angle)
  70.     angle x y arrow
  71. endps
  72.  
  73. defineps PSSetParameters(int cap, join; float linewidth)
  74.     join cap linewidth setup
  75. endps
  76.