[comp.windows.news] A Rose is a rose is a rose...

rbogen%dreams@Sun.COM (Richard Bogen) (09/16/89)

%This file creates a LiteWindow which has a rose curve draw into it.
%The menu enables the parameters to be changed giving a different curve
%
%Richard A. Bogen - Sun Microsystems, Inc. - 1989
%
systemdict /SliderItem known not {(NeWS/liteitem.ps) LoadFile pop} if
 
/c 0 def /num 13 def /den 5 def

/rose {matrix currentmatrix
       clippath pathbbox 2 div exch 2 div exch 
       2 copy translate c 1 add div exch c 1 add div exch scale pop pop
       0 c moveto 
       0 1 den 1 sub {360 mul 1 add
       dup 1 exch 360 add 
         {dup dup 
          num mul den div sin c add /p exch def
          sin p mul exch
          cos p mul lineto}
          for} currentpoint stroke pause moveto for 
      setmatrix} def

/win framebuffer /new DefaultWindow send def
/reshapefromuser win send
/can {ClientCanvas} win send def
/itemdict 10 dict begin
  /cslide ( Constant)  [1  100 c] /Left      
        {/c ItemValue 10 div store} can /new SliderItem send def
  100 300 200 0 /reshape cslide send
  
  /numslide ( Numerator)  [1  100 num] /Left      
        {/num ItemValue store} can /new SliderItem send def
  100 200 200 0 /reshape numslide send

  /denslide (Denominator)  [1  100 den] /Left      
        {/den ItemValue store} can /new SliderItem send def
  100 100  200 0 /reshape denslide send

  /done (REDRAW) {/paint win send} can /new ButtonItem send def
  10 10 0 0 /reshape done send
currentdict end def

/redraw {1 fillcanvas 0 setgray rose stroke} def
 
{/ClientMenu [(Change Parms) {itemdict paintitems}] /new DefaultMenu send def
 /DestroyClient {/unmap self send currentprocess killprocessgroup} def
 /PaintIcon {redraw} def /PaintClient {redraw} def
 /FrameLabel {(p = % + sin \(%/% * a\))[c num den] sprintf} def} win send

itemdict forkitems /map win send