home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1995 August / NEBULA.bin / Graphics / PostScript / PSHacks / jitterbug.ps < prev    next >
Encoding:
Text File  |  1993-01-23  |  2.7 KB  |  100 lines

  1. %% jitterbug.ps
  2. %%
  3. %% Written April 29, 1990,
  4. %% Scott Hess
  5. %% NeXT Campus Consultant
  6. %% Gustavus Adolphus College
  7. %% St. Peter, Mn    56082
  8. %% scott@gacvax1.bitnet
  9. %%
  10. %% This program is heavily based on melt.ps.  It doesn't melt the screen
  11. %% though, it just makes it jump around.
  12.  
  13. %% This file may be installed so that the Scene application will bring it up
  14. %% under the Movies menu.  To do this, create a directory within the
  15. %% /NextLibrary/Images/Scene_movies directory named jitterbug.movie.  Inside this
  16. %% directory, place this file, with the name jitterbug.script.ps.  Then, run
  17. %% Scene, and there you are.  This really belongs in the /LocalLibrary
  18. %% directory, but unfortunately, Scene will not find it there.  Sad, eh?
  19.  
  20. %% This code is freely released into the public domain.  You may cut/paste,
  21. %% slash, rearrange, remove comments, and otherwise mutilate this code
  22. %% with no fear of reprisal from myself.  So, go ahead!  I want to see more
  23. %% screen hacks, people!
  24.  
  25. %% scott
  26.  
  27. %% Grab the Workspace and draw it in the passed window.
  28. /getWorkspace    % window
  29. {
  30.   gstate /dest exch def
  31.   /tempwin 0 0 1120 832 Nonretained window def
  32.   tempwin windowdeviceround
  33.   /tgs gstate def
  34.  
  35.   false tempwin setautofill
  36.   Above 0 currentwindow orderwindow
  37.  
  38.   dest setgstate 0 0 1120 832 tgs 0 0 Copy composite
  39.   tempwin termwindow
  40. } def
  41.  
  42. %% Move a region of the current gstate.
  43. /shift            %% x y w h dx dy
  44. {
  45.   4 index add
  46.   exch 5 index add
  47.   exch
  48.   gstate
  49.   3 1 roll
  50.   Copy composite
  51. } def
  52.  
  53. %% Return after mouseclick accepted.
  54. /waitmouse
  55. {
  56.   { buttondown {exit} if} loop
  57.   { stilldown not {exit} if} loop
  58. } def
  59.  
  60. %% return a random number between the 0 and the integer passed -1.
  61. %% (ie, 100 rand returns  from the range 0..99).
  62. /random
  63. {
  64.   rand exch mod
  65. } def
  66.  
  67. gsave
  68.   %% get a window the size of the Workspace.
  69.   /win 0 0 1120 832 Buffered window def
  70.   win windowdeviceround
  71.  
  72.   currentwindow getWorkspace
  73.  
  74.   %% Move the psuedo-Workspace to the front.
  75.   Above 0 win orderwindow
  76.  
  77.   %% How fast to drop.  Not really needed, now.
  78.   /moveby 3 def
  79.   
  80.   0.0 setgray                %% leave behind Black
  81.     {
  82.       /width 1100 random 20 add def    %% get a width from 20..1119
  83.       /height 812 random 20 add def    %% and a width from 20..831.
  84.       /x 1120 width add random width sub def
  85.       x 0 lt { width x add /x 0 def} if    %% constrain x to screen.
  86.       /y 832 height add random height sub def
  87.       y 0 lt { height y add /y 0 def} if %% constrain y to screen.
  88.       /dx moveby random moveby 3 div sub def    %% how much to move?
  89.       /dy moveby random moveby 3 div sub def
  90.       x y width height dx dy shift        %% move it.
  91.       flushgraphics
  92.       buttondown {exit} if        %% get out of here if buttondown
  93.     }
  94.   loop
  95.   waitmouse                %% wait for that buttondown.
  96.  
  97.   win termwindow            %% get rid of the window.
  98. grestore
  99.  
  100.