🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.postscript
Article #1578

Re: Drawing lots of triangles

#1578
From: rsilverman
Date: Sat, 20 Jan 1990 23:55
46 lines
2126 bytes
In article <9561@batcomputer.tn.cornell.edu>, eric@batcomputer.tn.cornell.edu (Eric Fielding) writes:
asks about improving the PostScript output of a program.

Eric,

Based on the sample you gave, I think there are a number of things you could
do:

1)  Remove the initgraphics and erasepage from the top of the code.  They will 
prevent your description from being easily operated on as a unit for inclusion 
in another page.

2)  Instead of sequences like "/SK {stroke} def", use "/SK /stroke load def". 
This avoids the overhead of both the procedure call and name lookup in the
former.

3)  A typical sequence painting a triangle is

>  NP 8761 6576 MT
> 8781 6584 LT
> 8782 6574 LT
> 8761 6576 LT
> CP GS 99 SG FL GR
> NP 8761 6576 MT   %...beginning of next triangle

This is inefficient in a number of ways.  The third lineto instruction is
unnecessary; closepath does it for you.  The filling operation is surrounded by
a gsave/grestore pair, for no apparent reason, as the path is destroyed by
newpath immediately afterward.  Get rid of the GS/GR, and then you can remove
the NP as well; the fill operator clears the current path for you.  Thus:

8761 6576 MT
8781 6584 LT
8782 6574 LT
CP 99 SG FL

is all you need for each triangle.  Note that if the triangles were being
stroked as well as filled, then the gsave/grestore would be appropriate.

Another thing you might consider: if the picture contains many instances of
exactly the same triangle in the same size and orientation, in black or white,
the you could create a font containing the frequently used triangles as
characters, and take advantage of the font cache for a tremendous speedup. 
Hope this helps,

Richard Silverman
Technical Details
Message-ID: <5774@eagle.wesleyan.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!think!yale!eagle!rsilverman
References: <9561@batcomputer.tn.cornell.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!think!yale!eagle!rsilverman
From: rsilverman@eagle.wesleyan.edu
Newsgroups: comp.lang.postscript
Subject: Re: Drawing lots of triangles
Message-ID: <5774@eagle.wesleyan.edu>
Date: 20 Jan 90 23:55:51 GMT
References: <9561@batcomputer.tn.cornell.edu>
Distribution: na
Lines: 46