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

  1. %% melt.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 adds some MUCH needed functionality to the NeXT every other
  11. %% windowing system has a similar program, why not us?
  12. %%
  13. %% This melts the screen.  The central region flows down towards the
  14. %% bottom, etc.
  15.  
  16. %% This file may be installed so that the Scene application will bring it up
  17. %% under the Movies menu.  To do this, create a directory within the
  18. %% /NextLibrary/Images/Scene_movies directory named melt.movie.  Inside this
  19. %% directory, place this file, with the name melt.script.ps.  Then, run
  20. %% Scene, and there you are.  This really belongs in the /LocalLibrary
  21. %% directory, but unfortunately, Scene will not find it there.  Sad, eh?
  22.  
  23. %% This code is freely released into the public domain.  You may cut/paste,
  24. %% slash, rearrange, remove comments, and otherwise mutilate this code
  25. %% with no fear of reprisal from myself.  So, go ahead!  I want to see more
  26. %% screen hacks, people!
  27.  
  28. %% scott
  29.  
  30. %% Grab the Workspace and draw it in the passed window.
  31. /getWorkspace    % window
  32. {
  33.   gstate /dest exch def
  34.   /tempwin 0 0 1120 832 Nonretained window def
  35.   tempwin windowdeviceround
  36.   /tgs gstate def
  37.  
  38.   false tempwin setautofill
  39.   Above 0 currentwindow orderwindow
  40.  
  41.   dest setgstate 0 0 1120 832 tgs 0 0 Copy composite
  42.   tempwin termwindow
  43. } def
  44.  
  45. %% Move a region of the current gstate.
  46. /shift            %% x y w h dx dy
  47. {
  48.   4 index add
  49.   exch 5 index add
  50.   exch
  51.   gstate
  52.   3 1 roll
  53.   Copy composite
  54. } def
  55.  
  56. %% Return after mouseclick accepted.
  57. /waitmouse
  58. {
  59.   { buttondown {exit} if} loop
  60.   { stilldown not {exit} if} loop
  61. } def
  62.  
  63. %% return a random number between the 0 and the integer passed -1.
  64. %% (ie, 100 rand returns  from the range 0..99).
  65. /random
  66. {
  67.   rand exch mod
  68. } def
  69.  
  70. gsave
  71.   %% get a window the size of the Workspace.
  72.   /win 0 0 1120 832 Buffered window def
  73.   win windowdeviceround
  74.  
  75.   currentwindow getWorkspace
  76.  
  77.   %% Move the psuedo-Workspace to the front.
  78.   Above 0 win orderwindow
  79.  
  80.   %% How fast to drop.  Not really needed, now.
  81.   /dropby 1 def
  82.   
  83.   0.0 setgray                %% leave behind Black
  84.     {
  85.       /width 1100 random 20 add def    %% get a width from 20..1119
  86.       /height 416 random 416 add def    %% drop at least half the screen.
  87.       /x 1120 width add random width sub def
  88.       x 0 lt { width x add /x 0 def} if    %% constrain x to screen.
  89.       /drop dropby random 1 add def    %% how much to drop?
  90.       x 832 height sub width height 0 drop neg shift    %% move it.
  91.       x 832 drop sub width drop rectfill    %% erase old.
  92.       flushgraphics
  93.       buttondown {exit} if        %% get out of here if buttondown
  94.     }
  95.   loop
  96.   waitmouse                %% wait for that buttondown.
  97.  
  98.   win termwindow            %% get rid of the window.
  99. grestore
  100.  
  101.