Size

class kurbopy.Size(width, height)

A 2D size.

classmethod ZERO()

A size with zero width or height.

area()

The area covered by this size.

aspect_ratio()

Returns the aspect ratio of a rectangle with the given size.

If the width is 0, the output will be sign(self.height) * infinity. If The width and height are 0, then the output will be NaN.

ceil()

Returns a new Size, with width and height rounded up to the nearest integer, unless they are already an integer.

clamp(min, max)

Returns a new size bounded by min and max.

# Examples

` this = Size(0., 100.) min = Size(10., 10.) max = Size(50., 50.) assert this.clamp(min, max) == Size(10., 50.)) `

expand()

Returns a new Size, with width and height rounded away from zero to the nearest integer, unless they are already an integer.

floor()

Returns a new Size, with width and height rounded down to the nearest integer, unless they are already an integer.

height
is_empty()

Whether this size has zero area.

Note: a size with negative area is not considered empty.

is_finite()

Is this size finite?

is_nan()

Is this size NaN?

max_side()

Returns the max of width and height.

# Examples

` size = Size(-10.5, 42.0) assert size.max_side() == 42.0 `

min_side()

Returns the min of width and height.

# Examples

` size = Size(-10.5, 42.0) assert size.min_side() == -10.5 `

round()

Returns a new Size, with width and height rounded to the nearest integer.

# Examples

` size_pos = Size(3.3, 3.6).round() assert size_pos.width == 3.0) assert size_pos.height == 4.0) size_neg = Size(-3.3, -3.6).round() assert size_neg.width == -3.0) assert size_neg.height == -4.0) `

to_rect()

Convert this Size into a [Rect] with origin (0.0, 0.0).

to_vec2()

Convert this size into a [Vec2], with width mapped to x and height mapped to y.

trunc()

Returns a new Size, with width and height rounded down towards zero the nearest integer, unless they are already an integer.

width