home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1995 August / NEBULA.bin / SourceCode / Palettes / CircularSlider / CircularSlider.subproj / wraps.psw < prev   
Encoding:
Text File  |  1993-09-06  |  6.3 KB  |  213 lines

  1. /*
  2.  *    Filename: wraps.psw
  3.  *      Created : Sat Aug 24 21:25:44 1991
  4.  *    Author  : Vince DeMarco <vince@whatnxt.cuc.ab.ca>
  5.  *    LastEditDate Was "Mon Sep  6 16:32:45 1993"
  6.  */
  7.  
  8. defineps PSDrawBackground(float height; float width;
  9.                        float center_x; float center_y; float radius)
  10.  
  11.  
  12.      gsave                          %% save the current graphics state
  13.  
  14.      center_x
  15.      center_y translate             %% translate the current point to the center of the
  16.                                     %% circle
  17.  
  18.      height width gt {              %% if the height is greater than the width then
  19.          1 height width div scale   %% scale the y by height / width
  20.      } if
  21.  
  22.      height width lt {              %% if height is less than the width then scale
  23.          width height div 1 scale   %% the x by width / height
  24.      } if
  25.  
  26.      %%%%%% Draw the Raised Background
  27.  
  28.      newpath
  29.      1.0 nxsetgray
  30.      -1.0 1.5 radius 2 add 0 360 arc
  31.      closepath
  32.      fill
  33.  
  34.      newpath
  35.      0.0 nxsetgray
  36.      1.5 -1 radius 2 add 225 45 arc
  37.      closepath
  38.      fill
  39.  
  40.      newpath
  41.      0.3333 nxsetgray
  42.      1.5 -0.25 radius 1 add 0 360 arc
  43.      closepath
  44.      fill
  45.  
  46.      grestore
  47.  
  48. endps
  49.  
  50.  
  51. defineps PSPieChart(float height; float width;
  52.                     float center_x; float center_y; float radius; float angle)
  53.  
  54.      gsave                          %% save the current graphics state
  55.  
  56.      center_x
  57.      center_y translate             %% translate the current point to the center of the
  58.                                     %% circle
  59.  
  60.      height width gt {              %% if the height is greater than the width then
  61.          1 height width div scale   %% scale the y by height / width
  62.      } if
  63.  
  64.      height width lt {              %% if height is less than the width then scale
  65.          width height div 1 scale   %% the x by width / height
  66.      } if
  67.  
  68.      %%%%%% Draw the background of the Circular Slider
  69.      newpath
  70.      0.33333 setgray
  71.      0 0.5 radius 1 add 0 360 arc
  72.      closepath
  73.      fill
  74.  
  75.      %%%%%% Draw the control portion of Circular Slider
  76.      0.5 nxsetgray
  77.      newpath
  78.      center_x width div center_y height div moveto
  79.      0 0.5 radius 90 angle 90 sub neg arcn
  80.      closepath
  81.      fill
  82.  
  83.      %%%%%% stroke out an outline
  84. %     0 nxsetgray
  85. %     2 setlinewidth
  86. %     0.5 0.5 radius 1 add 0 360 arc
  87. %     matrix defaultmatrix setmatrix     %% create an empty 6x6 element unit matrix
  88.                                         %% replace the currently created matrix with the
  89.                                         %% default matrix for the device then sets up that
  90.                                         %% matrix as the CTM
  91.                                         %%
  92.                                         %% This is done so the stroked lines don't get
  93.                                         %% wider because of the scaling
  94.      stroke
  95.  
  96.      grestore
  97.  
  98. endps
  99.  
  100. defineps PSPieChartDisabled(float height; float width;
  101.                             float center_x; float center_y; float radius; float angle)
  102.  
  103.      gsave                          %% save the current graphics state
  104.  
  105.      center_x
  106.      center_y translate             %% translate the current point to the center of the
  107.                                     %% circle
  108.  
  109.      height width gt {              %% if the height is greater than the width then
  110.          1 height width div scale   %% scale the y by height / width
  111.      } if
  112.  
  113.      height width lt {              %% if height is less than the width then scale
  114.          width height div 1 scale   %% the x by width / height
  115.      } if
  116.  
  117.      %%%%%% Draw the background of the Circular Slider
  118.      newpath
  119.      0.33333 nxsetgray
  120.      0.5 0.5 radius 1 add 0 360 arc
  121.      closepath
  122.      fill
  123.  
  124.      %%%%%% Draw the control portion of Circular Slider
  125.      0.66666 nxsetgray
  126.      newpath
  127.      center_x width div center_y height div moveto
  128.      0.5 0.5 radius 90 angle 90 sub neg arcn
  129.      closepath
  130.      fill
  131.  
  132.      %%%%%% stroke out an outline
  133.      0 nxsetgray
  134.      0.5 setlinewidth
  135.  
  136.      newpath
  137.      0.5 0.5 radius 1 add 0 360 arc
  138.      closepath
  139.      matrix defaultmatrix setmatrix     %% create an empty 6x6 element unit matrix
  140.                                         %% replace the currently created matrix with the
  141.                                         %% default matrix for the device then sets up that
  142.                                         %% matrix as the CTM
  143.                                         %%
  144.                                         %% This is done so the stroked lines don't get
  145.                                         %% wider because of the scaling
  146.      stroke
  147.  
  148.      grestore
  149.  
  150. endps
  151.  
  152.  
  153. defineps PSControlKnob(float height; float width;
  154.                        float center_x; float center_y; float radius; float xpos; float ypos)
  155.  
  156.      gsave                          %% save the current graphics state
  157.  
  158.      center_x
  159.      center_y translate             %% translate the current point to the center of the
  160.                                     %% circle
  161.  
  162.      height width gt {              %% if the height is greater than the width then
  163.          1 height width div scale   %% scale the y by height / width
  164.      } if
  165.  
  166.      height width lt {              %% if height is less than the width then scale
  167.          width height div 1 scale   %% the x by width / height
  168.      } if
  169.  
  170.      %%%%%% Draw the Control Portion of the Circular Slider2
  171.      newpath
  172.      0.6666 nxsetgray
  173.      0.5 0.5 radius 1 add 0 360 arc
  174.      closepath
  175.      fill
  176.  
  177.      %%%%%% Draw the Knob
  178.      xpos 2 sub ypos 2 sub translate
  179.      6 6 2 [1 0 0 -1 0 6] <9020455016a01af01bf09be0> image
  180.  
  181.      grestore
  182.  
  183. endps
  184.  
  185.  
  186. defineps PSControlKnobDisabled(float height; float width;
  187.                                float center_x; float center_y; float radius)
  188.  
  189.      gsave                          %% save the current graphics state
  190.  
  191.      center_x
  192.      center_y translate             %% translate the current point to the center of the
  193.                                     %% circle
  194.  
  195.      height width gt {              %% if the height is greater than the width then
  196.          1 height width div scale   %% scale the y by height / width
  197.      } if
  198.  
  199.      height width lt {              %% if height is less than the width then scale
  200.          width height div 1 scale   %% the x by width / height
  201.      } if
  202.  
  203.      %%%%%% Draw the Control Portion of the Circular Slider2
  204.      newpath
  205.      0.6666 nxsetgray
  206.      0.5 0.5 radius 1 add 0 360 arc
  207.      closepath
  208.      fill
  209.  
  210.      grestore
  211.  
  212. endps
  213.