Skip to content

Size

A 2D size with width and height.

Properties

Methods

Properties#

aspect_ratio property #

aspect_ratio: float

Returns the aspect ratio (width / height).

height instance-attribute #

height: Number

width instance-attribute #

width: Number

Methods#

copy #

copy(
    *,
    width: Number | None = None,
    height: Number | None = None,
) -> Size

Returns a copy of this object with the specified properties overridden.

from_height classmethod #

from_height(height: Number) -> Size

Creates a Size with the given height and an infinite width.

from_radius classmethod #

from_radius(radius: Number) -> Size

Creates a square Size whose width and height are twice the given radius.

from_width classmethod #

from_width(width: Number) -> Size

Creates a Size with the given width and an infinite height.

infinite classmethod #

infinite()

Creates a Size whose width and height are both positive infinity.

is_finite #

is_finite() -> bool

Checks if both dimensions are finite.

is_infinite #

is_infinite() -> bool

Checks if either dimension is infinite.

square classmethod #

square(dimension: Number) -> Size

Creates a square Size where width and height are the same.

zero classmethod #

zero()

Creates a Size whose width and height are both 0.0.