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 encodingx
andy
. 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
:true
if 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
:true
if 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
:true
if the current dimension is smaller, otherwisefalse
.
Conversion to bool
​
operator bool();
Checks if the dimension is non-zero.
Returns:
bool
:true
if bothx
andy
are 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