2.2.10. Rotation and Scaling of Elements (layout.managers.transform
)¶
-
class
layout.managers.transform.
AnyRotationLM
(angle, element=None)¶ Bases:
layout.managers.root.LayoutManager
A layout manager that allows its child element to be rotated to any angle. The rotated element is always given space that is of the same aspect ratio as the minimum size it requested, even if extra space is available.
This class implements a different algorithm that is much less efficient than
RotateLM
for right angles. UseRotateLM
if you are rotating through a multiple of PI/2. Because of the aspect ratio feature of this algorithm, the results of this class with a right-angle rotation will also differ from that ofRotateLM
.Arguments:
angle
- The angle to rotate, given in radians.
-
get_minimum_size
(data)¶ Finds the minimum size of its child element as a rectangle. Then works out the minimum size needed to fit that rectangle when rotated. This can dramatically overstate the actual size needed to fit the rotated element if the original element is not rectangular.
-
render
(rect, data)¶ Asks the element to render itself.
-
class
layout.managers.transform.
FixedScaleLM
(scale=1.0, element=None)¶ Bases:
layout.managers.root.LayoutManager
A layout manager that scales its one element by a fixed amount.
-
get_minimum_size
(data)¶ How small can the element be? Should return a Point.
-
render
(rect, data)¶ Asks the element to render itself.
-
-
class
layout.managers.transform.
FlexScaleLM
(element=None)¶ Bases:
layout.managers.root.LayoutManager
A layout manager that holds one element, and scales it down with anisotropic scaling, if it is too large to fit. Unlike the regular
ScaleLM
, this class gives the scaled object any additional room it has to fit, rather than preserving its aspect ratio.-
get_minimum_size
(data)¶ How small can the element be? Should return a Point.
-
render
(rect, data)¶ Asks the element to render itself.
-
-
class
layout.managers.transform.
RotateLM
(angle, element=None)¶ Bases:
layout.managers.root.LayoutManager
A layout manager that holds one element and rotates it by the given number of right angles.
The right angle value given can’t be fractional, it must be an integer. Convenience constants are provided in this class for code readability.
-
ANGLE_0
= 0¶ No rotation
-
ANGLE_180
= 2¶ Rotates 180 degrees.
-
ANGLE_270
= 3¶ Rotates 90 decrees clockwise, or 270 degrees clockwise.
-
ANGLE_90
= 1¶ Rotates 90 degrees counter-clockwise
-
NORMAL
= 0¶ No rotation
-
UPSIDE_DOWN
= 2¶ Rotates 180 degrees.
-
X_DOWN
= 3¶ Rotates 90 degrees clockwise, so the X-axis points down.
-
X_UP
= 1¶ Rotates 90 degrees counter-clockwise so the X-axis points up.
-
get_minimum_size
(data)¶ Returns the rotated minimum size.
-
render
(rect, data)¶ Asks the element to render itself.
-
-
class
layout.managers.transform.
ScaleLM
(element=None)¶ Bases:
layout.managers.root.LayoutManager
A layout manager that holds one element, and scales it down with isotropic scaling if it is too large to fit.
-
get_minimum_size
(data)¶ How small can the element be? Should return a Point.
-
render
(rect, data)¶ Asks the element to render itself.
-