2.1.1. Positions and Sizes (layout.datatypes.position
)¶
-
class
layout.datatypes.position.
Point
¶ Bases:
layout.datatypes.position.Point
A single point in space, or a vector in 2D.
-
get_angle
()¶ Returns the CCW angle from the positive X-axis (i.e. that returned from atan2.
-
get_angle_between
(other)¶ Returns the smallest angle between this vector and the given other vector.
-
get_component_product
(other)¶ Returns the component product of this vector and the given other vector.
-
get_copy
()¶ Returns a copy of this vector.
-
get_left_normal
()¶ Returns the left hand normal of this vector: the vector produced by rotating this vector about ninety degrees anti-clockwise.
-
get_magnitude
()¶ Returns the magnitude of this vector.
-
get_magnitude_squared
()¶ Returns the square of the magnitude of this vector.
-
get_maximum
(other)¶ Updates this vector so its components are the higher of its current components and those of the given other value.
-
get_minimum
(other)¶ Updates this vector so its components are the lower of its current components and those of the given other value.
-
get_normalized
()¶ Returns a vector of unit length, unless it is the zero vector, in which case it is left as is.
-
static
get_random
(min_pt, max_pt)¶ Returns a random vector in the given range.
-
get_right_normal
()¶ Returns the right hand normal of this vector: the vector produced by rotating this vector about ninety degrees clockwise.
-
get_rotated
(angle)¶ Rotates this vector through the given anti-clockwise angle in radians.
-
get_scalar_product
(other)¶ Returns the scalar product of this vector with the given other vector.
-
get_x_mirror
()¶ Returns a copy of this vector reflected in the x=0 axis.
-
get_y_mirror
()¶ Returns a copy of this vector reflected in the y=0 axis.
-
-
class
layout.datatypes.position.
Rectangle
(x, y, w, h)¶ Bases:
object
A rectangle in two dimensional space.
The data in this rectangle can be accessed in many different ways. It has data members of
x
,y
,w
, andh
, and properties corresponding to all combinations ofleft
(which equalsx
),right
,top
,bottom
(which equalsy
),center
(horizontal) andmiddle
(vertical). Pair combinations (such astop_right
) return aPoint
, while single values (such ascenter
) return a number. You can also abbreviate each of the properties using its initial letter.So to access the center point of the rectangle, for example, you use any of the properties:
Rectangle.cm
Rectangle.mc
Rectangle.center_middle
Rectangle.middle_center
And to access just the right-hand coordinate, you can use:
Rectangle.right
Rectangle.r
-
get_data
()¶ Returns the x, y, w, h, data as a tuple.