wnk@uxc.cso.uiuc.edu (05/03/90)
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 set and edit your startup.ps to remove the offending lines. Now, I've tested this same code with psview and printed it on a postscript printer, and it works fine there. I also discovered how to have psview draw to the background instead of its window, which is what the code at the end of the note does. However, when I put it in my startup.ps it bombs. Could anyone give a novice some insight as to what he's doing wrong? Any help would be greatly appreciated. ----------------------------------------------------------------------------- %! % "Smiley" /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 framebuffer setcanvas 0 0.392 1 setrgbcolor % set background color clippath fill % fill background DrawSmile grestore } def PaintRoot showpage %EndOfFile ---------- Walter Kreiling wnk@aquifer.las.uiuc.edu
msc@ramoth.esd.sgi.com (Mark Callow) (05/09/90)
In article <209000001@uxc.cso.uiuc.edu>, wnk@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@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."