Using PostScript ensures that your graphs are scalable, portable
and of very high typesetting quality.
In addition, if you use PostScript for creating animations, you
can also easily embed the resulting graphs in other documents.
There are some examples of PostScript animations available from
this site: See N-Queens,
Connect 4 and
Knight's Tour for more information.
This page explains the general principle underlying these
animations.
First, think about the mini-language that you want to use
to describe the small individual steps of your animation.
For example, in many scheduling tasks, you want to show the
placement of individual items on a common roster or time-table. In
such examples, you first define custom PostScript procedures that
let you:
- draw an item at a specific position.
- clear a position.
You want to think in abstract positions, not in pixel
positions. Typically, the abstract positions will be indicated by
one or two natural numbers that denote a particular time slot or
board field.
Coordinates specified in a PostScript program refer to locations
within a coordinate system that always bears the same
relationship to the current page, regardless of the output
device on which printing or displaying will be done. This
coordinate system is called user space.
For example, to clear a square at an abstract position indicated
by two coordinates on the operand stack, you can define:
/cs { gsave translate 1 setgray 0 0 1 1 rectfill grestore } bind def
and use it like:
5 7 cs
in the code that emits animation steps.