[comp.windows.open-look] Exciting wild coloured squiggly backgrounds for openwin!!!

lee@sq.sq.com (Liam R. E. Quin) (12/06/90)

(this is for openwindows 2.0, hence the cross-post).

Some PostScript to play with!  How can you wait?!?

I defined my own PaintRoot procedure in NeWS/paintroot.ps, which generates
random squiggly coloured shapes on the root window, which look interesting.

Two notes:
1) you get less work done because people come and say `wow' and ask you to
   generate more of them and whether you can print them, and...

2) after a (fairly long) while it stops working and you get dictfull messages.
   Doing psh < paintroot.ps makes it work again though.  It's pretty enough
   that I don't mind!

3) on a sun 4/110 it can take a second or two to repaint the screen, but on
   a sparcstation2 it would probably finish before it had started...


Using Liam's Root Window Thingy:

The following entry in .openwin-menu just under "Properties..." will add a
button to make a new random root window on the Workspace menu:

"root..."                       POSTSCRIPT LiamDict begin LiamNewRoot end

Or you can experiment by saying
	echo LiamDict begin LiamNewRoot end | psh
which will draw a pattern for you.


Here are the changes:
    If you don't already have a $HOME/NeWS directory, make one and copy
    /usr/openwin/etc/NeWS/init.ps into it.  Change the line that says
      UserProfile /UsePaintRoot? false ?get setpaintroot
to
      true setpaintroot % call LiamPaintroot to repaint the root window

Copy /usr/openwin/etc/NeWS/paintroot.ps to your NeWS directory, and apply
the following patch.

Then run "openwin", have lunch while it starts up :-(, and come back and
enjoy the pretty pictures when you click on "root..."!

Lee


*** Original/paintroot.ps	Wed Jun 27 15:17:47 1990
--- paintroot.ps	Wed Dec  5 17:14:53 1990
***************
*** 11,16 ****
--- 11,125 ----
  systemdict 
  begin
  
+ % define random root stuff...
+ /LiamDict 40 dict def
+ LiamDict begin
+ 
+ % the numbers are to help me keep track of the dictionary size.
+ 
+ %1
+ /LiamSeed rand def
+ 
+ %2
+ /coloralloc {       % color => -
+     dup currentcanvas /Colormap get % color color cmap
+     exch createcolorsegment         % color cmapentry
+     def
+ } def
+ 
+ %3
+ /Setcolor {
+     dup coloralloc setcolor
+ } def
+ 
+ 
+ %4 
+ /mAx 0 def
+ %5
+ /mIn 0 def
+ 
+ %6
+ /rAndom { % min max random
+       /mAx exch 1 add def
+       /mIn exch def
+       random  mAx mIn sub  mul  mIn add  cvi
+ } def
+ 
+ %7
+ % exp min max  expRandom  non-linear random number
+ % the larger exp is, the closer to min the returned number.  Min and Max
+ % ought to be +ve, I think.
+ /exprAndom {
+       /mAx exch 1 add def
+       /mIn exch def
+       /E 1 def
+       { /E E random mul def } repeat E  mAx mIn sub  mul  mIn add  cvi
+ } def
+ 
+ % Magic numbers are miny maxy (and minx, maxx, of course)
+ /nexty { 0 12 72 mul rAndom} def %8 %% Assumes 12x16 inch display, approx
+ /nextx { 0 16 72 mul rAndom} def %9
+ 
+ /LiamRandCurve { %10
+   newpath
+   nextx nexty moveto
+ 
+   3 2 200 exprAndom {  % from 2 to 200, most likely lower...
+     nextx nexty
+     nextx nexty
+     nextx nexty
+     curveto
+   } repeat
+ 
+   closepath
+ 
+   gsave
+     random random random rgbcolor Setcolor
+     eofill
+   grestore
+ 
+   random 0.5 gt {
+     % random colour for the stroke
+     random random random rgbcolor Setcolor
+     % very occasionally, use a much thicker line...
+     gsave
+      random  5 { random mul } repeat
+      300 mul dup /LiamBorder exch def setlinewidth % 11
+      stroke
+     grestore
+     gsave
+       /LiamBorder2 random random mul random mul random mul 100 mul def % 12
+       LiamBorder 1 sub LiamBorder2 gt LiamBorder2 0.001 gt and {
+ 	LiamBorder2 setlinewidth
+ 	random random random hsbcolor Setcolor
+ 	stroke
+       } if
+     grestore
+   } if
+ } def
+ 
+ /LiamNewRoot { % 11
+     random pop % miss one...
+     /LiamRandSeed rand def
+     random random random rgbcolor dup Setcolor
+     systemdict begin
+ 	/RootColor exch def
+     end
+     LiamPaintRoot
+ } def
+ 
+ /LiamPaintRoot { % 12
+     LiamRandSeed srand
+     framebuffer setcanvas
+     RootColor setcolor
+     clippath fill
+     12 1 5 exprAndom { % almost certainly only once
+ 	LiamRandCurve
+     } repeat
+ } def
+ 
+ end % end of Liam's dictionary setup
+ 
      %
      % Need to make this a procedure for multi-screen to work.
      %
***************
*** 27,34 ****
      /PaintRoot {
  	gsave
  	    framebuffer setcanvas
! 	    RootColor setcolor
! 	    clippath fill
  	grestore
      } def
  
--- 136,146 ----
      /PaintRoot {
  	gsave
  	    framebuffer setcanvas
! 	    % RootColor setcolor
! 	    % clippath fill
! 	    LiamDict begin
! 		LiamPaintRoot
! 	    end
  	grestore
      } def
  


End of patch.

Lee

-- 
Liam R. E. Quin,  lee@sq.com, SoftQuad Inc., Toronto, +1 (416) 963-8337