Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!ames!oliveb!sun!campfire!scout
From: scout@campfire.Sun.COM (David LaVallee)
Newsgroups: comp.windows.news
Subject: Re: Color PostScript screendump for NeWS
Summary: simple NeWS command to capture region
Message-ID: <69295@sun.uucp>
Date: 21 Sep 88 02:47:59 GMT
References: <620@cmx.npac.syr.edu> <35369@philabs.Philips.Com>
Sender: news@sun.uucp
Reply-To: scout@sun.UUCP (David LaVallee)
Organization: Sun Microsystems, Mountain View
Lines: 61

Here's a little cut and paste and sketch program that uses the file
/tmp/clip as its storage. NeWS stores the "clip" as a run-length
encoded sun raster file (B+W or Color).

I have used this program to clip stuff for B+W and color raster
printers, on a Sun with TRANSCRIPT software this is one way to
print the rasterfile to a LaserWriter:

/usr/lib/rasfilters/convert.2 /tmp/clip | pssun | lpr

--Scoutly

%%NeWS1.1
%%author:	David A. LaVallee
%%title:	paint2

[/x0 /y0 /x1 /y1 /x /y /win /can] {null def} forall
/win framebuffer /new DefaultWindow send def
/reshapefromuser win send
{   /ClientMenu [
        (cut)
    {
        framebuffer createoverlay setcanvas getwholerect waitprocess aload pop
        framebuffer setcanvas points2rect rectpath (/tmp/clip) writescreen
    }
        (paste)
    {
        can createoverlay setcanvas getwholerect waitprocess aload pop
        can setcanvas points2rect gsave 4 2 roll translate scale
        {(/tmp/clip) readcanvas imagecanvas} stopped {pop} if grestore
    }
    ] /new DefaultMenu send def
} win send
/map win send
/can win /ClientCanvas get def
can /Retained true put

/paintit {0 setgray x1 y1 moveto x y lineto stroke} def

/setxy {
	/x1 x store /y1 y store
	begin /x XLocation store /y YLocation store end
} def

/paintbrush {
10 dict begin
    currentcursorlocation /y exch store /x exch store
    /x0 x store /y0 y store
    /x1 x store /y1 y store
    paintit
    [   null {currentprocess killprocess} /UpTransition null eventmgrinterest
	MouseDragged {setxy paintit} null null eventmgrinterest
    ] forkeventmgr pop
end
} def

/PaintEventMgr [
        PointButton {
                can setcanvas paintbrush
        } /DownTransition can eventmgrinterest
] forkeventmgr def