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;