Welcome to Python-flavored Magnum! Please note that, while already being rather stable, this functionality is still considered experimental and some APIs might get changed without preserving full backwards compatibility.

magnum.Range2D class

Two-dimensional float range

Static methods

def from_center(arg0: Vector2, arg1: Vector2, /) -> Range2D
Create a range from center and half size
def from_size(arg0: Vector2, arg1: Vector2, /) -> Range2D
Create a range from minimal coordinates and size
def zero_init() -> Range2D
Construct a zero range

Methods

def center(self, /) -> Vector2
Range center
def center_x(self, /) -> float
Range center on X axis
def center_y(self, /) -> float
Range center on Y axis
def contains(self, arg0: Vector2, /) -> bool
Whether given point is contained inside the range
def contains(self, arg0: Range2D, /) -> bool
Whether another range is fully contained inside this range
def padded(self, arg0: Vector2, /) -> Range2D
Padded ange
def scaled(self, arg0: Vector2, /) -> Range2D
Scaled range
def scaled(self, arg0: float, /) -> Range2D
Scaled range
def scaled_from_center(self, arg0: Vector2, /) -> Range2D
Range scaled from the center
def scaled_from_center(self, arg0: float, /) -> Range2D
Range scaled from the center
def size(self, /) -> Vector2
Range size
def size_x(self, /) -> float
Range width
def size_y(self, /) -> float
Range height
def translated(self, arg0: Vector2, /) -> Range2D
Translated range
def x(self, /) -> Range1D
Range in the X axis
def y(self, /) -> Range1D
Range in the Y axis

Special methods

def __eq__(self, arg0: Range2D, /) -> bool
Equality comparison
def __getstate__(self, /) -> bytes
Dumps the in-memory representation of range min/max components
def __init__(self, arg0: Range2Di, /) -> None
Construct from different underlying type
def __init__(self, arg0: Range2Dd, /) -> None
Construct from different underlying type
def __init__(self, /) -> None
Default constructor
def __init__(self, arg0: Vector2, arg1: Vector2, /) -> None
Construct a range from minimal and maximal coordinates
def __init__(self, arg0: tuple[Vector2, Vector2], /) -> None
Construct a range from minimal and maximal coordinates
def __init__(self, arg0: tuple[tuple[float, float], tuple[float, float]], /) -> None
Construct a range from a pair of minimal and maximal coordinates
def __ne__(self, arg0: Range2D, /) -> bool
Non-equality comparison
def __repr__(self, /) -> str
Object representation
def __setstate__(self, arg0: bytes, /) -> None
Treats the data as the in-memory representation of range min/max components

Properties

bottom: float get set
Bottom edge
bottom_left: Vector2 get set
Bottom left corner
bottom_right: Vector2 get set
Bottom right corner
left: float get set
Left edge
max: Vector2 get set
Maximal coordinates (exclusive)
min: Vector2 get set
Minimal coordinates (inclusive)
Right edge
top: float get set
Top edge
top_left: Vector2 get set
Top left corner
top_right: Vector2 get set
Top right corner

Method documentation

def magnum.Range2D.__setstate__(self, arg0: bytes, /) -> None

Treats the data as the in-memory representation of range min/max components

Exceptions
ValueError If the data size doesn’t match type size