This section describes a set of commands for creating soft paths as opposed to the commands of the previous section, which created hard paths. A soft path is a path that can still be “changed” or “molded.” Once you (or the PGF system) is satisfied with a soft path, it is turned into a hard path, which can be inserted into the resulting .pdf or .ps file.
Note that the commands described in this section are “high-level” in the sense that they are not implemented in driver files, but rather directly by the PGF-system layer. For this reason, the commands for creating soft paths do not start with \pgfsys@, but rather with \pgfsyssoftpath@. On the other hand, as a user you will never use these commands directly, so they are described as part of the low-level interface.
When the user writes a command like \draw (0bp,0bp) -- (10bp,0bp); quite a lot happens behind the scenes:
|
The \pgfsyssoftpath@xxxx commands, which are described below, construct a soft path. Each time such a command is used, special tokens are added to the end of an internal macro that stores the soft path currently being constructed.
Why such a complicated process? Why not have \pgfpathlineto directly call \pgfsys@lineto and be done with it? There are two reasons:
|
Such corrupt code is tolerated by most viewers, but not always. It is much better to create only (reasonably) legal code.
No special action must be taken in order to start the creation of a soft path. Rather, each time a command like \pgfsyssoftpath@lineto is called, a special token is added to the (global) current soft path being constructed.
However, you can access and change the current soft path. In this way, it is possible to store a soft path, to manipulate it, or to invoke it.
This command will store the current soft path in <macro name>.
This command will set the current soft path to be the path stored in <macro name>. This macro should store a path that has previously been extracted using the \pgfsyssoftpath@getcurrentpath command and has possibly been modified subsequently.
This command will turn the current soft path in a “hard” path. To do so, it iterates over the soft path and calls an appropriate \pgfsys@xxxx command for each element of the path. Note that the current soft path is not changed by this command. Thus, in order to start a new soft path after the old one has been invoked and is no longer needed, you need to set the current soft path to be empty. This may seems strange, but it is often useful to immediately use the last soft path again.
This command will invoke the current soft path and then set it to be empty.
This command appends a “move-to” segment to the current soft path. The coordinates <x> and <y> are given as normal TEX dimensions.
Example: One way to draw a line:
|
Appends a “line-to” segment to the current soft path.
Appends a “curve-to” segment to the current soft path with controls (a,b) and (c,d).
Appends a rectangle segment to the current soft path.
Appends a “close-path” segment to the current soft path.
A soft path is stored in a standardized way, which makes it possible to modify it before it becomes “hard.” Basically, a soft path is a long sequence of triples. Each triple starts with a token that identifies what is going on. This token is followed by two dimensions in braces. For example, the following is a soft path that means “the path starts at (0bp,0bp) and then continues in a straight line to (10bp,0bp).”
|
A curve-to is hard to express in this way since we need six numbers to express it, not two. For this reasons, a curve-to is expressed using three triples as follows: The command
|
results in the following three triples:
|
These three triples must always “remain together.” Thus, a lonely supportbtoken is forbidden.
In details, the following tokens exist: