[comp.windows.news] Fun window Zapper

jh@ist.CO.UK (Jeremy Huxtable) (06/07/89)

%! /usr/NeWS/bin/psh

% Interesting NeWS window zapper (NeWS1.1)
%
% Jeremy Huxtable
%
% Mon May 22 08:53:57 BST 1989

% A more interesting way of zapping your windows. If you 'psh' this file,
% then all windows which you zap from then on will be pushed off the screen
% by a small person rather than just boringly disappearing.

% Technical note:
% The little person is drawn directly onto the framebuffer rather than using
% a canvas. The area under it is then marked as damaged using 'extenddamage'
% and is redrawn automatically. Canvases? Who needs canvases anyway?

{
    /ThingWidth 16 def
    /ThingHeight 20 def
    /MoveDelta 15 def
    /Things [/man1 /man2 /man3 /man4 /man5] def

    /destroy {
	gsave
	    framebuffer setcanvas
	    0 setgray
	    clippath pathbbox pop 3 1 roll pop pop % fb_width
	    FrameX sub MoveDelta div 1 sub
	    1 1 3 -1 roll {
		Iconic? {
		    IconX ThingWidth sub 1 sub IconY moveto
		    Things IconX MoveDelta div cvi Things length mod get showicon
		    IconX MoveDelta add IconY move
		    IconX MoveDelta sub ThingWidth sub 1 sub IconY
		} {
		    FrameX ThingWidth sub 1 sub FrameY moveto
		    Things FrameX MoveDelta div cvi Things length mod get showicon
		    FrameX MoveDelta add FrameY move
		    FrameX MoveDelta sub ThingWidth sub 1 sub FrameY
		} ifelse
		ThingWidth ThingHeight rectpath extenddamage
		pause
	    } for
	grestore
	DestroyFrame DestroyClient
    } def

} DefaultWindow send