![]() |
1.11 |
A rectangle with a point and a size. More...
#include <geometry.h>
Public Types | |
using | DimType = Dim |
Helper to reference the dimension type. | |
Public Member Functions | |
constexpr | RectType () noexcept=default |
constexpr | RectType (const PointType< Dim > &point, const SizeType< Dim, DimCompat > &size) noexcept |
Construct a rectangle with an explicit point and size. | |
template<typename Dim2 > | |
constexpr | RectType (const RectType< Dim2 > &r) |
constexpr | RectType (const SizeType< Dim, DimCompat > &size) noexcept |
Construct a rectangle with the specified size and the point being at the default origin 0,0. | |
constexpr | RectType (Dim x, Dim y, Dim width, Dim height) noexcept |
EGT_NODISCARD constexpr Dim | area () const noexcept |
Calculate the area of the rectangle. | |
EGT_NODISCARD constexpr Dim | bottom () const noexcept |
Get the bottom side the rectangle. | |
EGT_NODISCARD constexpr PointType< Dim, DimCompat > | bottom_left () const noexcept |
Get the bottom left point of the rectangle. | |
EGT_NODISCARD constexpr PointType< Dim, DimCompat > | bottom_right () const noexcept |
Get the bottom right point of the rectangle. | |
EGT_NODISCARD constexpr PointType< Dim, DimCompat > | center () const noexcept |
Return the center point of the rectangle. | |
constexpr void | clear () noexcept |
Clear the rectangle by giving it no width or height. | |
EGT_NODISCARD constexpr bool | contains (const RectType &rhs) const noexcept |
Returns true if this rectangle contains the specified one. | |
EGT_NODISCARD constexpr bool | empty () const noexcept |
Returns true if the rectangle has no width or height. | |
constexpr void | grow_around_center (Dim radius) noexcept |
Grow the rectangle around its center by the specified radius. | |
EGT_NODISCARD constexpr Dim | height () const noexcept |
Get the height value. | |
constexpr void | height (Dim height) noexcept |
Set the height value. | |
EGT_NODISCARD constexpr bool | intersect (const PointType< Dim, DimCompat > &point) const noexcept |
Returns true if the specified point is inside the rectangle. | |
EGT_NODISCARD constexpr bool | intersect (const RectType &rect) const noexcept |
Determine if two rectangles intersect, or, overlap. | |
EGT_NODISCARD constexpr Dim | left () const noexcept |
Get the left side the rectangle. | |
constexpr void | move_to_center (const PointType< Dim, DimCompat > ¢er) noexcept |
Move the rectangle's center to the specified point. | |
constexpr RectType & | operator+= (const PointType< Dim, DimCompat > &rhs) noexcept |
RectType operator. | |
constexpr RectType & | operator+= (const SizeType< Dim, DimCompat > &rhs) noexcept |
RectType operator. | |
constexpr RectType & | operator-= (const PointType< Dim, DimCompat > &rhs) noexcept |
RectType operator. | |
constexpr RectType & | operator-= (const SizeType< Dim, DimCompat > &rhs) noexcept |
RectType operator. | |
EGT_NODISCARD constexpr const PointType< Dim, DimCompat > & | point () const noexcept |
Get the PointType of the rectangle. | |
constexpr void | point (const PointType< Dim, DimCompat > &p) noexcept |
Set the rectangle's origin to the specified point. | |
EGT_NODISCARD constexpr Dim | right () const noexcept |
Get the right side the rectangle. | |
constexpr void | shrink_around_center (Dim radius) noexcept |
Shrink the rectangle around its center by the specified radius. | |
EGT_NODISCARD constexpr const SizeType< Dim, DimCompat > & | size () const noexcept |
Get the SizeType of the rectangle. | |
constexpr void | size (const SizeType< Dim, DimCompat > &size) noexcept |
Set the SizeType of the rectangle. | |
EGT_NODISCARD constexpr Dim | top () const noexcept |
Get the top side of the rectangle. | |
EGT_NODISCARD constexpr PointType< Dim, DimCompat > | top_left () const noexcept |
Get the top left point of the rectangle. | |
EGT_NODISCARD constexpr PointType< Dim, DimCompat > | top_right () const noexcept |
Get the top right point of the rectangle. | |
EGT_NODISCARD constexpr Dim | width () const noexcept |
Get the width value. | |
constexpr void | width (Dim width) noexcept |
Set the width value. | |
EGT_NODISCARD constexpr Dim | x () const noexcept |
Get the x value. | |
constexpr void | x (Dim x) noexcept |
Set the x value. | |
EGT_NODISCARD constexpr Dim | y () const noexcept |
Get the y value. | |
constexpr void | y (Dim y) noexcept |
Set the y value. | |
Static Public Member Functions | |
static constexpr RectType | intersection (const RectType &lhs, const RectType &rhs) noexcept |
Return the intersecting rectangle of two rectangles, if any. | |
static constexpr RectType | merge (const RectType &lhs, const RectType &rhs) noexcept |
Merge two rectangles together into one super rectangle that contains them both. | |
Protected Attributes | |
PointType< Dim, DimCompat > | m_origin |
Origin. | |
SizeType< Dim, DimCompat > | m_size |
Size. | |
A rectangle with a point and a size.
Typically Rect, RectF are used as aliases.
All rectangle points are at the top left.
using DimType = Dim |
Helper to reference the dimension type.
|
constexprdefaultnoexcept |
|
inlineexplicitconstexprnoexcept |
Construct a rectangle with an explicit point and size.
|
inlineconstexprnoexcept |
Construct a rectangle with the specified size and the point being at the default origin 0,0.
|
inlineconstexprnoexcept |
x | X origin coordinate. |
y | Y origin coordinate. |
width | Width |
height | Height |
|
inlineconstexpr |
|
inlineconstexprnoexcept |
Calculate the area of the rectangle.
|
inlineconstexprnoexcept |
Get the bottom side the rectangle.
|
inlineconstexprnoexcept |
Get the bottom left point of the rectangle.
|
inlineconstexprnoexcept |
Get the bottom right point of the rectangle.
|
inlineconstexprnoexcept |
Return the center point of the rectangle.
|
inlineconstexprnoexcept |
Clear the rectangle by giving it no width or height.
|
inlineconstexprnoexcept |
Returns true if this rectangle contains the specified one.
This is different than intersect(). The specified rectangle must be completely inside this one.
|
inlineconstexprnoexcept |
Returns true if the rectangle has no width or height.
|
inlineconstexprnoexcept |
Grow the rectangle around its center by the specified radius.
radius | Relative radius to change by. |
|
inlineconstexprnoexcept |
Get the height value.
|
inlineconstexprnoexcept |
Set the height value.
|
inlineconstexprnoexcept |
Returns true if the specified point is inside the rectangle.
point | The point to test. |
left
, right
) half-open interval for the x
coordinate and the [top
, bottom
) half-open interval for the y
coordinate in order to get a consistent implementation for both Rect and RectF.Indeed, if the point and rectangle represent pixels, let's take a rectangle at x=0 with its width=10 for instance, then we expect the pixels of the rectangle first row to have their x
coordinates in the range {0..9}, hence 10-pixel wide, while the next pixel at x=10, the 11th pixel of the row, is outside the rectangle. That is to say, right
= left
+ width
is outside the rectangle.
|
inlineconstexprnoexcept |
Determine if two rectangles intersect, or, overlap.
rect | The rect to test. |
|
inlinestaticconstexprnoexcept |
Return the intersecting rectangle of two rectangles, if any.
|
inlineconstexprnoexcept |
Get the left side the rectangle.
|
inlinestaticconstexprnoexcept |
Merge two rectangles together into one super rectangle that contains them both.
|
inlineconstexprnoexcept |
Move the rectangle's center to the specified point.
|
inlineconstexprnoexcept |
RectType operator.
|
inlineconstexprnoexcept |
RectType operator.
|
inlineconstexprnoexcept |
RectType operator.
|
inlineconstexprnoexcept |
RectType operator.
|
inlineconstexprnoexcept |
Get the PointType of the rectangle.
|
inlineconstexprnoexcept |
Set the rectangle's origin to the specified point.
|
inlineconstexprnoexcept |
Get the right side the rectangle.
|
inlineconstexprnoexcept |
Shrink the rectangle around its center by the specified radius.
radius | Relative radius to change by. |
|
inlineconstexprnoexcept |
Get the SizeType of the rectangle.
|
inlineconstexprnoexcept |
Set the SizeType of the rectangle.
|
inlineconstexprnoexcept |
Get the top side of the rectangle.
|
inlineconstexprnoexcept |
Get the top left point of the rectangle.
|
inlineconstexprnoexcept |
Get the top right point of the rectangle.
|
inlineconstexprnoexcept |
Get the width value.
|
inlineconstexprnoexcept |
Set the width value.
|
inlineconstexprnoexcept |
Get the x value.
|
inlineconstexprnoexcept |
Set the x value.
|
inlineconstexprnoexcept |
Get the y value.
|
inlineconstexprnoexcept |
Set the y value.
|
protected |
Origin.
|
protected |
Size.