1 <?xml version=
"1.0" encoding=
"UTF-8"?>
2 <?xml-stylesheet type=
"text/xsl" href=
"formats/html.xsl"?>
4 <!-- This file is part of Shapes. -->
6 <!-- Shapes is free software: you can redistribute it and/or modify -->
7 <!-- it under the terms of the GNU General Public License as published by -->
8 <!-- the Free Software Foundation, either version 3 of the License, or -->
9 <!-- any later version. -->
11 <!-- Shapes is distributed in the hope that it will be useful, -->
12 <!-- but WITHOUT ANY WARRANTY; without even the implied warranty of -->
13 <!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -->
14 <!-- GNU General Public License for more details. -->
16 <!-- You should have received a copy of the GNU General Public License -->
17 <!-- along with Shapes. If not, see <http://www.gnu.org/licenses/>. -->
19 <!-- Copyright 2008, 2014 Henrik Tidefelt -->
23 <within-namespace>..Shapes..Layout
</within-namespace>
24 <extension>basic-layout
</extension>
26 <p>Elementary layout using bounding boxes.
</p>
31 <title><self /></title>
32 <meta-selflink><self-href /></meta-selflink>
33 <up-link><parent-namespace /></up-link>
34 <base href=
<!--#expand-next-string-->"$(BASE)" />
35 <examples-home href=
<!--#expand-next-string-->"$(EXAMPLES)" />
36 <shapes-version number=
<!--#expand-next-string-->"$(SHAPES_VERSION)" />
38 <!--#include virtual="^/toc.xml" -->
43 <p>The functions in this extension provide the basic means for layout.
</p>
46 <section id=
"extensions/basic-layout/path-max">
47 <title>Extreme coordinates on paths
</title>
49 <p>These functions optimize along paths in one of the four principal directions, returning the coordinate of the optimum.
</p>
51 <system-binding identifier=
"xmax">
56 <type><named-type name=
"Path" /></type>
60 <type><named-type name=
"Length" /></type>
62 <dynamic-references></dynamic-references>
64 <p>Rightmost coordinate along
<arg name=
"p" />.
</p>
70 <system-binding identifier=
"xmin">
75 <type><named-type name=
"Path" /></type>
79 <type><named-type name=
"Length" /></type>
81 <dynamic-references></dynamic-references>
83 <p>Leftmost coordinate along
<arg name=
"p" />.
</p>
89 <system-binding identifier=
"ymax">
94 <type><named-type name=
"Path" /></type>
98 <type><named-type name=
"Length" /></type>
100 <dynamic-references></dynamic-references>
102 <p>Topmost coordinate along
<arg name=
"p" />.
</p>
108 <system-binding identifier=
"ymin">
113 <type><named-type name=
"Path" /></type>
117 <type><named-type name=
"Length" /></type>
119 <dynamic-references></dynamic-references>
121 <p>Bottommost coordinate along
<arg name=
"p" />.
</p>
130 <section id=
"extensions/basic-layout/basic">
131 <title>Basic positioning operations
</title>
134 <system-binding identifier=
"center">
136 <case constructor-of=
"Drawable">
138 <arg identifier=
"obj">
139 <type><named-type name=
"Drawable" /></type>
142 <type><named-type name=
"FloatPair" /></type>
143 <default><eq>(
0,
0)
</eq></default>
146 <dynamic-references></dynamic-references>
148 <p>The argument
<arg name=
"z" /> is interpreted as a point in the bounding box of
<arg name=
"obj" />, with (-
1,-
1) being the lower left corner, and (
1,
1) being the upper right corner.
<arg name=
"obj" /> is then shifted so that this point ends up at the origin.
</p>
154 <system-binding identifier=
"center_x">
156 <case constructor-of=
"Drawable">
158 <arg identifier=
"obj">
159 <type><named-type name=
"Drawable" /></type>
162 <type><named-type name=
"Float" /></type>
163 <default><eq>0</eq></default>
166 <dynamic-references></dynamic-references>
168 <p>Like
<value name=
"..Shapes..Layout..center" />, but operates only along the
<eq>x
</eq> axis.
</p>
174 <system-binding identifier=
"center_y">
176 <case constructor-of=
"Drawable">
178 <arg identifier=
"obj">
179 <type><named-type name=
"Drawable" /></type>
182 <type><named-type name=
"Float" /></type>
183 <default><eq>0</eq></default>
186 <dynamic-references></dynamic-references>
188 <p>Like
<value name=
"..Shapes..Layout..center" />, but operates only along the
<eq>y
</eq> axis.
</p>
194 <system-binding identifier=
"centerof">
196 <case constructor-of=
"Coords">
198 <arg identifier=
"obj">
199 <type><named-type name=
"Drawable" /></type>
202 <dynamic-references></dynamic-references>
204 <p>Returns the point which is mid-way between the extreme points of the bounding box in the
<eq>x
</eq> and
<eq>y
</eq> direction, respectively.
</p>
213 <section id=
"extensions/basic-layout/labelmargin">
214 <title>Label margin
</title>
216 <p>When positioning text relative to other elements, it often looks good if labels appear at a certain distance from the objects they label. This idea is implemented as functions using a common dynamic variable.
</p>
218 <dynamic-variable identifier=
"labelmargin">
219 <default><physical><scalar>1</scalar><unit>mm
</unit></physical></default>
220 <type><named-type name=
"Length" /></type>
222 <p>Distance to be used when placing labels relative to the point they label.
</p>
226 <system-binding identifier=
"center_wlm">
228 <case constructor-of=
"Drawable">
230 <arg identifier=
"obj">
231 <type><named-type name=
"Drawable" /></type>
234 <type><named-type name=
"FloatPair" /></type>
237 <dynamic-references><dynvar extension=
"basic-layout" name=
"labelmargin" /></dynamic-references>
239 <p>The argument
<arg name=
"z" /> is interpreted as a point in the bounding box of
<arg name=
"obj" />, with (-
1,-
1) being the lower left corner, and (
1,
1) being the upper right corner.
<arg name=
"obj" /> is then shifted so that this point ends up at the origin.
</p>
248 <section id=
"extensions/basic-layout/mediation">
249 <title>Mediation
</title>
251 <p>By
<em>mediation
</em> we refer to the specification of a value relative to a lower and upper bound. The bounds can either be very general, or the beginning and end of a path.
</p>
253 <system-binding identifier=
"mediate">
259 <p>Elements constitute a linear space, that is, they can be added and multiplied by scalars.
</p>
264 <type><template-type name=
"L" /></type>
268 <type><named-type name=
"Float" /></type>
270 <arg identifier=
"x1">
271 <type><template-type name=
"L" /></type>
273 <arg identifier=
"x2">
274 <type><template-type name=
"L" /></type>
277 <dynamic-references></dynamic-references>
279 <p>Simply computes (
1-
<arg name=
"r" />)*
<arg name=
"x1" /> +
<arg name=
"r" />*
<arg name=
"x2" />.
</p>
285 <system-binding identifier=
"mspoint">
287 <case constructor-of=
"Coords">
289 <arg identifier=
"pth">
290 <type><named-type name=
"Path" /></type>
292 <arg identifier=
"mediation">
293 <type><named-type name=
"Float" /></type>
295 <arg identifier=
"slide">
296 <type><named-type name=
"Length" /></type>
297 <default><physical><scalar>0</scalar><unit>cm
</unit></physical></default>
300 <dynamic-references></dynamic-references>
302 <p>Interprets
<arg name=
"mediation" /> as a length relative the total length of
<arg name=
"pth" />, then adds
<arg name=
"slide" /> to this length, and finds the coordinates at the computed arc time.
</p>
303 <p>For instance, the geometric midpoint of a path
<inline>myPath
</inline> is obtained as
<inline>[mspoint myPath
0.5]
</inline>.
</p>
311 <section id=
"extensions/basic-layout/boxes">
314 <p>It is sometime useful to control the layout of an object by altering one or several of its boxes. At the moment, there are just two boxes, the
<em>bounding box
</em> and the
<em>bleed box
</em>, and for historical reasons, the short
<em>bbox
</em> refers to the
<em>bounding box
</em>.
</p>
316 <system-binding identifier=
"bboxed_sym">
320 <arg identifier=
"obj">
321 <type><named-type name=
"Drawable" /></type>
325 <type><named-type name=
"Drawable" /></type>
327 <dynamic-references></dynamic-references>
329 <p>Enlarges the bounding box to a rectangle just big enough to obtain the center of the bounding box at the origin.
</p>
335 <system-binding identifier=
"bboxed_sym_y">
339 <arg identifier=
"obj">
340 <type><named-type name=
"Drawable" /></type>
344 <type><named-type name=
"Drawable" /></type>
346 <dynamic-references></dynamic-references>
348 <p>Enlarges the bounding box to a rectangle just big enough to obtain the center of the bounding box at the
<eq>y
</eq> coordinate zero.
</p>
354 <system-binding identifier=
"bboxed_sym_x">
358 <arg identifier=
"obj">
359 <type><named-type name=
"Drawable" /></type>
363 <type><named-type name=
"Drawable" /></type>
365 <dynamic-references></dynamic-references>
367 <p>Enlarges the bounding box to a rectangle just big enough to obtain the center of the bounding box at the
<eq>x
</eq> coordinate zero.
</p>
373 <system-binding identifier=
"bboxed_enlarge">
377 <arg identifier=
"obj">
378 <type><named-type name=
"Drawable" /></type>
381 <type><named-type name=
"Coords" /></type>
385 <type><named-type name=
"Drawable" /></type>
387 <dynamic-references></dynamic-references>
389 <p>Enlarges the bounding box in all four principal direction to a rectangle, the horizontal and vertical enlargements given by the corresponding coordinates of
<arg name=
"z" />.
</p>
395 <system-binding identifier=
"enlarge_bleedbox">
399 <arg identifier=
"obj">
400 <type><named-type name=
"Drawable" /></type>
403 <type><named-type name=
"Coords" /></type>
407 <type><named-type name=
"Drawable" /></type>
409 <dynamic-references></dynamic-references>
411 <p>Like
<value name=
"..Shapes..Layout..bboxed_enlarge" />, but acting on the bleed box instead of the bounding box.
</p>