Dimension
Preview noticeβ
The MatrixOS Python API is in preview and is subject to change; it may contain errors.
Overviewβ
The Dimension class represents 2D dimension structure containing width and height. It's used for layout operations, size calculations, and spatial operations within the MatrixOS framework.
The Dimension class is implemented in Applications/Python/PikaPython/MatrixOS_Dimension.py with type hints in Applications/Python/PikaPython/_MatrixOS_Dimension.pyi.
Dimension(*val)β
class Dimension:
def __init__(self, *val) -> None
Creates a dimension using various input formats:
- 0 arguments: Zero dimension (0, 0)
- 1 argument: From raw bytes
- 2 arguments: Width and height
Parameters:
*val: Variable arguments depending on desired constructor
Getter Methodsβ
Xβ
def X(self) -> int
Gets the X component (width) of the dimension.
Returns:
int: The width value
Yβ
def Y(self) -> int
Gets the Y component (height) of the dimension.
Returns:
int: The height value
Setter Methodsβ
SetXβ
def SetX(self, x: int) -> None
Sets the X component (width) of the dimension.
Parameters:
x(int): New width value
SetYβ
def SetY(self, y: int) -> None
Sets the Y component (height) of the dimension.
Parameters:
y(int): New height value
Methodsβ
Containsβ
def Contains(self, point: Point) -> bool
Checks if a point is contained within this dimension (from origin).
Parameters:
point(Point): Point to check
Returns:
bool: True if point is within dimension bounds
Areaβ
def Area(self) -> int
Calculates the area of the dimension.
Returns:
int: Area (width Γ height)
Operatorsβ
__add__β
def __add__(self, other: Dimension) -> Dimension
Adds two dimensions component-wise.
Parameters:
other(Dimension): Dimension to add
Returns:
Dimension: New dimension with added components
__eq__β
def __eq__(self, other: Dimension) -> bool
Checks if two dimensions are equal.
Parameters:
other(Dimension): Dimension to compare
Returns:
bool: True if dimensions are equal
__bool__β
def __bool__(self) -> bool
Checks if dimension is non-zero (truthy).
Returns:
bool: True if dimension has non-zero area
Comments