15#include "../SIMD/module.hpp"
16#include "../utility/utility.hpp"
17#include "../concurrency/concurrency.hpp"
18#include "../macros.hpp"
24namespace hi {
inline namespace v1 {
32 using value_type = array_type::value_type;
60 v{x, y, x + width, y + height}
79 v(
static_cast<array_type
>(p0).
xy00() +
static_cast<array_type
>(p3).
_00xy())
81 hi_axiom(p0.holds_invariant());
82 hi_axiom(p3.holds_invariant());
94 v(
static_cast<array_type
>(p0).
xyxy() +
static_cast<array_type
>(extent).
_00xy())
109 return (v <= v.zwzw()).mask() == 0b1111;
116 return (v == v.zwxy()).mask() == 0b1111;
133 return *
this = *
this | rhs;
143 return *
this = *
this | rhs;
150 return point2{v.xy01()};
152 return point2{v.zy01()};
154 return point2{v.xw01()};
156 return point2{v.zw01()};
163 [[
nodiscard]]
constexpr friend point2 get(aarectangle
const &rhs)
noexcept
165 if constexpr (I == 0) {
166 return point2{rhs.v.xy01()};
167 }
else if constexpr (I == 1) {
168 return point2{rhs.v.zy01()};
169 }
else if constexpr (I == 2) {
170 return point2{rhs.v.xw01()};
171 }
else if constexpr (I == 3) {
172 return point2{rhs.v.zw01()};
174 hi_static_no_default();
199 return (v.zwzw() - v).x();
204 return (v.zwzw() - v).y();
231 return (bottom() + top()) / value_type{2};
238 return (left() + right()) / value_type{2};
250 v = v.xyxw() + array_type{value_type{0}, value_type{0},
newWidth, value_type{0}};
254 constexpr aarectangle& set_height(value_type
newHeight)
noexcept
256 v = v.xyzy() + array_type{value_type{0}, value_type{0}, value_type{0},
newHeight};
267 return (
static_cast<array_type
>(rhs).
xyxy() >= v).mask() == 0b0011;
289 auto x = value_type{0};
303 auto y = value_type{0};
317 return {point2{x, y},
needle};
340 return equal(lhs.v, rhs.v);
345 if (lhs.empty()
or rhs.
empty()) {
352 if (((lhs.v >
rhs_swap).mask() & 0b0011) != 0) {
357 if (((lhs.v <
rhs_swap).mask() & 0b1100) != 0) {
364 [[
nodiscard]]
friend constexpr aarectangle operator|(aarectangle
const& lhs, aarectangle
const& rhs)
noexcept
375 [[
nodiscard]]
friend constexpr aarectangle operator|(aarectangle
const& lhs, point2
const& rhs)
noexcept
378 return aarectangle{rhs, rhs};
393 hilet offset =
diff * 0.5f;
395 hilet p0 =
get<0>(lhs) - offset;
396 hilet p3 = max(
get<3>(lhs) + offset, p0);
424 hilet p0 = round(
get<0>(rhs));
468 if (p0.x() < p3.x() && p0.y() < p3.y()) {
477 hilet
lhs_ =
static_cast<array_type
>(lhs);
478 hilet
rhs_ =
static_cast<array_type
>(rhs);
500 constexpr static bool is_always_lock_free =
false;
502 constexpr atomic()
noexcept =
default;
522 return is_always_lock_free;
525 void store(
value_type desired, std::memory_order = std::memory_order_seq_cst)
noexcept
527 hilet
lock = std::scoped_lock(_mutex);
531 value_type load(std::memory_order = std::memory_order_seq_cst)
const noexcept
533 hilet
lock = std::scoped_lock(_mutex);
539 hilet
lock = std::scoped_lock(_mutex);
540 return std::exchange(_value, desired);
545 hilet
lock = std::scoped_lock(_mutex);
546 if (_value == expected) {
558 std::memory_order success,
559 std::memory_order failure)
noexcept
573 std::memory_order order = std::memory_order_seq_cst)
noexcept
580 hilet
lock = std::scoped_lock(_mutex);
588 hilet
lock = std::scoped_lock(_mutex);
589 return _value |= arg;
597template<
typename CharT>
598struct std::formatter<
hi::aarectangle, CharT> {
606 return std::vformat_to(fc.out(),
"{}:{}", std::make_format_args(get<0>(t), t.
size()));
types and utilities for alignment.
Defined the geo::extent, extent2 and extent3 types.
@ middle
Align to the vertical-middle.
@ bottom
Align to the bottom.
@ right
Align the text to the right side.
@ left
Align the text to the left side.
@ center
Align the text in the center.
@ other
The gui_event does not have associated data.
DOXYGEN BUG.
Definition algorithm.hpp:16
geometry/margins.hpp
Definition lookahead_iterator.hpp:5
@ inside
The border is drawn inside the edge of a quad.
@ outside
The border is drawn outside the edge of a quad.
constexpr Out narrow_cast(In const &rhs) noexcept
Cast numeric values without loss of precision.
Definition cast.hpp:377
Class which represents an axis-aligned rectangle.
Definition aarectangle.hpp:29
friend constexpr aarectangle ceil(aarectangle const &lhs, extent2 const &rhs) noexcept
Round rectangle by expanding to a certain granularity.
Definition aarectangle.hpp:440
constexpr extent2 size() const noexcept
Get size of the rectangle.
Definition aarectangle.hpp:182
friend constexpr aarectangle intersect(aarectangle const &lhs, aarectangle const &rhs) noexcept
Return the overlapping part of two rectangles.
Definition aarectangle.hpp:464
static constexpr aarectangle large() noexcept
Create a large axis aligned rectangle.
Definition aarectangle.hpp:42
friend constexpr aarectangle operator*(aarectangle const &lhs, value_type rhs) noexcept
Expand the rectangle for the same amount in all directions.
Definition aarectangle.hpp:389
constexpr friend point2 midpoint(aarectangle const &rhs) noexcept
Get the center of the rectangle.
Definition aarectangle.hpp:243
constexpr aarectangle(extent2 const &extent) noexcept
Create a rectangle from the size.
Definition aarectangle.hpp:69
friend constexpr aarectangle operator-(aarectangle const &lhs, value_type rhs) noexcept
Shrink the rectangle for the same amount in all directions.
Definition aarectangle.hpp:417
constexpr bool empty() const noexcept
Check if the rectangle has no area.
Definition aarectangle.hpp:114
constexpr bool contains(point3 const &rhs) const noexcept
Check if a 3D coordinate is inside the rectangle.
Definition aarectangle.hpp:275
constexpr bool contains(point2 const &rhs) const noexcept
Check if a 2D coordinate is inside the rectangle.
Definition aarectangle.hpp:264
static constexpr aarectangle _align(aarectangle outside, aarectangle inside, alignment alignment) noexcept
Need to call the hidden friend function from within another class.
Definition aarectangle.hpp:333
friend constexpr aarectangle floor(aarectangle const &rhs) noexcept
Round rectangle by shrinking to pixel edge.
Definition aarectangle.hpp:449
constexpr bool holds_invariant() const noexcept
Make sure p0 is left/bottom from p3.
Definition aarectangle.hpp:107
friend constexpr aarectangle align(aarectangle haystack, extent2 needle, alignment alignment) noexcept
Align a rectangle within another rectangle.
Definition aarectangle.hpp:287
friend constexpr aarectangle align(aarectangle haystack, aarectangle needle, alignment alignment) noexcept
Align a rectangle within another rectangle.
Definition aarectangle.hpp:326
friend constexpr aarectangle operator+(aarectangle const &lhs, value_type rhs) noexcept
Expand the rectangle for the same amount in all directions.
Definition aarectangle.hpp:406
constexpr value_type center() const noexcept
The center on the x-axis between left and right.
Definition aarectangle.hpp:236
constexpr aarectangle & operator|=(point2 const &rhs) noexcept
Expand the current rectangle to include the new rectangle.
Definition aarectangle.hpp:141
constexpr aarectangle(float x, float y, float width, float height) noexcept
Create a box from the position and size.
Definition aarectangle.hpp:59
friend constexpr aarectangle ceil(aarectangle const &rhs) noexcept
Round rectangle by expanding to pixel edge.
Definition aarectangle.hpp:431
constexpr aarectangle(point2 const &p0, point2 const &p3) noexcept
Create a rectangle from the left-bottom and right-top points.
Definition aarectangle.hpp:78
constexpr aarectangle & operator|=(aarectangle const &rhs) noexcept
Expand the current rectangle to include the new rectangle.
Definition aarectangle.hpp:131
constexpr value_type middle() const noexcept
The middle on the y-axis between bottom and top.
Definition aarectangle.hpp:229
constexpr aarectangle(point2 const &p0, extent2 const &extent) noexcept
Create a rectangle from the size.
Definition aarectangle.hpp:93
Horizontal/Vertical alignment combination.
Definition alignment.hpp:242
A high-level geometric extent.
Definition extent2.hpp:29
A high-level geometric vector Part of the high-level vector, point, mat and color types.
Definition vector2.hpp:19
T compare_exchange_weak(T... args)
T is_lock_free(T... args)