Structure describing an integer precision 2D rectangle. More...
Public Member Functions | |
int32_t | GetWidth (void) const noexcept |
Return the width of a rectangle. | |
int32_t | GetHeight (void) const noexcept |
Return the height of a rectangle. | |
int32_t | GetLeft (void) const noexcept |
Return the leftmost X value of a rectangle. | |
int32_t | GetTop (void) const noexcept |
Return the topmost Y value of a rectangle. | |
int32_t | GetRight (void) const noexcept |
Return the rightmost X value of a rectangle. | |
int32_t | GetBottom (void) const noexcept |
Return the bottommost Y value of a rectangle. | |
void | SetWidth (int32_t iWidth) noexcept |
Set the width of a rectangle. | |
void | SetHeight (int32_t iHeight) noexcept |
Set the height of a rectangle. | |
void | SetSize (int32_t iWidth, int32_t iHeight) noexcept |
Set the size of a rectangle. | |
void | SetLeft (int32_t iLeft) noexcept |
Set the left most X coordinate of a rectangle. | |
void | SetTop (int32_t iTop) noexcept |
Set the top most Y coordinate of a rectangle. | |
void | SetRight (int32_t iRight) noexcept |
Set the right most X coordinate of a rectangle. | |
void | SetBottom (int32_t iBottom) noexcept |
Set the bottom most Y coordinate of a rectangle. | |
void | Set (int32_t iLeft, int32_t iTop, int32_t iRight, int32_t iBottom) noexcept |
Set all four coordinates of a rectangle. | |
void | SetBySize (int32_t iLeft, int32_t iTop, int32_t iWidth, int32_t iHeight) noexcept |
Set all four coordinates of a rectangle using upper left corner and width and height. | |
void | Clear (void) noexcept |
Set all four coordinates of a rectangle to zero. | |
void | Offset (int32_t iX, int32_t iY) noexcept |
Adjust all four coordinates by a horizontal and vertical offset. | |
int32_t | CenterX (void) const noexcept |
Find and return the center x position of a rect. | |
int32_t | CenterY (void) const noexcept |
Find and return the center y position of a rect. | |
void | GetCenter (int32_t *pX, int32_t *pY) const noexcept |
Find and return the center position of a rect. | |
void | GetCenter (Point2D_t *pOutput) const noexcept |
Find and return the center position of a rect. | |
void | MoveTo (int32_t iX, int32_t iY) noexcept |
Move a rectangle to a new location. | |
void | MoveTo (const Point2D_t *pInput) noexcept |
Move a rectangle to a new location. | |
void | MoveX (int32_t iX) noexcept |
Move a rectangle to a specific x coordinate. | |
void | MoveY (int32_t iY) noexcept |
Move a rectangle to a specific y coordinate. | |
void | MoveWithinRect (const Rect_t *pInput) noexcept |
Move a rect so that it is encompassed by a larger rect. | |
void | CenterAroundX (int32_t iX) noexcept |
Move a rect around a center X. | |
void | CenterAroundX (const Point2D_t *pInput) noexcept |
Move a rect around a center X. | |
void | CenterAroundX (const Rect_t *pInput) noexcept |
Move a rect around a center X of an input rectangle. | |
void | CenterAroundY (int32_t iY) noexcept |
Move a rect around a center Y. | |
void | CenterAroundY (const Point2D_t *pInput) noexcept |
Move a rect around a center Y. | |
void | CenterAroundY (const Rect_t *pInput) noexcept |
Move a rect around a center Y of an input rectangle. | |
void | CenterAround (int32_t iX, int32_t iY) noexcept |
Move a rect around a center point. | |
void | CenterAround (const Point2D_t *pInput) noexcept |
Move a rect around a center point. | |
void | CenterAround (const Rect_t *pInput) noexcept |
Move a rect around a center point of another rectangle. | |
uint_t | IsInside (int32_t iX, int32_t iY) const noexcept |
Return TRUE if the X and Y coordinates are inside of a rectangle. | |
uint_t | IsInside (const Point2D_t *pPoint) const noexcept |
Return TRUE if the Point2D_t is inside of a rectangle. | |
uint_t | IsInside (const Rect_t *pRect) const noexcept |
Return TRUE if the input rectangle is completely inside of the rectangle. | |
void | Sort (void) noexcept |
Ensure that the rectangle is sorted. | |
void | SetSorted (int32_t iLeft, int32_t iTop, int32_t iRight, int32_t iBottom) noexcept |
Set all four coordinates of a rectangle and ensure they are sorted. | |
uint_t | IsEmpty (void) const noexcept |
Return TRUE if the rect is empty. | |
uint_t | IsNotEmpty (void) const noexcept |
Return TRUE if the rect is not empty. | |
uint_t | IsEqual (const Rect_t *pInput) const noexcept |
Return TRUE if the two rectangles are equal. | |
uint_t | IsNotEqual (const Rect_t *pInput) const noexcept |
Return TRUE if the two rectangles are not equal. | |
uint_t | operator== (const Rect_t &rInput) const noexcept |
Return TRUE if the two rectangles are equal. | |
uint_t | operator!= (const Rect_t &rInput) const noexcept |
Return TRUE if the two rectangles are not equal. | |
void | Inset (int32_t iX, int32_t iY) noexcept |
Shrink or expand a rect by a specific number of units. | |
uint_t | IsIntersecting (const Rect_t *pInput) const noexcept |
Return TRUE if the two rectangles intersect. | |
uint_t | Intersection (const Rect_t *pInput1, const Rect_t *pInput2) noexcept |
Create the intersection of two rectangles. | |
void | Union (const Rect_t *pInput1, const Rect_t *pInput2) noexcept |
Generate the union between two rects. | |
void | Add (const Point2D_t *pInput) noexcept |
Expand a rectangle to encompass a new point. | |
void | Add (int32_t iX, int32_t iY) noexcept |
Expand a rectangle to encompass a new point. | |
void | Clip (const Rect_t *pInput) noexcept |
Clip a rectangle to a bounds rectangle. | |
void | Get (Rect *pOutput) const noexcept |
Convert a Rect_t into a MacOS Rect structure. | |
void | Set (const Rect *pInput) noexcept |
Convert a MacOS Rect structure into a Rect_t. | |
void | Get (CGRect *pOutput) const noexcept |
Convert a Rect_t into a MacOSX/iOS CGRect structure. | |
void | Set (const CGRect *pInput) noexcept |
Convert a CGRect structure into a Rect_t. | |
void | Get (_NSRect *pOutput) const noexcept |
Convert a Rect_t into a MacOS _NSRect structure. | |
void | Set (const _NSRect *pInput) noexcept |
Convert a CGRect Rect structure into a Rect_t. | |
void | Get (tagRECT *pOutput) const noexcept |
Convert a Rect_t into a Windows RECT structure. | |
void | Set (const tagRECT *pInput) noexcept |
Convert a Windows RECT structure into a Rect_t. | |
Public Attributes | |
int32_t | m_iLeft |
Leftmost x of rectangle. | |
int32_t | m_iTop |
Topmost y of rectangle. | |
int32_t | m_iRight |
Rightmost x of rectangle. | |
int32_t | m_iBottom |
Bottommost y of rectangle. | |
Structure describing an integer precision 2D rectangle.
Simple container structure that holds the upper left and lower right coordinates in integer precision.
|
noexcept |
Expand a rectangle to encompass a new point.
If a passed point is outside of the bounds of the current rect, expand the rectangle to contain the point.
If the rectangle is empty, initialize the rectangle to encompass only the point with a width and height of one.
pInput | Pointer to a valid Point2D_t structure |
|
noexcept |
Expand a rectangle to encompass a new point.
If a passed point is outside of the bounds of the current rect, expand the rectangle to contain the point.
If the rectangle is empty, initialize the rectangle to encompass only the point with a width and height of one.
iX | X coordinate of the new point to add |
iY | Y coordinate of the new point to add |
|
noexcept |
Move a rect around a center point.
Given a central location, move the rectangle so that point represents the new center of the rectangle.
pInput | Coordinates of the center point |
|
noexcept |
Move a rect around a center point of another rectangle.
Using the central point of the input rectangle, move the current rectangle so that point represents the new center of the rectangle.
pInput | Rectangle whose center will be the center of this rectangle. |
|
noexcept |
Move a rect around a center point.
Given a central location, move the rectangle so that point represents the new center of the rectangle.
iX | X coordinate of the center point |
iY | Y coordinate of the center point |
|
noexcept |
Move a rect around a center X.
Given a central X coordinate, move the rectangle so that X coordinate represents the new X center of the rectangle. The top and bottom values are not modified.
pInput | Pointer to a point to obtain the X center coordinate. |
|
noexcept |
Move a rect around a center X of an input rectangle.
Given a rectangle, determine the central X coordinate, and then move the rectangle so that X coordinate represents the new X center of the rectangle. The top and bottom values are not modified.
pInput | Pointer to a rectangle to obtain the center X. |
|
noexcept |
Move a rect around a center X.
Given a central X coordinate, move the rectangle so that X coordinate represents the new X center of the rectangle. The top and bottom values are not modified.
iX | X coordinate of the center point |
|
noexcept |
Move a rect around a center Y.
Given a central Y coordinate, move the rectangle so that Y coordinate represents the new Y center of the rectangle. The left and right values are not modified.
pInput | Pointer to a point to obtain the Y center coordinate. |
|
noexcept |
Move a rect around a center Y of an input rectangle.
Given a rectangle, determine the central Y coordinate, and then move the rectangle so that Y coordinate represents the new Y center of the rectangle. The left and right values are not modified.
pInput | Pointer to a rectangle to obtain the center Y. |
|
noexcept |
Move a rect around a center Y.
Given a central Y coordinate, move the rectangle so that Y coordinate represents the new Y center of the rectangle. The left and right values are not modified.
iY | Y coordinate of the center point |
|
noexcept |
Find and return the center x position of a rect.
Use this form instead of (left+right)>>1 since it prevents overflow errors
|
noexcept |
Find and return the center y position of a rect.
Use this form instead of (top+bottom)>>1 since it prevents overflow errors
|
inlinenoexcept |
Set all four coordinates of a rectangle to zero.
Initializes a Burger::Rect_t to an empty rectangle.
|
noexcept |
Clip a rectangle to a bounds rectangle.
Clip the rectangle to the boundaries set by the input rectangle. If this rectangle is outside of the boundaries, set it to an empty rectangle with all entries being set to zero.
pInput | Pointer to a valid boundary rectangle |
|
noexcept |
|
noexcept |
|
noexcept |
Convert a Rect_t into a MacOS Rect structure.
Converts the contents of a Rect_t into a MacOS/Quicktime for Windows Rect structure. Since it's converting an int32_t into a short, data loss could occur if the values exceed 32767 or are less than -32768.
|
noexcept |
|
inlinenoexcept |
Return the bottommost Y value of a rectangle.
Return the bottom most value of the rectangle
|
noexcept |
Find and return the center position of a rect.
Use this form instead of (left+right)>>1 since it prevents overflow errors
pX | Pointer to int32_t to receive the center X |
pY | Pointer to int32_t to receive the center Y |
|
noexcept |
Find and return the center position of a rect.
Use this form instead of (left+right)>>1 since it prevents overflow errors
pOutput | Pointer to Point2D_t to receive the center |
|
inlinenoexcept |
Return the height of a rectangle.
Subtract the bottom value from the top value and returns the difference in the form of the rectangle's height.
|
inlinenoexcept |
Return the leftmost X value of a rectangle.
Return the left most value of the rectangle
|
inlinenoexcept |
Return the rightmost X value of a rectangle.
Return the right most value of the rectangle
|
inlinenoexcept |
Return the topmost Y value of a rectangle.
Return the top most value of the rectangle
|
inlinenoexcept |
Return the width of a rectangle.
Subtract the right value from the left value and returns the difference in the form of the rectangle's width.
|
noexcept |
Shrink or expand a rect by a specific number of units.
If positive offsets are given, the rectangle is shrunk by the number of units. The rectangle is grown if the offsets are negative values. the coordinates are sorted after adjustment.
iX | Number of units to shrink the rectangle horizontally |
iY | Number of units to shrink the rectangle vertically |
Create the intersection of two rectangles.
Create the intersection of two rects and return TRUE if they truly intersect.
pInput1 | Pointer to the first valid Rect_t structure |
pInput2 | Pointer to the second valid Rect_t structure |
|
noexcept |
Return TRUE if the rect is empty.
If either the horizontal or vertical coordinates are equal, this will be considered an empty rectangle.
Return TRUE if the Point2D_t is inside of a rectangle.
Given an X and Y coordinate inside of a Point2D_t, determine if it is inside of a rect if so, then return TRUE, otherwise, return FALSE.
Determination of whether a point is inside is that the value must be greater than or equal to the minimum and less than the maximum. If the rectangle has a width or height of zero or less, then this function always returns FALSE
pPoint | Pointer to a valid Point2D_t structure. |
|
noexcept |
Return TRUE if the X and Y coordinates are inside of a rectangle.
Given an X and Y coordinate, determine if it is inside of a rect if so, then return TRUE, otherwise, return FALSE.
Determination of whether a point is inside is that the value must be greater than or equal to the minimum and less than the maximum. If the rectangle has a width or height of zero or less, then this function always returns FALSE
iX | X coordinate to test |
iY | Y coordinate to test |
|
noexcept |
|
noexcept |
Move a rectangle to a new location.
Given an x,y point, "move" the rectangle so that bottom right corner maintains the same offset (Width/Height) from the new origin point as the previous origin point
pInput | Pointer to a valid Point2D_t structure. |
|
noexcept |
Move a rectangle to a new location.
Given an x,y point, "move" the rectangle so that bottom right corner maintains the same offset (Width/Height) from the new origin point as the previous origin point
iX | New upper left X coordinate |
iY | New upper top Y coordinate |
|
noexcept |
Move a rect so that it is encompassed by a larger rect.
Favor bounding to the top-leftmost edge in the case that the bounds rect cannot fit the rect in question.
pInput | Pointer to a valid boundary rectangle |
|
noexcept |
Move a rectangle to a specific x coordinate.
iX | New upper left X coordinate |
|
noexcept |
Move a rectangle to a specific y coordinate.
iY | New upper top Y coordinate |
|
inlinenoexcept |
Adjust all four coordinates by a horizontal and vertical offset.
Given a new X and Y offset value, adjust the location of the entire rectangle by the X and Y offsets. This is performed by addition of the offsets. No bounds checking is performed, so the rectangle could "wrap around"
iX | Number of units to add to the left and right coordinates |
iY | Number of units to add to the top and bottom coordinates |
|
noexcept |
Convert a CGRect Rect structure into a Rect_t.
Converts the contents of a MacOSX CGRect structure into a Rect_t. Since it's converting a float or double into an int, data loss could occur.
pInput | Pointer to a valid MacOSX _NSRect structure. |
|
noexcept |
|
noexcept |
|
noexcept |
|
inlinenoexcept |
Set all four coordinates of a rectangle.
Sets the left, top, right and bottom coordinates of the rectangle to specific values. No bounds checking is performed to prevent unsorted rectangles.
iLeft | Requested left most X coordinate of the rectangle. |
iTop | Requested top most Y coordinate of the rectangle. |
iRight | Requested right most X coordinate of the rectangle. |
iBottom | Requested bottom most Y coordinate of the rectangle. |
|
inlinenoexcept |
Set the bottom most Y coordinate of a rectangle.
Set the bottom most Y coordinate to a specific value. No bounds checking is performed to prevent unsorted rectangles.
iBottom | Requested bottom most Y coordinate of the rectangle. |
|
inlinenoexcept |
Set all four coordinates of a rectangle using upper left corner and width and height.
Sets the left, top, right and bottom coordinates of the rectangle to using iLeft and iTop as the upper left anchor point and iWidth and iHeight to determine what the new bottom right coordinate should be. No bounds checking is performed to prevent unsorted rectangles, espectially in the cases of negative width or height.
iLeft | Requested left most X coordinate of the rectangle. |
iTop | Requested top most Y coordinate of the rectangle. |
iWidth | Requested width of the rectangle. |
iHeight | Requested height of the rectangle. |
|
inlinenoexcept |
Set the height of a rectangle.
Set the bottom most Y coordinate so the rectangle will be the requested height. No bounds checking is performed, so unsorted rectangles are possible on overflow or underflow input.
iHeight | Requested height of the rectangle. |
|
inlinenoexcept |
Set the left most X coordinate of a rectangle.
Set the left most X coordinate to a specific value. No bounds checking is performed to prevent unsorted rectangles.
iLeft | Requested left most X coordinate of the rectangle. |
|
inlinenoexcept |
Set the right most X coordinate of a rectangle.
Set the right most X coordinate to a specific value. No bounds checking is performed to prevent unsorted rectangles.
iRight | Requested right most X coordinate of the rectangle. |
|
inlinenoexcept |
Set the size of a rectangle.
Set the right most X coordinate and the bottom most Y coordinate so the rectangle will be the requested width and height. No bounds checking is performed, so unsorted rectangles are possible on overflow or underflow input.
iWidth | Requested width of the rectangle. |
iHeight | Requested height of the rectangle. |
|
noexcept |
Set all four coordinates of a rectangle and ensure they are sorted.
Sets the left, top, right and bottom coordinates of the rectangle to specific values. The Left and Right are sorted so that the Left side is less than or equal to the Right and the Top and Bottom sides are sorted as well.
Due to the sorting, there is a slight performance penalty to perform the tests. If it's known in advance that the coordinates are sorted, use Set(int32_t,int32_t,int32_t,int32_t) instead.
iLeft | First X coordinate of the rectangle. |
iTop | First Y coordinate of the rectangle. |
iRight | Second X coordinate of the rectangle. |
iBottom | Second Y coordinate of the rectangle. |
|
inlinenoexcept |
Set the top most Y coordinate of a rectangle.
Set the top most X coordinate to a specific value. No bounds checking is performed to prevent unsorted rectangles.
iTop | Requested top most Y coordinate of the rectangle. |
|
inlinenoexcept |
Set the width of a rectangle.
Set the right most X coordinate so the rectangle will be the requested width. No bounds checking is performed, so unsorted rectangles are possible on overflow or underflow input.
iWidth | Requested width of the rectangle. |
|
noexcept |
Ensure that the rectangle is sorted.
If a rectangle is sorted (Left<=Right and Top<=Bottom) this function does nothing. Otherwise, the Left and Right entries and the Top and Bottom entries are sorted so they pass the above test. This will fix any rectangle that may have reveresed entries.
Generate the union between two rects.
Create a rectangle that will encompass both input retangles
pInput1 | Pointer to the first non-empty rectangle |
pInput2 | Pointer to the second non-empt rectangle |
int32_t Burger::Rect_t::m_iBottom |
Bottommost y of rectangle.
int32_t Burger::Rect_t::m_iLeft |
Leftmost x of rectangle.
int32_t Burger::Rect_t::m_iRight |
Rightmost x of rectangle.
int32_t Burger::Rect_t::m_iTop |
Topmost y of rectangle.