home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1995 August / NEBULA.bin / SourceCode / MiscKit1.2.6 / Palettes / MiscCircularSlider / MiscCircularSlider.subproj / MiscCSWraps.psw < prev    next >
Encoding:
Text File  |  1994-03-27  |  6.2 KB  |  147 lines

  1.  
  2. defineps MiscCSDrawBezel(float xx; float yy; float realradius; float width; float grayLevel)
  3.  
  4. % this is straight from yap and needs tweaking/cleaning up.
  5. gsave
  6. xx yy 1 add translate
  7. /radius realradius 2 sub width 2 div sub def
  8. /x realradius 1 add def
  9. /y realradius 2 sub def
  10. /circle { translate x y radius 0 360 arc closepath stroke } def
  11. gsave
  12.     width setlinewidth
  13.     0.333 setgray -2 2 circle 0 1 circle 1 0 circle
  14.     0 setgray 0 -1 circle 0 -1 circle 1 1 circle
  15.     1 setgray 0 -2 circle 1 0 circle 0 1 circle
  16.     grayLevel setgray
  17.     -1 0 circle
  18. grestore
  19. grestore
  20. endps
  21.  
  22. defineps MiscCSDrawKnob(float xx; float yy; float realradius; float width; float angle)
  23.  
  24. % this is straight from yap and needs tweaking/cleaning up.
  25. gsave
  26. xx yy 1 add translate
  27. /radius realradius 2 sub width 2 div sub def
  28. /x realradius 1 add def
  29. /y realradius 2 sub def
  30. /knobwidth width 4 sub def
  31. /knob { translate knobwidth knobwidth scale newpath 0.5 0.5 0.5 0 360 arc closepath fill grestore gsave } def
  32.   gsave
  33.     angle cos radius mul x 1 add add
  34.     angle sin radius mul y 1 add add translate
  35.     width 2 div neg  4 sub width 2 div neg 2 add translate
  36.     0 setgray gsave 7 -2 knob 7 0 knob 5 -2 knob grestore
  37.     0.333 setgray gsave 6 -1 knob 6 0 knob  5 -1 knob grestore
  38.     1 setgray gsave 4 1 knob 4 0 knob 5 1 knob grestore
  39.     0.666 setgray gsave 5 0 knob grestore
  40.   grestore
  41. grestore
  42. endps
  43.  
  44. defineps MiscCSDrawBackground(float center_x; float center_y; float radius; float height; float width)
  45.     gsave
  46.     center_x center_y translate    %% xlate to the center of the circle
  47.     %% if height is greater than the width then scale the y by height / width
  48.     height width gt { 1 height width div scale } if
  49.     %% if height is less than the width then scale the x by width / height
  50.     height width lt { width height div 1 scale } if
  51.     %% Draw the Raised Background
  52.     newpath 1.0 setgray -1.0 1.5 radius 2 add 0 360 arc closepath fill
  53.     newpath 0.0 setgray 1.5 -1 radius 2 add 225 45 arc closepath fill
  54.     newpath 0.3333 setgray 1.5 -0.25 radius 1 add 0 360 arc closepath fill
  55.     grestore
  56. endps
  57.  
  58. defineps MiscCSPieChart(float center_x; float center_y; float radius; float height; float width; float angle)
  59.     gsave
  60.     center_x center_y translate    %% translate to center of circle
  61.     %% if height is greater than the width then scale the y by height / width
  62.     height width gt { 1 height width div scale } if
  63.     %% if height is less than the width then scale the x by width / height
  64.     height width lt { width height div 1 scale } if
  65.     %% Draw the background of the Circular Slider
  66.     newpath 0.33333 setgray 0 0.5 radius 1 add 0 360 arc closepath fill
  67.     %% Draw the control portion of Circular Slider
  68.     0.5 nxsetgray newpath 0 0 moveto
  69.     0 0.5 radius 90 90 angle sub arcn closepath fill
  70.     %% stroke out an outline
  71. %    0 setgray 2 setlinewidth 0.5 0.5 radius 1 add 0 360 arc
  72. %    matrix defaultmatrix setmatrix    %% create an empty 6x6 element unit matrix
  73.         %% replace the currently created matrix with the default matrix for
  74.         %% the device then sets up that matrix as the CTM.  This is done so
  75.         %% the stroked lines don't get wider because of the scaling
  76.     stroke
  77.     grestore
  78. endps
  79.  
  80. defineps MiscCSPieChartDisabled(float center_x; float center_y; float radius; float height; float width; float angle)
  81.     gsave
  82.     center_x center_y translate        %% translate to the center of the circle
  83.     %% if height is greater than the width then scale the y by height / width
  84.     height width gt { 1 height width div scale } if
  85.     %% if height is less than the width then scale the x by width / height
  86.     height width lt { width height div 1 scale } if
  87.     %% Draw the background of the Circular Slider
  88.     newpath 0.666 setgray 0.5 0.5 radius 1 add 0 360 arc closepath fill
  89.     %% Draw the control portion of Circular Slider
  90.     0.333 setgray newpath 0 0 moveto
  91.     0.5 0.5 radius 90 90 angle sub arcn    closepath fill
  92.     %% stroke out an outline
  93.     0 setgray 0.5 setlinewidth
  94.     newpath 0.5 0.5 radius 1 add 0 360 arc closepath
  95.     matrix defaultmatrix setmatrix    %% create an empty 6x6 element unit matrix
  96.         %% replace the currently created matrix with the default matrix for
  97.         %% the device then sets up that matrix as the CTM.  This is done so
  98.         %% the stroked lines don't get wider because of the scaling
  99.     stroke
  100.     grestore
  101. endps
  102.  
  103. defineps MiscCSControlKnob(float center_x; float center_y; float radius; float height; float width; float angle)
  104.     gsave
  105.     center_x center_y translate        %% translate to the center of the circle
  106.     %% if height is greater than the width then scale the y by height / width
  107.     height width gt { 1 height width div scale } if
  108.     %% if height is less than the width then scale the x by width / height
  109.     height width lt { width height div 1 scale } if
  110.     %% Draw the Control Portion of the Circular Slider2
  111.     newpath 0.6666 nxsetgray 0.5 0.5 radius 1 add 0 360 arc    closepath fill
  112.     %% Draw the Knob
  113.     /rs radius radius 8 mul 100 div sub 2 sub def
  114.     rs angle cos mul 2 sub % xpos
  115.     rs angle sin mul 2 sub % ypos
  116.     translate 6 6 2 [1 0 0 -1 0 6] <9020455016a01af01bf09be0> image
  117.     grestore
  118. endps
  119.  
  120. defineps MiscCSControlKnobDisabled(float center_x; float center_y; float radius; float height; float width)
  121.     gsave
  122.     center_x center_y translate %% translate to the center of circle
  123.     %% if height is greater than the width then scale the y by height / width
  124.     height width gt { 1 height width div scale } if
  125.     %% if height is less than the width then scale the x by width / height
  126.     height width lt { width height div 1 scale } if
  127.     %% Draw the Control Portion of the Circular Slider2
  128.     newpath 0.6666 nxsetgray 0.5 0.5 radius 1 add 0 360 arc closepath fill
  129.     grestore
  130. endps
  131.  
  132. defineps MiscCSControlDial(float center_x; float center_y; float radius; float height; float width; float angle; float grayLevel)
  133.     gsave
  134.     center_x center_y translate %% translate to the center of circle
  135.     %% if height is greater than the width then scale the y by height / width
  136.     height width gt { 1 height width div scale } if
  137.     %% if height is less than the width then scale the x by width / height
  138.     height width lt { width height div 1 scale } if
  139.     %% Draw the Control Portion of the Circular Slider2
  140.     newpath 0.6666 nxsetgray 0.5 0.5 radius 1 add 0 360 arc closepath fill
  141.     %% Draw the "Knob" (line segment) 1/3 of way from center to outside
  142.     grayLevel setgray radius 25 div setlinewidth
  143.     /r2 radius 3 div def /ac angle cos def /as angle sin def
  144.     radius ac mul radius as mul moveto r2 ac mul r2 as mul lineto stroke
  145.     grestore
  146. endps
  147.