home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1994 June / NEBULA_SE.ISO / SourceCode / MiscKit / Palettes / MiscArrowButtonPalette / MiscArrowButton.subproj / wraps.psw < prev   
Encoding:
Text File  |  1994-01-11  |  2.6 KB  |  160 lines

  1.  
  2. /*     This is not guarenteed to be efficient,  it does the job. 
  3.      I am just learning, so if anything is really bad, please let me know */
  4.     
  5. /*     PSABdrawdiamond makes the assumption that the height will always
  6.     be smaller than the width, which may not always be true... */
  7.  
  8. defineps PSABdrawdiamond (float x; float y; float width; float height)
  9.  
  10. % upper right dark gray edge
  11.  
  12. /halfh height 2 div def
  13. /halfw width 2 div def
  14.  
  15. newpath
  16. 1 setlinecap
  17. 1 setlinewidth
  18. .333 setgray
  19. x y moveto
  20. halfw height rmoveto
  21. halfh  halfh neg rlineto
  22. stroke
  23.  
  24.  
  25. % lower left dark gray edge
  26.  
  27. newpath
  28. .333 setgray
  29. x y moveto
  30. halfw 0 rmoveto
  31. halfh neg halfh rlineto
  32. stroke
  33.  
  34. % white edge (upper right)
  35.  
  36. newpath
  37. 1 setlinecap
  38. 1 setgray
  39. x y moveto
  40. halfw height rmoveto
  41. halfh neg halfh neg rlineto
  42. stroke
  43.  
  44. % white shadow
  45.  
  46. newpath
  47. .8 setgray
  48. x y moveto
  49. halfw 1 sub height  rmoveto
  50. halfh  neg halfh  neg rlineto
  51. stroke
  52.  
  53. % black edge    (lower right)
  54.  
  55. newpath
  56. 1 setlinecap
  57. 0 setgray
  58. x y moveto
  59. halfw 0 rmoveto
  60. halfh halfh rlineto
  61. stroke
  62.  
  63. % low right shadow
  64.  
  65. newpath
  66. .333 setgray
  67. x y moveto
  68. halfw 1 add 0 rmoveto
  69. halfh 1 sub  halfh 1 sub rlineto
  70. stroke
  71.  
  72. % the light gray rectangle inside the main one (10 10 scale and you'll see)
  73.  
  74. newpath
  75. .667 setgray
  76. x y moveto
  77. halfw 1 rmoveto
  78. halfh 1 sub neg halfh 1 sub rlineto
  79. halfh 1 sub halfh 1 sub rlineto
  80. halfh 1 sub halfh 1 sub neg rlineto
  81. closepath
  82. stroke
  83.  
  84. showpage
  85.  
  86. endps
  87.  
  88.  
  89.  
  90. /*     Draws the black arrow. If direction is zero then it points to the
  91.     left, else it points to the right. */ 
  92.  
  93. defineps PSABdrawarrow (float x; float y; float width; float height; 
  94.         int direction; int enabled)
  95.  
  96. % the inside black triangle (pointing right for this example)
  97.  
  98. /halfh height 2 div def
  99. /halfw width 2 div def
  100. /ratio halfh 2 div 1 sub def
  101.  
  102. % erase the middle rectangle
  103.  
  104. newpath
  105. .667 setgray
  106. x y moveto
  107. halfw ratio rmoveto
  108. halfh ratio sub neg halfh ratio sub rlineto
  109. halfh ratio sub halfh ratio sub rlineto
  110. halfh ratio sub halfh ratio sub neg rlineto
  111. closepath
  112. fill
  113. stroke
  114.  
  115. % draw the new black arrow depending on direction
  116.  
  117. enabled 1 eq
  118. {
  119.  newpath
  120.  0 setgray 
  121.  x y moveto
  122.  halfw ratio rmoveto
  123.  direction 0 eq 
  124.  { halfh ratio sub neg halfh ratio sub rlineto
  125.    halfh ratio sub halfh ratio sub rlineto }
  126.  { halfh ratio sub halfh ratio sub rlineto 
  127.    halfh ratio sub neg halfh ratio sub rlineto } ifelse
  128.  closepath
  129.  fill
  130.  stroke
  131. } if
  132.  
  133. showpage
  134.  
  135. endps
  136.  
  137.  
  138.  
  139. /*     Just a little wrap to draw upside down just in case the view is flipped */
  140.  
  141. defineps PSABflipme (float height)
  142.  
  143. 1.0 -1.0 scale
  144. 0.0 height neg translate
  145.  
  146. endps
  147.  
  148.  
  149.  
  150. /* Assumes that you already have set a font */
  151.  
  152. defineps PSABshowstring (float x; float y; float gray; char *str)
  153.  
  154. gray setgray
  155. x y moveto
  156. (str) show
  157.  
  158. endps
  159.  
  160.