Class: Dimension
The Dimension class represents a 2D dimension or size, with utility functions for operations like area calculation and comparisons.
The source file for this class is located in os/framework/Dimension.h
Constructorsβ
Default Constructorβ
Dimension();
Initializes the dimension to (0, 0).
From x and yβ
Dimension(int16_t x, int16_t y);
Constructs a dimension from individual x and y values.
Parameters:
x(int16_t): The width.y(int16_t): The height.
From Raw 32-bit Valueβ
Dimension(uint32_t rawByte);
Constructs a dimension from a 32-bit raw value.
Parameters:
rawByte(uint32_t): The raw data encodingxandy. The high 16 bits representx, and the low 16 bits representy.
Member Functionsβ
Containsβ
bool Contains(Point point);
Checks if a point is within the dimension.
Parameters:
point(Point): The point to check.
Returns:
bool:trueif the point is within the dimension, otherwisefalse.
Areaβ
uint32_t Area();
Calculates the area of the dimension.
Returns:
uint32_t: The area, calculated asx * y.
Operatorsβ
Additionβ
Dimension operator+(const Dimension& cp) const;
Adds two dimensions together.
Parameters:
cp(const Dimension&): The other dimension to add.
Returns:
Dimension: A new dimension resulting from the addition.
Inequality Comparisonβ
bool operator!=(const Dimension& cp) const;
Checks if two dimensions are not equal.
Parameters:
cp(const Dimension&): The other dimension to compare.
Returns:
bool:trueif the dimensions are not equal, otherwisefalse.
Less Than Comparisonβ
bool operator<(const Dimension& cp) const;
Compares two dimensions. First compares x, and if they are equal, compares y.
Parameters:
cp(const Dimension&): The other dimension to compare.
Returns:
bool:trueif the current dimension is smaller, otherwisefalse.
Conversion to boolβ
operator bool();
Checks if the dimension is non-zero.
Returns:
bool:trueif bothxandyare non-zero, otherwisefalse.
Conversion to uint32_tβ
operator uint32_t();
Converts the dimension to a 32-bit raw value.
Returns:
uint32_t: A raw representation of the dimension. The high 16 bits representx, and the low 16 bits representy.
Comments