(texdraw)Saving positions


Next: Scaling coordinates Prev: Drawing paths Up: Drawing Segments and Scaling
Enter node , (file) or (file)node

3.3 Saving positions
====================

The '\savecurrpos' command saves the current position.  The saved
position is an absolute position, not one relative to a segment.  The
position saving mechanism is global; the position can be saved within a
nested segment and then used outside of the segment.  The X and Y
coordinates of the position are saved separately as named coordinates.
The names are of the form '*NAME', with the leading '*' being
obligatory.  A companion command, '\savepos', saves a given coordinate
(relative to the current segment) as an absolute symbolic position.

'\savecurrpos (*PX *PY)'
     Save the current position as the absolute position referenced by
     '(*PX *PY)'.
'\savepos (X Y)(*PX *PY)'
     Save the coordinate position '(X Y)' as the absolute position
     referenced by '(*PX *PY)'.  The coordinate '(X Y)' is interpreted
     in the normal fashion as a coordinate relative to the current
     segment, using the current scaling factors and drawing unit.

   The symbolic names used to specify a saved position can consist of
any characters that are not special to TeX, but must start with a '*'
character.  The symbolic names can be used as the X and/or Y coordinate
in any command that needs a coordinate.  Symbolic coordinates are not
normally used with relative motion commands such as '\rlvec' or
'\rmove'.  If used with relative motion, the corresponding displacement
is equal to the symbolic coordinate value.

   On exit from a segment, the position and graphics state on entry is
restored.  Any changes to line types, scaling and position are
discarded.  However, it is sometimes useful alter the position on exit
from a segment.  The '\savepos' command allows for the saving of a
position within the segment.  This position can be restored after the
'\esegment' with a '\move' command using the saved symbolic position.
This approach can be used to build modules which operate in a manner
analogous to the basic relative motion line vector commands.

   The following example defines a macro which draws a box 0.75 inches
wide by 0.5 inches high containing centered text.  On leaving the macro
the position will be set at a point on the righthand side of the box.
     \def\tbox #1{\bsegment
                    \lvec (0 +0.25)    \lvec (0.75 +0.25)
                    \lvec (0.75 -0.25) \lvec (0 -0.25) \lvec (0 0)
                    \textref h:C v:C \htext (0.375 0){#1}
                    \savepos (0.75 0)(*ex *ey)
                  \esegment
                  \move (*ex *ey)}
   With this definition, we can treat '\tbox' in the same way as the
basic vector commands, stringing them together to form a block diagram
as in this example.
     \centertexdraw{
       \ravec (1 0) \tbox{$H(z)$} \ravec (1 0)
     }


automatically generated by info2www version 1.2.2.9