3.3 Positions
A position can be defined by a coordinate pair, e.g.
3,2.5
, more generally using parentheses by
(
expression, expression
)
, as a sum or difference as position +
(
expression, expression
)
, or by the
construction
(
position, position
)
, the latter taking the
x
-coordinate from the first position and
the
y
-coordinate from the second. A position can be given a symbolic name beginning with an
upper-case letter, e.g.
Top: (0.5,4.5)
. Such a definition does not affect the calculated figure
boundaries. The current position
Here
is always defined and is equal to (0
,
0) at the beginning of a
diagram or block. The coordinates of a position are accessible, e.g.
Top.x
and
Top.y
can be used in
expressions. The center, start, and end of linear objects (and the defined points of other objects as
described below) are predefined positions, as shown in the following example, which also illustrates
how to refer to a previously drawn element if it has not been given a name:
line from last line.start to 2nd last arrow.end then to 3rd line.center
Objects can be named (using a name commencing with an upper-case letter), for example:
Bus23: line up right
after which, positions associated with the object can be referenced using the name; for example:
arc cw from Bus23.start to Bus23.end with .center at Bus23.center
An arc is drawn by specifying its rotation, starting point, end point, and center, but sensible
defaults are assumed if any of these are omitted. Note that
arc cw from Bus23.start to Bus23.end
does not define the arc uniquely; there are two arcs that satisfy this specification. This distribution
includes the m4 macros
arcr( position, radius, start radians, end radians, modifiers, ht)
arcd( position, radius, start degrees, end degrees, modifiers, ht)
arca( chord linespec, ccw|cw, radius, modifiers)
to draw uniquely defined arcs. If the fifth argument of
arcr
or
arcd
contains
->
or
<-
then a
midpoint arrowhead of height specified by arg6 is added. For example,
arcd((1,-1),,0,-90,<- outlined "red") dotted
draws a red dotted arc with midpoint arrowhead, centre at (1
, −
1)
,
and default radius. The example
arca(from (1,1) to (2,2),,1,->)
draws an acute angled arc with arrowhead on the chord defined by the first argument.
The linear objects can be given arrowheads at the start, end, or both ends, for example:
line dashed <- right 0.5
arc <-> height 0.06 width 0.03 ccw from Here to Here+(0.5,0) \
with .center at Here+(0.25,0)
spline -> right 0.5 then down 0.2 left 0.3 then right 0.4
The arrowheads on the arc above have had their shape adjusted using the
height
and
width
parameters.
3.4 The planar objects: box, circle, ellipse, and text
Planar objects are drawn by specifying the width, height, and position, thus:
A: box ht 0.6 wid 0.8 at (1,1)
after which, in this example, the position
A.center
is defined, and can be referenced simply as
A
.
The compass points
A.n, A.s, A.e, A.w, A.ne, A.se, A.sw, A.nw
are automatically defined, as
are the dimensions
A.height
and
A.width.
Planar objects can also be placed by specifying the
location of a defined point; for example, two touching circles can be drawn as shown:
circle radius 0.2
circle diameter (last circle.width * 1.2) with .sw at last circle.ne
The planar objects can be filled with gray or colour. For example, either
box dashed fill_(number) or box dashed outlined "color" shaded "color"
produces a dashed box. The first case has a gray fill determined by number, with 0 corresponding
to black and 1 to white; the second case allows color outline and fill, the color strings depending
on the postprocessor. Postprocessor-compatible RGB color strings are produced by the macro
rgbstring(red fraction, green fraction, blue fraction); to produce an orange fill for example:
... shaded rgbstring( 1, 0.645, 0)
7