chiark / gitweb /
Import upstream version 5.3.
[mup] / mup / docs / uguide / tags.html
CommitLineData
69695f33
MW
1<HTML>
2<HEAD><TITLE>
3Location Tags
4</TITLE></HEAD>
5<BODY>
6<P>
7&nbsp;&nbsp;&nbsp;<A HREF="roll.html">&lt;-- previous page</A>
8
9&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A HREF="index.html">Table of Contents</A>&nbsp;&nbsp;&nbsp;&nbsp;<A HREF="prnttext.html">next page --&gt;</A>
10</P>
11
12<H2>
13Location tags
14</H2>
15<P>
16A location tag is associated with a
17<A HREF="noteattr.html#ntag">note,</A>
18<A HREF="chrdattr.html#ctag">chord,</A>
19or
20<A HREF="bars.html#btag">barline.</A>
21It can then be referenced in order to place a second object, like a comment
22or dotted line, relative to the first object.
23</P>
24<P>
25A tag name can be either a single lower case letter, or an underscore
26folowed by one or more letters, digits, or underscores.
27Each location tag is really a collection of six values,
28namely the north, south, east,
29west, x, and y values of the tagged object. These are referenced by giving
30the tag name followed by a dot, followed by the letter n, s, e, w, x, or y.
31For example:
32<BR><PRE>
33c.n // north of tag c
34_xyz.e // east of tag _xyz
35x.x // x coordinate of tag x
36</PRE><BR>
37</P>
38<P>
39The n, s, e, and w values describe the smallest rectangle that will
40completely enclose the object being tagged.
41The north refers to the top of the object, the south to the bottom, the
42west to the left edge, and the east the right edge. The x and y values
43correspond to the &quot;center&quot; coordinate of the object. This is not necessarily
44the geometric center, but more of a &quot;logical center.&quot; In the case of a tag
45associated with an individual note, it is the geometric center of the note head.
46However, on tags associated with a chord, the x is at the center line of
47note heads that are on the &quot;normal&quot; side of the stem. (Normally, when a stem
48is up, notes are put on the left side of the stem, and when the stem is
49down they are placed on the right side. However, when two notes adjacent
50on the staff have to be printed in a single chord, one has to be moved to the
51opposite side.) The y of a chord is always the middle line of the staff
52containing the chord. The x of a bar line is its geometric center. The y
53of a bar line is the center line of the top visible staff.
54</P>
55<P>
56Tag names can be re-used. The value of a tag will always be its most
57recent definition.
58</P>
59<P>
60There are also several &quot;pre-defined&quot; tags. They are:
61<DL>
62<DT>
63_page
64<DD>
65the entire page
66<DT>
67_win
68<DD>
69the available part of the page
70<DT>
71_cur
72<DD>
73the current location
74</DL>
75</P>
76<P>
77The _page tag refers to the entire page.
78The x and y values of _page are at the geometric center of the page.
79This tag is
80seldom useful, but is provided in case you want to force something to
81a specific place on a page.
82</P>
83<P>
84<A NAME="wintag">The _win tag</A>
85refers to the area of the page available for printing.
86The name comes from the idea that it provides a view, as if through a window,
87of a portion of the page. Its precise meaning depends upon the current
88context.
89In header, footer, top, bottom,
90header2, footer2, top2, bottom2, and block contexts,
91it refers to the area of the
92page taken up by the corresponding element. In music context, it refers
93to the area of the page that remains after excluding the margins and the
94header, footer, top and bottom for the page.
95There is no way to access location tags in any other
96contexts, so _win (and all other location tags)
97are meaningless in other contexts.
98</P>
99<P>
100The _cur tag refers to the current location on the page. This is a single
101point, such that east and west values are the same as x, and north and
102south values are the same as y. It is only useful immediately
103after a command that explicitly sets the current location, that is, after
104a printing command or line or curve command. Since Mup places musical
105data in an arbitrary order, trying to use _cur at other times is likely
106to cause output at a seemingly random place.
107</P>
108<P>
109Location tags can be referenced by a number of commands, including those
110for
111<A HREF="prnttext.html">printing text,</A>
112or
113<A HREF="linecurv.html">drawing lines or curves.</A>
114In the simplest case, two
115tag references are given in parentheses. The first tag
116must refer to a horizontal direction (the &quot;x&quot; direction for mathematicians),
117namely a tag with a w, e, or x after the dot. The second tag is then a
118vertical tag, having n, s, or y. For example:
119<BR><PRE>
120(g.x, g.y) // x and y of tag &quot;g&quot;
121(_tag.w, _item.n) // west of tag &quot;_tag&quot; and
122 // north of tag &quot;_item&quot;
123</PRE><BR>
124The first example refers to the x,y coordinate of tag &quot;g&quot;. The second item
125refers to two different tags. The point referenced has its horizontal
126location aligned with
127the west side of the object having the tag &quot;_tag,&quot; while its vertical
128position is in line with the north side of the object having the tag &quot;_item&quot;.
129In other words, if a line were drawn along the west side of the object
130tagged with &quot;_tag&quot; and another line were drawn along the top edge of the
131object with tag &quot;_item&quot;, the point where those two lines crossed would be
132the point referenced.
133</P>
134<P>
135Frequently, you may want to place something relative to a tagged object.
136You can add offsets in both the x and y dimensions. These offsets are given
137in stepsizes.
138As was mentioned earlier, a stepsize is half the distance between two staff
139lines.
140<BR><PRE>
141(g.x + 4.5, g.y + 4.5)
142</PRE><BR>
143refers to the point 4.5 stepsizes to the right and above the point (g.x, g.y).
144Adding an offset moves to the right in the horizontal direction and
145upward in the vertical direction. You can also subtract an offset:
146<BR><PRE>
147(k.w - 1.3, m.n - 2)
148</PRE><BR>
149refers to a point 1.3 stepsizes to the left of the
150west edge of k and 2 stepsizes below the top of m.
151</P>
152<P>
153In the horizontal direction, offsets can be given in terms of &quot;time&quot;. This
154is specified by using the keyword &quot;time&quot; followed by a number of beats.
155As an example, suppose we have the tag reference:
156<BR><PRE>
157(q.x + time 1, q.y + 2)
158</PRE><BR>
159If the
160<A HREF="param.html#time">time signature</A>
161is 4/4 and tag &quot;q&quot; happens
162to be associated with a half note, this tag reference
163would refer to a point halfway between that note and the following chord,
164since it includes an offset of a quarter note. If &quot;q&quot; had been associated
165with a whole note, the point would be only 1/4 of the way between the
166note and the following chord. Since notes are placed based on various
167constraints and aesthetic considerations, the actual distance will vary
168depending on which tag is referenced.
169</P>
170<P>
171In the case of a
172<A HREF="bars.html#btag">tag associated with a bar line,</A>
173the time to distance mapping
174is done based on the distance between the bar (at count &quot;0&quot;) and the first
175chord in the measure (at count &quot;1&quot;). So, for example, in 4/4 time, a reference
176to a bar line tag + time 0.5 would indicate a place halfway between the bar
177line and the first chord, whereas tag + time 0.25 would be one fourth of the
178way.
179</P>
180<P>
181The mapping of time to distance is done based only on the note, rest, or bar
182line associated with the tag. For example, if the tag is associated with a
183quarter note, and the distance between that note and the next was 0.5 inches,
184specifying &quot;+ time 2&quot; (a half note) would mean 1.0 inch to the right, or
185specifying &quot;- time 2&quot; would mean 1.0 inch to the left, even if the notes to
186the left or right happened to be spread somewhat differently than 0.5 inches
187per quarter note. Thus it is usually advisable not to specify a time offset
188greater than the time value of the note or rest associated with the tag,
189nor to subtract a time value. Stated another way, when specifying the X
190portion of a coordinate using a time offset, it is best to use a location tag
191based on whichever note, rest, or bar is immediately to the left of the
192X location you are trying to specify.
193</P>
194<P>
195The various kinds of offsets can be combined.
196<BR><PRE>
197( _pp + 1.2 - time 3.5, _zz + 2)
198</PRE><BR>
199</P>
200<P>
201At least one of the three possible items--tag, stepsize offset, or
202time offset--must be specified for each direction. Only one
203tag is allowed for each direction. If no tag is specified, the reference
204becomes an absolute reference, giving an exact page location. For example:
205<BR><PRE>
206(10, 20)
207</PRE><BR>
208is 10 stepsizes from the left edge and 20 stepsizes
209above the bottom of the page.
210Time offsets are not allowed on absolute references, and must follow the tag
211reference.
212</P>
213<P>
214It is possible to specify multiple offsets of the same type, although
215this is rarely, if ever, useful. Thus the following are equivalent:
216<BR><PRE>
217( f.x + 1 - 0.5 + time 1 - time 0.5, f.s + .3 - .1)
218( f.x + 0.5 + time 0.5, f.s + .2)
219</PRE><BR>
220</P>
221<HR><P>
222&nbsp;&nbsp;&nbsp;<A HREF="roll.html">&lt;-- previous page</A>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A HREF="index.html">Table of Contents</A>&nbsp;&nbsp;&nbsp;&nbsp;<A HREF="prnttext.html">next page --&gt;</A>
223</P>
224</BODY></HTML>