12#ifndef JAU_MATH_RECTI2F_HPP_
13#define JAU_MATH_RECTI2F_HPP_
34 template<jau::req::packed_
integral Value_type>
35 class alignas(sizeof(Value_type))
RectI {
62 : m_x(0), m_y(0), m_width(0), m_height(0) {}
81 constexpr
bool operator==(const
RectI& rhs ) const noexcept {
85 return m_x == rhs.m_x && m_y == rhs.m_y &&
86 m_width == rhs.m_width &&
87 m_height == rhs.m_height;
95 const size_t sum1 = size_t(m_x) + size_t(m_height);
96 const size_t sum2 = size_t(m_width) + size_t(m_y);
97 const size_t val1 = sum1 * (sum1 + 1)/2 +
size_t(m_x);
98 const size_t val2 = sum2 * (sum2 + 1)/2 +
size_t(m_y);
99 const size_t sum3 = val1 + val2;
100 return sum3 * (sum3 + 1)/2 + val2;
104 { m_x = pos.x; m_y = pos.y; m_width = size.x; m_height= size.y;
return *
this; }
108 { m_x =
x; m_y =
y; m_width =
width; m_height=
height;
return *
this; }
112 { m_x = xywh[0]; m_y = xywh[1]; m_width = xywh[2]; m_height= xywh[3];
return *
this; }
116 { xywh[0] = m_x; xywh[1] = m_y; xywh[2] = m_width; xywh[3] = m_height;
return xywh; }
134 return 0 == m_width || 0 == m_height;
138 {
return std::to_string(m_x)+
"/"+std::to_string(m_y)+
" "+std::to_string(m_width)+
"x"+std::to_string(m_height); }
141 template<jau::req::packed_
integral T>
143 return out << v.toString();
149 static_assert(
sizeof(int) ==
alignof(
Recti));
150 static_assert(
sizeof(int)*4 ==
sizeof(
Recti));
Rectangle with x, y, width and height value_type components.
constexpr RectI(const value_type xywh[]) noexcept
constexpr RectI() noexcept
constexpr value_type x() const noexcept
constexpr Vector2I< value_type > getSize() const noexcept
constexpr value_type height() const noexcept
constexpr void setY(const value_type y) noexcept
constexpr RectI & set(const Vector2I< value_type > &pos, const Vector2I< value_type > &size) noexcept
static constexpr int value_alignment
size_t hashCode() const noexcept
TODO constexpr std::strong_ordering operator<=>(const Recti_t& rhs) const noexcept { return ....
constexpr RectI(const RectI &o) noexcept=default
constexpr void setWidth(const value_type width) noexcept
const value_type * const_iterator
constexpr RectI(RectI &&o) noexcept=default
constexpr RectI(const value_type x, const value_type y, const value_type width, const value_type height) noexcept
constexpr RectI & set(const value_type x, const value_type y, const value_type width, const value_type height) noexcept
this = { x, y, width, height }, returns this.
constexpr void setHeight(const value_type height) noexcept
constexpr RectI & operator=(const RectI &) noexcept=default
std::string toString() const noexcept
const value_type * const_pointer
constexpr RectI & operator=(RectI &&) noexcept=default
const value_type & const_reference
constexpr void setX(const value_type x) noexcept
static constexpr const size_t byte_size
constexpr Vector2I< value_type > getPosition() const noexcept
iterator get(iterator xywh) const noexcept
xywh = this, returns xywh.
constexpr RectI & set(const_iterator xywh) noexcept
this = xywh, returns this.
constexpr void setPosition(const Vector2I< value_type > &pos) noexcept
constexpr value_type width() const noexcept
constexpr RectI(const Vector2I< value_type > &pos, const Vector2I< value_type > &size) noexcept
constexpr bool is_zero() const noexcept
Return true if area is zero.
constexpr void setSize(const Vector2I< value_type > &size) noexcept
static constexpr const size_t components
constexpr value_type y() const noexcept
2D vector using two value_type components.
std::ostream & operator<<(std::ostream &out, const Matrix4< T > &v) noexcept