Rect
Functions for rectangle operations.
Move
move(rect: Rect, offset: Vec2) → Rect
Move a rectangle by a specified offset.
Parameters
rect
: The rectangle to move.offset
: The offset by which to move the rectangle.
Returns
Rect
: The moved rectangle.
Clamp
clamp(rect: Rect, min: Vec2, max: Vec2) → Rect
Clamp a rectangle to a specified range.
Parameters
rect
: The rectangle to clamp.min
: The minimum allowed values for each component.max
: The maximum allowed values for each component.
Returns
Rect
: The clamped rectangle.
clamp(rect: Rect, other: Rect) → Rect
Clamp a rectangle to another rectangle.
Parameters
rect
: The rectangle to clamp.other
: The rectangle to clamp to.
Returns
Rect
: The clamped rectangle.
Scale By
scale_by(rect: Rect, factor: float) → Rect
Scale a rectangle by a specified factor.
Parameters
rect
: The rectangle to scale.factor
: The scaling factor (uniform scaling).
Returns
Rect
: The scaled rectangle.
scale_by(rect: Rect, factor: Vec2) → Rect
Scale a rectangle by a specified factor for each component.
Parameters
rect
: The rectangle to scale.factor
: The scaling factor for each component.
Returns
Rect
: The scaled rectangle.
Scale To
scale_to(rect: Rect, size: Vec2) → Rect
Scale a rectangle to a specified size.
Parameters
rect
: The rectangle to scale.size
: The desired size of the rectangle.
Returns
Rect
: The scaled rectangle.