Iridescence 1.00
Embedded Graphic Framework
Loading...
Searching...
No Matches
DsRect Class Reference

DsRect is a class that represents a 2D rectangle (X, Y, W, H) More...

#include <ds_geometry.h>

Inheritance diagram for DsRect:
[legend]

Public Member Functions

 DsRect ()
 Creates a DsRect object initialized to (0, 0, 0, 0).
 
 DsRect (int32_t x, int32_t y, int32_t w, int32_t h)
 Creates a DsPoint object initialized to (x, y, w, h).
 
 DsRect (const DsPoint &pos, const DsSize &size)
 Creates a DsPoint object initialized to (x, y, w, h).
 
DsPoint getPosition (void) const
 Gets the position of the rectangle (top left corner).
 
void setPosition (const DsPoint &pos)
 Sets the position of the rectangle (top left corner).
 
void setPosition (const DsFPoint &pos)
 Sets the position of the rectangle (top left corner).
 
DsSize getSize (void) const
 Gets the size of the rectangle.
 
void setSize (const DsSize &size)
 Sets the size of the rectangle.
 
DsFPoint getCenter (void) const
 Gets the position of the center of the rectangle.
 
uint32_t area (void) const
 Gets the area of rectangle.
 
bool contains (const DsPoint &p) const
 Does the rectangle contain a specific point?
 
DsRect intersect (const DsRect &r) const
 Gets the intersection rectangle of the current DsRect object with another rectangle.
 
DsRectmove (const DsPoint &offset)
 Moves the current DsRect object by a specified 2D offset.
 
DsFRect move (const DsFPoint &offset) override final
 Moves the current DsRect object by a specified 2D offset.
 
DsRectcat (const DsRect &r)
 Concatenates the current DsRect object with another rectangle.
 
DsRect erode (uint32_t size) const
 Erodes the current DsRect object by a specific size.
 
DsRect erodeHorizontal (uint32_t size) const
 Erodes the current DsRect object by a specific size in the horizontal direction.
 
DsRect erodeLeft (uint32_t size) const
 Erodes the current DsRect object by a specific size on the left side only.
 
DsRect erodeRight (uint32_t size) const
 Erodes the current DsRect object by a specific size on the right side only.
 
DsRect erodeVertical (uint32_t size) const
 Erodes the current DsRect object by a specific size in the vertical direction only.
 
DsRect erodeTop (uint32_t size) const
 Erodes the current DsRect object by a specific size on the top side only.
 
DsRect erodeBottom (uint32_t size) const
 Erodes the current DsRect object by a specific size on the bottom side only.
 
DsRect dilate (uint32_t size)
 Dilates the current DsRect object by a specific size.
 
DsRect dilateTop (uint32_t size)
 Dilates the current DsRect object by a specific size on the top side only.
 
DsRect dilateBotom (uint32_t size)
 Dilates the current DsRect object by a specific size on the bottom side only.
 
DsRect dilateLeft (uint32_t size)
 Dilates the current DsRect object by a specific size on the left side only.
 
DsRect dilateRight (uint32_t size)
 Dilates the current DsRect object by a specific size on the right side only.
 
DsRect getLeftRegion (int32_t split_line)
 Splits the rectangle in two using a vertical line and returns the left rectangle.
 
DsRect getRightRegion (int32_t split_line)
 Splits the rectangle in two using a vertical line and returns the right rectangle.
 
DsRect getTopRegion (int32_t split_line)
 Splits the rectangle in two using a horizontal line and returns the top rectangle.
 
DsRect getBottomRegion (int32_t split_line)
 Splits the rectangle in two using a horizontal line and returns the bottom rectangle.
 
DsRectalign (const DsRect &boundary, const DsAlignment &alignment, const DsPoint &offset=DsPoint())
 Changes the X and Y components of the current rectangle to align it in the specified parent rectangle.
 
pair< float, float > getVerticalRange (float x) const override final
 
pair< float, float > getHorizontalRange (float y) const override final
 
DsFRect getRect (void) const override final
 
void rotate (const DsSurface &surface) override final
 

Public Attributes

int32_t x
 X coordinate of the top left corner.
 
int32_t y
 Y coordinate of the top left corner.
 
int32_t w
 Width of the rectangle in pixels.
 
int32_t h
 Height of the rectangle in pixels.
 

Friends

DsRect operator+ (const DsRect &lhs, const DsRect &rhs)
 Addition operator - concatenates two DsRect objects.
 

Detailed Description

DsRect is a class that represents a 2D rectangle (X, Y, W, H)

Constructor & Destructor Documentation

◆ DsRect() [1/2]

DsRect::DsRect ( int32_t  x,
int32_t  y,
int32_t  w,
int32_t  h 
)
inline

Creates a DsPoint object initialized to (x, y, w, h).

Parameters
xX coordinate of the top left corner
yY coordinate of the top left corner
wRectangle width
hRectangle height

◆ DsRect() [2/2]

DsRect::DsRect ( const DsPoint pos,
const DsSize size 
)
inline

Creates a DsPoint object initialized to (x, y, w, h).

Parameters
posPosition of the top left corner
sizeRectangle size

Member Function Documentation

◆ align()

DsRect & DsRect::align ( const DsRect boundary,
const DsAlignment alignment,
const DsPoint offset = DsPoint() 
)
inline

Changes the X and Y components of the current rectangle to align it in the specified parent rectangle.

Parameters
boundaryThe boundary rectangle
alignmentAlignment mode
offsetOffset to apply to the aligned rectangle
Returns
Reference to the DsRect object

◆ area()

uint32_t DsRect::area ( void  ) const
inline

Gets the area of rectangle.

Returns
Rectangle area

◆ cat()

DsRect & DsRect::cat ( const DsRect r)
inline

Concatenates the current DsRect object with another rectangle.

Parameters
rRectangle to concatenate with the current DsRect object
Returns
Reference to the current DsRect object

◆ contains()

bool DsRect::contains ( const DsPoint p) const
inline

Does the rectangle contain a specific point?

Parameters
pPoint to check if it's inside the rectangle
Returns
True if the rectangle contains the specified point

◆ dilate()

DsRect DsRect::dilate ( uint32_t  size)
inline

Dilates the current DsRect object by a specific size.

Parameters
sizeThe size to dilate the current DsRect by
Returns
New DsRect object

◆ dilateBotom()

DsRect DsRect::dilateBotom ( uint32_t  size)
inline

Dilates the current DsRect object by a specific size on the bottom side only.

Parameters
sizeThe size to dilate the current DsRect by
Returns
New DsRect object

◆ dilateLeft()

DsRect DsRect::dilateLeft ( uint32_t  size)
inline

Dilates the current DsRect object by a specific size on the left side only.

Parameters
sizeThe size to dilate the current DsRect by
Returns
New DsRect object

◆ dilateRight()

DsRect DsRect::dilateRight ( uint32_t  size)
inline

Dilates the current DsRect object by a specific size on the right side only.

Parameters
sizeThe size to dilate the current DsRect by
Returns
New DsRect object

◆ dilateTop()

DsRect DsRect::dilateTop ( uint32_t  size)
inline

Dilates the current DsRect object by a specific size on the top side only.

Parameters
sizeThe size to dilate the current DsRect by
Returns
New DsRect object

◆ erode()

DsRect DsRect::erode ( uint32_t  size) const
inline

Erodes the current DsRect object by a specific size.

Parameters
sizeThe size to erode the current DsRect by
Returns
New DsRect object

◆ erodeBottom()

DsRect DsRect::erodeBottom ( uint32_t  size) const
inline

Erodes the current DsRect object by a specific size on the bottom side only.

Parameters
sizeThe size to erode the current DsRect by
Returns
New DsRect object

◆ erodeHorizontal()

DsRect DsRect::erodeHorizontal ( uint32_t  size) const
inline

Erodes the current DsRect object by a specific size in the horizontal direction.

Parameters
sizeThe size to erode the current DsRect by
Returns
New DsRect object

◆ erodeLeft()

DsRect DsRect::erodeLeft ( uint32_t  size) const
inline

Erodes the current DsRect object by a specific size on the left side only.

Parameters
sizeThe size to erode the current DsRect by
Returns
New DsRect object

◆ erodeRight()

DsRect DsRect::erodeRight ( uint32_t  size) const
inline

Erodes the current DsRect object by a specific size on the right side only.

Parameters
sizeThe size to erode the current DsRect by
Returns
New DsRect object

◆ erodeTop()

DsRect DsRect::erodeTop ( uint32_t  size) const
inline

Erodes the current DsRect object by a specific size on the top side only.

Parameters
sizeThe size to erode the current DsRect by
Returns
New DsRect object

◆ erodeVertical()

DsRect DsRect::erodeVertical ( uint32_t  size) const
inline

Erodes the current DsRect object by a specific size in the vertical direction only.

Parameters
sizeThe size to erode the current DsRect by
Returns
New DsRect object

◆ getBottomRegion()

DsRect DsRect::getBottomRegion ( int32_t  split_line)
inline

Splits the rectangle in two using a horizontal line and returns the bottom rectangle.

Parameters
split_lineThe Y coordinate of the split line
Returns
Bottom side DsRect object

◆ getCenter()

DsFPoint DsRect::getCenter ( void  ) const
inline

Gets the position of the center of the rectangle.

Returns
Center position

◆ getHorizontalRange()

pair< float, float > DsRect::getHorizontalRange ( float  y) const
finaloverridevirtual

Implements DsRegion.

◆ getLeftRegion()

DsRect DsRect::getLeftRegion ( int32_t  split_line)
inline

Splits the rectangle in two using a vertical line and returns the left rectangle.

Parameters
split_lineThe X coordinate of the split line
Returns
Left side DsRect object

◆ getPosition()

DsPoint DsRect::getPosition ( void  ) const
inline

Gets the position of the rectangle (top left corner).

Returns
Top left corner position

◆ getRect()

DsFRect DsRect::getRect ( void  ) const
finaloverridevirtual

Implements DsRegion.

◆ getRightRegion()

DsRect DsRect::getRightRegion ( int32_t  split_line)
inline

Splits the rectangle in two using a vertical line and returns the right rectangle.

Parameters
split_lineThe X coordinate of the split line
Returns
Right side DsRect object

◆ getSize()

DsSize DsRect::getSize ( void  ) const
inline

Gets the size of the rectangle.

Returns
Rectangle size

◆ getTopRegion()

DsRect DsRect::getTopRegion ( int32_t  split_line)
inline

Splits the rectangle in two using a horizontal line and returns the top rectangle.

Parameters
split_lineThe Y coordinate of the split line
Returns
Top side DsRect object

◆ getVerticalRange()

pair< float, float > DsRect::getVerticalRange ( float  x) const
finaloverridevirtual

Implements DsRegion.

◆ intersect()

DsRect DsRect::intersect ( const DsRect r) const
inline

Gets the intersection rectangle of the current DsRect object with another rectangle.

Parameters
rRectangle to intersect with the current DsRect object
Returns
The intersection of the current DsRect object with r

◆ move() [1/2]

DsFRect DsRect::move ( const DsFPoint offset)
finaloverridevirtual

Moves the current DsRect object by a specified 2D offset.

Parameters
offsetOffset (x, y)

Implements DsRegion.

◆ move() [2/2]

DsRect & DsRect::move ( const DsPoint offset)
inline

Moves the current DsRect object by a specified 2D offset.

Parameters
offsetOffset (x, y)
Returns
Reference to the current DsRect object

◆ rotate()

void DsRect::rotate ( const DsSurface surface)
finaloverridevirtual

Implements DsRegion.

◆ setPosition() [1/2]

void DsRect::setPosition ( const DsFPoint pos)
inline

Sets the position of the rectangle (top left corner).

Parameters
posTop left corner position

◆ setPosition() [2/2]

void DsRect::setPosition ( const DsPoint pos)
inline

Sets the position of the rectangle (top left corner).

Parameters
posTop left corner position

◆ setSize()

void DsRect::setSize ( const DsSize size)
inline

Sets the size of the rectangle.

Parameters
sizeRectangle size

Friends And Related Symbol Documentation

◆ operator+

DsRect operator+ ( const DsRect lhs,
const DsRect rhs 
)
friend

Addition operator - concatenates two DsRect objects.

Parameters
lhsLeft hand side DsRect object
rhsRight hand side DsRect object
Returns
Concatenated rectangles

The documentation for this class was generated from the following file: