Dimension
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
Examples:
# Create zero dimension
zero_dim = Dimension()
# Create dimension from width and height
size = Dimension(8, 8) # 8x8 dimension
# Create from raw bytes (advanced usage)
raw_dim = Dimension(0x00080008) # Packed width/height
Getter Methods
X
def X(self) -> int
Gets the X component (width) of the dimension.
Returns:
int
: The width value
Example:
dim = Dimension(8, 6)
width = dim.X() # Returns 8
Y
def Y(self) -> int
Gets the Y component (height) of the dimension.
Returns:
int
: The height value
Example:
dim = Dimension(8, 6)
height = dim.Y() # Returns 6