Rect
Rectangle related functions
Clamp
clamp(rect: Rect, min: Vec2, max: Vec2) → RectClamp a rectangle to be within the specified bounds.
Args
rect: The rectangle to clamp.min: The minimum bounds as (min_x, min_y).max: The maximum bounds as (max_x, max_y).
Returns
Rect : A new rectangle clamped within the bounds.
Raises
ValueError: If min >= max or rectangle is larger than the clamp area.
clamp(rect: Rect, other: Rect) → RectClamp a rectangle to be within another rectangle.
Args
rect: The rectangle to clamp.other: The rectangle to clamp within.
Returns
Rect : A new rectangle clamped within the other rectangle.
Raises
ValueError: If rect is larger than the clamp area.
Move
move(rect: Rect, offset: Vec2) → RectMove a rectangle by the given offset.
Args
rect: The rectangle to move.offset: The offset to move by as (dx, dy).
Returns
Rect : A new rectangle moved by the offset.
Scale By
scale_by(rect: Rect, factor: SupportsFloat) → RectScale a rectangle by a uniform factor.
Args
rect: The rectangle to scale.factor: The scaling factor (must be > 0).
Returns
Rect : A new rectangle scaled by the factor.
Raises
ValueError: If factor is <= 0.
scale_by(rect: Rect, factor: Vec2) → RectScale a rectangle by different factors for width and height.
Args
rect: The rectangle to scale.factor: The scaling factors as (scale_x, scale_y).
Returns
Rect : A new rectangle scaled by the factors.
Raises
ValueError: If any factor is <= 0.