Discussion:
Little idioms and conventions
(too old to reply)
luser droog
2023-04-05 17:58:40 UTC
Permalink
One little convention I've used a lot in PostScript code is to
use the variables /x /y /X /Y to hold the bounds. This can
look a little weird if you're used to using /x /y to hold some
notion of a "current point", but if you're using the `currentpoint`
for that then that frees up /x /y for this usage.

0 0 612 792 {Y X y x}{exch def}forall
/+= {exch 1 index load add store} def
/margin {dup neg /Y += dup neg /X += dup /y += /x +=} def

Then you can set text down the page by first subtracting the
linewidth or leading from Y and then showing a line at x,Y.


Another convention I've used for small illustrations is to
follow the model of a glyph in a font. Encapsulate the
drawing in a procedure which expects the currentpoint
to be the lower left on entry and leaves the currentpoint
at the lower right on exit. This makes it easy to place
several of them in a row.

[I thought I'd come up with more while typing these 2, but I
only had these 2 coming in.]
jdaw1
2023-07-04 22:01:33 UTC
Permalink
Post by luser droog
One little convention I've used a lot in PostScript code is to
use the variables /x /y /X /Y to hold the bounds.
My convention is L R B T for bounds left tight bottom top.

Loading...