Module rect

Module rect 

Source

Modules§

boolean
Boolean operations on rectangles.

Structs§

Alignment
Horizontal/vertical alignment options.
Rect9Points
Returns an object containing the nine control points of a rectangle.
Rectangle
A rectangle defined by its top-left corner (x, y) and width and height.
Sides
Padding or margin values for each side of a rectangle.

Enums§

AlignKind
Alignment kind for rectangle positioning.
CardinalDirection
Cardinal directions including diagonals.
RectangleSide
Represents a side of a rectangle.

Functions§

align
Aligns rectangles within their bounding box.
align_a
Aligns rectangle a relative to rectangle b.
aspect_ratio
Returns the aspect ratio width / height.
axis_projection_intersection
Returns the overlapping projection range of rectangles along the counter axis.
contains
Returns true if rectangle a fully contains rectangle b.
contains_point
Returns true if the point is inside the rectangle (inclusive).
distribute_evenly
Repositions rectangles so they are evenly distributed along the axis while preserving the original ordering.
from_points
Computes the smallest rectangle that encloses all provided points.
get_cardinal_point
Returns the requested cardinal point of the rectangle.
get_center
Returns the center of the rectangle.
get_gaps
Calculates the gaps between adjacent rectangles along an axis.
get_relative_transform
Returns the transform mapping rectangle a onto rectangle b.
get_scale_factors
Returns [scale_x, scale_y] required to scale a to match b.
get_uniform_gap
Calculates the uniform gap between rectangles if present. Returns (Some(gap), gaps) if all gaps are equal within tolerance.
inset
Insets the rectangle by the given margin while keeping its center.
intersection
Returns the intersection of two rectangles, or None if they do not overlap.
intersects
Returns true if two rectangles intersect or touch at the edges.
is_identical
Returns true if two rectangles are exactly equal.
is_uniform
Returns true if all rectangles in the slice are identical.
offset
Returns the signed offset from the point to the nearest edge of the rectangle.
pad
Expands the rectangle by the given padding while keeping its center.
positive
Normalizes the rectangle so width and height are positive.
quantize
Quantizes the rectangle position and size by the given step.
rotate
Rotates the rectangle around its center and returns the bounding box.
to_9points
Computes the nine control points of the rectangle.
to_9points_chunk
Same as to_9points but returns the points in an array ordered as: topLeft, topRight, bottomRight, bottomLeft, topCenter, rightCenter, bottomCenter, leftCenter, center.
transform
Applies an affine transform to the rectangle and returns the bounding box.
union
Computes the bounding rectangle of all input rectangles.