Axis-aligned rectangle defined by an anchor point and size.
More...
#include <spk_extend_2d.hpp>
|
|
using | Anchor = spk::Vector2Int |
| | Position of the rectangle, expressed as its top-left corner.
|
|
using | Size = spk::Vector2UInt |
| | Width and height of the rectangle.
|
|
|
| Extend2D () |
| | Builds a zero-sized rectangle at the origin.
|
| | Extend2D (const Vector2Int &p_anchor, const Vector2UInt &p_size) |
| | Builds a rectangle from anchor and size vectors.
|
| | Extend2D (const Vector2Int &p_anchor, size_t p_width, size_t p_height) |
| | Builds a rectangle from anchor and explicit dimensions.
|
| | Extend2D (int p_x, int p_y, const Vector2UInt &p_size) |
| | Builds a rectangle from coordinates and size vector.
|
| | Extend2D (int p_x, int p_y, size_t p_width, size_t p_height) |
| | Builds a rectangle from coordinates and explicit dimensions.
|
| Extend2D | atOrigin () const |
| | Returns a copy translated to the origin.
|
| bool | contains (const Vector2Int &p_point) const |
| | Tests whether a point lies within the rectangle bounds.
|
| Extend2D | shrink (const Vector2Int &p_offset) const |
| | Returns a rectangle shrunk by the provided offset on each side.
|
| Extend2D | intersect (const Extend2D &p_other) const |
| | Computes the intersection of two rectangles.
|
| Extend2D | operator+ (const Extend2D &p_other) const |
| | Translates the rectangle by another rectangle's anchor.
|
| Extend2D | operator- (const Extend2D &p_other) const |
| | Translates the rectangle negatively by another rectangle's anchor.
|
| Extend2D & | operator+= (const Extend2D &p_other) |
| | In-place translation by another rectangle's anchor.
|
| Extend2D & | operator-= (const Extend2D &p_other) |
| | In-place negative translation by another rectangle's anchor.
|
| std::string | toString () const |
| | Converts the rectangle to a readable string.
|
| std::wstring | toWstring () const |
| | Converts the rectangle to a wide string.
|
| bool | operator== (const Extend2D &p_other) const |
| | Equality comparison between rectangles.
|
| bool | operator!= (const Extend2D &p_other) const |
| | Inequality comparison between rectangles.
|
|
| std::ostream & | operator<< (std::ostream &p_stream, const Extend2D &p_extend) |
| | Streams a rectangle to an output stream.
|
| std::wostream & | operator<< (std::wostream &p_stream, const Extend2D &p_extend) |
| | Streams a rectangle to a wide output stream.
|
Axis-aligned rectangle defined by an anchor point and size.
- See also
- spk::Vector2Int, spk::Vector2UInt
{
}
Axis-aligned rectangle defined by an anchor point and size.
Definition spk_extend_2d.hpp:24
bool contains(const Vector2Int &p_point) const
Tests whether a point lies within the rectangle bounds.
Definition spk_extend_2d.cpp:43
◆ Extend2D() [1/4]
Builds a rectangle from anchor and size vectors.
- Parameters
-
| p_anchor | Top-left position. |
| p_size | Width and height. |
◆ Extend2D() [2/4]
| spk::Extend2D::Extend2D |
( |
const Vector2Int & | p_anchor, |
|
|
size_t | p_width, |
|
|
size_t | p_height ) |
Builds a rectangle from anchor and explicit dimensions.
- Parameters
-
| p_anchor | Top-left position. |
| p_width | Rectangle width. |
| p_height | Rectangle height. |
◆ Extend2D() [3/4]
| spk::Extend2D::Extend2D |
( |
int | p_x, |
|
|
int | p_y, |
|
|
const Vector2UInt & | p_size ) |
Builds a rectangle from coordinates and size vector.
- Parameters
-
| p_x | Anchor x coordinate. |
| p_y | Anchor y coordinate. |
| p_size | Width and height. |
◆ Extend2D() [4/4]
| spk::Extend2D::Extend2D |
( |
int | p_x, |
|
|
int | p_y, |
|
|
size_t | p_width, |
|
|
size_t | p_height ) |
Builds a rectangle from coordinates and explicit dimensions.
- Parameters
-
| p_x | Anchor x coordinate. |
| p_y | Anchor y coordinate. |
| p_width | Rectangle width. |
| p_height | Rectangle height. |
◆ atOrigin()
| Extend2D spk::Extend2D::atOrigin |
( |
| ) |
const |
Returns a copy translated to the origin.
- Returns
- Rectangle anchored at (0,0).
◆ contains()
| bool spk::Extend2D::contains |
( |
const Vector2Int & | p_point | ) |
const |
Tests whether a point lies within the rectangle bounds.
- Parameters
-
- Returns
- true when the point is inside or on the edges.
◆ intersect()
Computes the intersection of two rectangles.
- Parameters
-
| p_other | Rectangle to intersect with. |
- Returns
- Overlapping rectangle (may be empty).
◆ operator!=()
| bool spk::Extend2D::operator!= |
( |
const Extend2D & | p_other | ) |
const |
Inequality comparison between rectangles.
- Parameters
-
| p_other | Rectangle to compare. |
- Returns
- true when anchor or size differ.
◆ operator+()
Translates the rectangle by another rectangle's anchor.
- Parameters
-
| p_other | Rectangle providing offset and size delta. |
- Returns
- Translated rectangle.
◆ operator+=()
In-place translation by another rectangle's anchor.
- Parameters
-
| p_other | Rectangle providing offset and size delta. |
- Returns
- Reference to this rectangle.
◆ operator-()
Translates the rectangle negatively by another rectangle's anchor.
- Parameters
-
| p_other | Rectangle providing offset and size delta. |
- Returns
- Translated rectangle.
◆ operator-=()
In-place negative translation by another rectangle's anchor.
- Parameters
-
| p_other | Rectangle providing offset and size delta. |
- Returns
- Reference to this rectangle.
◆ operator==()
| bool spk::Extend2D::operator== |
( |
const Extend2D & | p_other | ) |
const |
Equality comparison between rectangles.
- Parameters
-
| p_other | Rectangle to compare. |
- Returns
- true when anchor and size match.
◆ shrink()
Returns a rectangle shrunk by the provided offset on each side.
- Parameters
-
| p_offset | Offset to subtract from anchor and size. |
- Returns
- Shrunk rectangle.
◆ toString()
| std::string spk::Extend2D::toString |
( |
| ) |
const |
Converts the rectangle to a readable string.
- Returns
- UTF-8 string representation.
◆ toWstring()
| std::wstring spk::Extend2D::toWstring |
( |
| ) |
const |
Converts the rectangle to a wide string.
- Returns
- UTF-16/32 string representation.
◆ operator<< [1/2]
| std::ostream & operator<< |
( |
std::ostream & | p_stream, |
|
|
const Extend2D & | p_extend ) |
|
friend |
Streams a rectangle to an output stream.
- Parameters
-
| p_stream | Output stream. |
| p_extend | Rectangle to print. |
- Returns
- Reference to the stream.
◆ operator<< [2/2]
| std::wostream & operator<< |
( |
std::wostream & | p_stream, |
|
|
const Extend2D & | p_extend ) |
|
friend |
Streams a rectangle to a wide output stream.
- Parameters
-
| p_stream | Output stream. |
| p_extend | Rectangle to print. |
- Returns
- Reference to the stream.
The documentation for this struct was generated from the following files:
- includes/structure/graphics/spk_extend_2d.hpp
- srcs/structure/graphics/spk_extend_2d.cpp