remove pyxdate and pyxversion, which are not be handled by separate files
[PyX/mjg.git] / manual / box.tex
blob92095d753f5e3df3a7b96d9ef2d1592301470fbc
1 \chapter{Module box: convex box handling}
2 \label{module:box}
4 This module has a quite internal character, but might still be useful
5 from the users point of view. It might also get further enhanced to
6 cover a broader range of standard arranging problems.
8 In the context of this module a box is a convex polygon having
9 optionally a center coordinate, which plays an important role for the
10 box alignment. The center might not at all be central, but it should
11 be within the box. The convexity is necessary in order to keep the
12 problems to be solved by this module quite a bit easier and
13 unambiguous.
15 Directions (for the alignment etc.) are usually provided as pairs
16 (dx, dy) within this module. It is required, that at least one of
17 these two numbers is unequal to zero. No further assumptions are taken.
19 \section{Polygon}
21 A polygon is the most general case of a box. It is an instance of the
22 class \verb|polygon|. The constructor takes a list of points (which
23 are (x, y) tuples) in the keyword argument \verb|corners| and
24 optionally another (x, y) tuple as the keyword argument \verb|center|.
25 The corners have to be ordered counterclockwise. In the following list
26 some methods of this \verb|polygon| class are explained:
28 \begin{description}
29 \item[\texttt{path(centerradius=None, bezierradius=None,
30 beziersoftness=1)}:] returns a path of the box; the center might be
31 marked by a small circle of radius \verb|centerradius|; the corners
32 might be rounded using the parameters \verb|bezierradius| and
33 \verb|beziersoftness|. For each corner of the box there may be one value
34 for beziersoftness and two bezierradii. For convenience, it is not necessary
35 to specify the whole list (for beziersoftness) and the whole list of
36 lists (bezierradius) here. You may give a single value and/or a 2-tuple instead.
37 \item[\texttt{transform(*trafos)}:] performs a list of transformations
38 to the box
39 \item[\texttt{reltransform(*trafos)}:] performs a list of
40 transformations to the box relative to the box center
42 \includegraphics{boxalign}
43 \centerline{circle and line alignment examples (equal direction and
44 distance)}
46 \item[\texttt{circlealignvector(a, dx, dy)}:] returns a vector (a
47 tuple (x, y)) to align the box at a circle with radius \verb|a| in
48 the direction (\verb|dx|, \verb|dy|); see figure~\ref{fig:boxalign}
49 \item[\texttt{linealignvector(a, dx, dy)}:] as above, but align at a
50 line with distance \verb|a|
51 \item[\texttt{circlealign(a, dx, dy)}:] as circlealignvector, but
52 perform the alignment instead of returning the vector
53 \item[\texttt{linealign(a, dx, dy)}:] as linealignvector, but
54 perform the alignment instead of returning the vector
55 \item[\texttt{extent(dx, dy)}:] extent of the box in the direction
56 (\verb|dx|, \verb|dy|)
57 \item[\texttt{pointdistance(x, y)}:] distance of the point (\verb|x|,
58 \verb|y|) to the box; the point must be outside of the box
59 \item[\texttt{boxdistance(other)}:] distance of the box to the box
60 \verb|other|; when the boxes are overlapping, \verb|BoxCrossError| is
61 raised
62 \item[\texttt{bbox()}:] returns a bounding box instance appropriate to
63 the box
64 \end{description}
66 \section{Functions working on a box list}
68 \begin{description}
69 \item[\texttt{circlealignequal(boxes, a, dx, dy)}:] Performs a circle
70 alignment of the boxes \verb|boxes| using the parameters \verb|a|,
71 \verb|dx|, and \verb|dy| as in the \verb|circlealign| method. For the
72 length of the alignment vector its largest value is taken for all
73 cases.
74 \item[\texttt{linealignequal(boxes, a, dx, dy)}:] as above, but
75 performing a line alignment
76 \item[\texttt{tile(boxes, a, dx, dy)}:] tiles the boxes \verb|boxes|
77 with a distance \verb|a| between the boxes (in addition the maximal box
78 extent in the given direction (\verb|dx|, \verb|dy|) is taken into
79 account)
80 \end{description}
82 \section{Rectangular boxes}
84 For easier creation of rectangular boxes, the module provides the
85 specialized class \verb|rect|. Its constructor first takes four
86 parameters, namely the x, y position and the box width and height.
87 Additionally, for the definition of the position of the center, two
88 keyword arguments are available. The parameter \verb|relcenter| takes
89 a tuple containing a relative x, y position of the center (they are
90 relative to the box extent, thus values between \verb|0| and
91 \verb|1| should be used). The parameter \verb|abscenter| takes a tuple
92 containing the x and y position of the center. This values are
93 measured with respect to the lower left corner of the box. By
94 default, the center of the rectangular box is set to this lower left
95 corner.