a postscript/background question

Mark Callow msc at ramoth.esd.sgi.com
Wed May 9 10:32:20 AEST 1990


In article <209000001 at uxc.cso.uiuc.edu>, wnk at uxc.cso.uiuc.edu writes:
|> 
|> 
|> 
|> 	I have started playing with postscript lately, and I figured
|> the best way to test out what I've learned is to make nifty backgrounds
|> for my 4D/20TG workstation.  Well the first thing I tried was to draw
|> a smiley face. (The code is included at the end of the article).  What
|> I found was that you can't set the line width, or do partial circles.
|> If you try, the login process dies, and you have to login with NOGRAPHICS

Here is the corrected code.  I have your smiley face background up as I'm
writing this.  The problem is that wide lines are implemented in PostScript
by code in the file stroke.ps which isn't loaded by init.ps until after it
has loaded startup.ps and called PaintRoot.

Also you don't need the "framebuffer setcanvas".  When PaintRoot is called
the current canvas has been set correctly.  Lastly you don't need the
call to showpage.  That's only needed on printers.

Whenever you get PostScript errors (window's mysteriously disappear etc.)
the NeWS server puts messages into the file /usr/adm/SYSLOG indicating
the problem.  Remember to look there in the future.  That is how I found
out what was wrong.
======================= startup.ps with smiley face ==========================
%!
% "Smiley"

(NeWS/stroke.ps) LoadFile pop

/doCircle			% draw a filled circle
 { 0 360 arc fill } def

/doArc				% draw an arc
 { 200 340 arc stroke } def

/DrawSmile {
   1.0 1.0 0 setrgbcolor	% set color to yellow
   500 400 300 doCircle		% draw face
   0 0 0 setrgbcolor		% set color to black
   400 520 25 doCircle		% draw eyes
   600 520 25 doCircle
   4 setlinewidth		% set line width
   500 350 150 doArc		% draw mouth as 140 degree arc
} bind def

/PaintRoot {
    gsave
    0 0.392 1 setrgbcolor	% set background color
    clippath fill		% fill background
    DrawSmile
    grestore
} def

%EndOfFile
--
>From the TARDIS of Mark Callow
msc at ramoth.sgi.com, ...{ames,decwrl}!sgi!msc
"There is much virtue in a window.  It is to a human being as a frame is to
a painting, as a proscenium to a play.  It strongly defines its content."



More information about the Comp.sys.sgi mailing list