psrecord.icn: Procedures for PostScript record of window

procedure PSEnable:        enable PostScript recording
procedure PSSnap:          take PostScript snapshot
procedure PSRaw:           output raw PostScript
procedure PSDisable:       disable PostScript recording
procedure PSDone:          terminate PostScript recording

link psrecord
June 16, 2010; Gregg M. Townsend
Contributors: Stephen B. Wampler and Ralph E. Griswold
Requires: Version 9 graphics
This file is in the public domain.

These procedures intercept graphics calls in order to produce
a PostScript copy of what is drawn.  The record is decidedly
imperfect.
____________________________________________________________

   These procedures produce a PostScript record of the screen display
of an Icon program.  The technique used is to intercept calls to
graphics functions and write PostScript before calling the built-in
versions.

   Because the X emulation is imperfect, psrecord works best for
programs designed with it in mind.  Not all function calls are
intercepted; some such as CopyArea cannot be handled at all.  The
list of functions is in the internal routine PS_swap().  It is assumed
that there is only a single window and a single graphics context;
programs that switch among multiple graphics contexts will not be
recorded properly.

   PostScript recording is enabled by calling PSEnable(window, filename)
any time after after the window has been opened.  (The procedures in
"autopost.icn" may be used for this.)  Defaults for PSEnable are
&window and "xlog.ps".  At the end, PSDone() should be called to
properly terminate the file; when PSDone() is not called, the file is
still be legal but lacks the "showpage" command needed for printing.

   If the argument to PSDone is non-null, no showpage is written.
This is recommended for Encapsulated PostScript that is to be
placed in documents, since otherwise the bounding box resulting
from showpage may interfere with document layout.  showpage is, of
course, needed for PostScript that is to be printed stand-alone.

   Additional procedures provide more detailed control but must be used
with care.  PSDisable() and PSEnable() turn recording off and back on;
any graphics state changes during this time (such as changing the
foreground color) are lost.  PSSnap() inserts a "copypage" command in
the output; this prints a snapshot of the partially constructed page
without erasing it.  PSRaw() writes a line of PostScript to the output
file.

   PSStart(window, filename) is similar to PSEnable except that it
always starts a fresh output file each time it is called.

   The output file is legal Encapsulated PostScript unless PSSnap is
used; PSSnap renders the output nonconforming because by definition
an EPS file consists of a single page and does not contain a "copypage"
command.  It should be possible to postprocess such output to make a
set of legal EPS files.

   Some of the other limitations are as follows:
       Only a few font names are recognized, and scaling is inexact.
       Newlines in DrawString() calls are not interpreted.
       Output via write() or writes() is not recorded.
       The echoing of characters by read() or reads() is not recorded.
       DrawCurve output is approximated by straight line segments.
       Window resizing is ignored.
       Drawing arguments must be explicit; few defaults are supplied.

Source code | Program Library Page | Icon Home Page