This module has a quite internal character, but might still be useful from the users point of view. It might also get further enhanced to cover a broader range of standard arranging problems.
In the context of this module a box is a convex polygon having optionally a center coordinate, which plays an important role for the box alignment. The center might not at all be central, but it should be within the box. The convexity is necessary in order to keep the problems to be solved by this module quite a bit easier and unambiguous.
Directions (for the alignment etc.) are usually provided as pairs (dx, dy) within this module. It is required, that at least one of these two numbers is unequal to zero. No further assumptions are taken.
A polygon is the most general case of a box. It is an instance of the class
polygon. The constructor takes a list of points (which are (x, y) tuples) in
the keyword argument
corners and optionally another (x, y) tuple as the
center. The corners have to be ordered counterclockwise. In
the following list some methods of this
polygon class are explained:
path(centerradius=None, bezierradius=None, beziersoftness=1):
centerradius; the corners might be rounded using the parameters
beziersoftness. For each corner of the box there may be one value for beziersoftness and two bezierradii. For convenience, it is not necessary to specify the whole list (for beziersoftness) and the whole list of lists (bezierradius) here. You may give a single value and/or a 2-tuple instead.
circlealignvector(a, dx, dy):
ain the direction (
dy); see figure circle and line alignment examples (equal direction and distance)
linealignvector(a, dx, dy):
circlealign(a, dx, dy):
linealign(a, dx, dy):
y) to the box; the point must be outside of the box
other; when the boxes are overlapping,
circlealignequal(boxes, a, dx, dy):
boxesusing the parameters
dyas in the
circlealignmethod. For the length of the alignment vector its largest value is taken for all cases.
linealignequal(boxes, a, dx, dy):
tile(boxes, a, dx, dy):
boxeswith a distance
abetween the boxes (in addition the maximal box extent in the given direction (
dy) is taken into account)
For easier creation of rectangular boxes, the module provides the specialized
rect. Its constructor first takes four parameters, namely the x, y
position and the box width and height. Additionally, for the definition of the
position of the center, two keyword arguments are available. The parameter
relcenter takes a tuple containing a relative x, y position of the center
(they are relative to the box extent, thus values between
be used). The parameter
abscenter takes a tuple containing the x and y
position of the center. This values are measured with respect to the lower left
corner of the box. By default, the center of the rectangular box is set to this
lower left corner.