Skip to main content
Version: Matrix OS 3.2

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