home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1995 August / NEBULA.mdf / Graphics / PostScript / hop / hop.script.ps < prev    next >
Encoding:
Text File  |  1993-01-23  |  2.9 KB  |  108 lines

  1. % $Source: /usr/jm/source/ps/RCS/hop.ps,v $
  2. %   Copyright (c) 1991 by Jeffrey A. Marshall
  3. % $Revision: 1.6 $
  4. % $Date: 91/10/06 03:27:16 $
  5. %
  6. % hop.ps - real plan fractal movie for Scene
  7. %   This is a translated version of hopalong.c included
  8. % with the source code to xlock (X11 terminal locker) by
  9. % Patrick Naughton and Sun Microsystems, Inc.
  10. %
  11. % Permission to Use and Abuse as desired, except for commercial purposes.
  12. % No warranty of any kind.
  13. %  
  14. % Comments, Additions and Gripes are welcome:
  15. %  jm@baks.bell-atl.com
  16. %  76060,2302 - compuserve
  17. %  Jeffrey A. Marshall
  18. %  4 Bates Road
  19. %  Morgantown, WV 26505
  20.  
  21. % parameters 
  22. /timeout 30.0 def       % # of seconds between hops
  23. /batch_count 100 def    % # of points done at once
  24. /step 1 256 div def     % 256 <-> number of colors
  25. /width 1120 def         % width of window
  26. /height 832 def         % height of window
  27.  
  28. /currentTime {  % - currentTime -> seconds_mod_10000
  29.     currentrusage 
  30.     pop pop pop pop pop pop pop cvi
  31. } def
  32.  
  33. /initHop {  % initialize variables for a hop
  34.             % bool initHop -> -
  35.  
  36.     {   currentTime srand % has to be a better way
  37.         /centerx width 2 div cvi def
  38.         /centery height 2 div cvi def
  39.     } if
  40.  
  41.     /range centerx centerx mul  % centerx * centerx
  42.            centery centery mul  % centery * centery
  43.             add sqrt 10         % tmp 10.0
  44.             rand 10 mod         % tmp 10.0 (random() % 10)
  45.             add div def
  46.  
  47.     /pix 1.0 def    % current `color'
  48.     /inc rand 2147483647 div 400 mul 200 sub cvi def
  49.     /a rand 2147483647 div range mul range 2 div sub cvi def
  50.     /b rand 2147483647 div range mul range 2 div sub cvi def
  51.     /c rand 2147483647 div range mul range 2 div sub cvi def
  52.  
  53.     rand 2 mod 0 eq { /c 0 def } if
  54.  
  55.     /i 0 def
  56.     /j 0 def
  57.  
  58.     0 setgray
  59.     0 0 width height rectfill
  60.     /timeNow currentTime def
  61. } bind def
  62.  
  63. /hopDisplay {   % do a round of hop'n
  64.                 % - hopDisplay -> %
  65.     /inc inc 1 add def
  66.  
  67.     1.0 pix sub pix 1 sethsbcolor   % (1.0 - pix) pix 1 sethsbcolor
  68.     /pix pix step sub def           % increment `color'
  69.     pix 0 le { /pix 1.0 def } if
  70.  
  71.     newpath % want this inside of loop, if batch_count is very large
  72.     batch_count {
  73.         /oldj j def
  74.         /j a i sub def
  75.         /tmp i inc add b mul c sub abs sqrt def
  76.         /i oldj tmp i 0 le { add } { sub } ifelse def
  77.         centerx i j add add cvi
  78.         centery i j sub sub cvi
  79.         % newpath
  80.         moveto currentpoint lineto  % putpixel
  81.         % stroke
  82.     } repeat
  83.     stroke  % look up
  84. } bind def
  85.  
  86. % an evil window
  87. /deskWin666 0 0 width height Nonretained window def 
  88.  
  89. deskWin666 windowdeviceround
  90. 200 currentwindow setwindowlevel
  91. Above 0 currentwindow orderwindow
  92.  
  93. % an evil loop
  94. true initHop
  95. {
  96.     buttondown { exit } if
  97.     hopDisplay
  98.     currentTime timeNow sub timeout ge { false initHop } if
  99. } loop { buttondown not { exit } if } loop
  100.  
  101. Out 0 deskWin666 orderwindow
  102. deskWin666 termwindow
  103.  
  104.  
  105. %% Local Variables:
  106. %% compile-command: "pft -s -f /usr/jm/source/ps/hop.ps"
  107. %% End:
  108.