12#include "../SIMD/SIMD.hpp"
13#include "../utility/utility.hpp"
14#include "../macros.hpp"
21hi_export_module(hikogui.geometry : extent2);
23hi_export
namespace hi {
inline namespace v1 {
35 using value_type = array_type::value_type;
61 return vector2{
static_cast<array_type
>(*this)};
98 return _v.x() != 0.0f
or _v.y() != 0.0f
or _v.z() != 0.0f;
152 return vector2{_v._0y00()};
157 return *
this = *
this + rhs;
167 return extent2{lhs._v + rhs._v};
177 return extent2{lhs._v - rhs._v};
187 return extent2{lhs._v * array_type::broadcast(rhs)};
192 return extent2{
static_cast<array_type
>(lhs) +
static_cast<array_type
>(rhs)};
197 return vector2{
static_cast<array_type
>(lhs) +
static_cast<array_type
>(rhs)};
209 r._v[i] = lhs._v[i] + rhs;
222 return extent2{array_type::broadcast(lhs) * rhs._v};
232 return equal(lhs._v, rhs._v);
235 [[
nodiscard]]
constexpr friend std::partial_ordering operator<=>(
extent2 const& lhs,
extent2 const& rhs)
noexcept
239 auto const equal = (lhs._v == rhs._v).mask() & mask;
242 return std::partial_ordering::equivalent;
245 auto const less = (lhs._v < rhs._v).mask() & mask;
246 if ((less | equal) == mask) {
248 return std::partial_ordering::less;
251 auto const greater = (lhs._v > rhs._v).mask() & mask;
252 if ((greater | equal) == mask) {
254 return std::partial_ordering::greater;
258 return std::partial_ordering::unordered;
299 return extent2{ceil(array_type{rhs})};
304 return extent2{floor(
static_cast<array_type
>(rhs))};
309 return extent2{round(
static_cast<array_type
>(rhs))};
314 return extent2{min(
static_cast<array_type
>(lhs),
static_cast<array_type
>(rhs))};
319 return extent2{max(
static_cast<array_type
>(lhs),
static_cast<array_type
>(rhs))};
324 return extent2{clamp(
static_cast<array_type
>(value),
static_cast<array_type
>(min),
static_cast<array_type
>(max))};
333 return _v.x() >= 0.0f
and _v.y() >= 0.0f
and _v.z() == 0.0f
and _v.w() == 0.0f;
338 return std::format(
"[{}, {}]", rhs._v.x(), rhs._v.y());
343 return lhs << to_string(rhs);
354struct std::formatter<
hi::extent2, char> {
362 return std::vformat_to(fc.out(),
"[{}, {}]", std::make_format_args(t.
width(), t.
height()));
@ other
The gui_event does not have associated data.
DOXYGEN BUG.
Definition algorithm_misc.hpp:20
The HikoGUI namespace.
Definition recursive_iterator.hpp:15
constexpr Out narrow_cast(In const &rhs) noexcept
Cast numeric values without loss of precision.
Definition cast.hpp:378
A high-level geometric extent.
Definition extent2.hpp:32
constexpr float width() const noexcept
Access the x-as-width element from the extent.
Definition extent2.hpp:129
friend float hypot(extent2 const &rhs) noexcept
Get the length of the extent.
Definition extent2.hpp:274
constexpr friend extent2 operator*(float const &lhs, extent2 const &rhs) noexcept
Scale the extent by a scaler.
Definition extent2.hpp:220
constexpr float height() const noexcept
Access the y-as-height element from the extent.
Definition extent2.hpp:140
hi_force_inline constexpr friend float squared_hypot(extent2 const &rhs) noexcept
Get the squared length of the extent.
Definition extent2.hpp:265
constexpr friend extent2 operator+(extent2 const &lhs, float const &rhs) noexcept
Add a scaler to the extent.
Definition extent2.hpp:205
constexpr friend extent2 operator*(extent2 const &lhs, float const &rhs) noexcept
Scale the extent by a scaler.
Definition extent2.hpp:185
constexpr friend bool operator==(extent2 const &lhs, extent2 const &rhs) noexcept
Compare if two extents are equal.
Definition extent2.hpp:230
constexpr friend extent2 operator-(extent2 const &lhs, extent2 const &rhs) noexcept
Subtract two extents from each other.
Definition extent2.hpp:175
constexpr friend float rcp_hypot(extent2 const &rhs) noexcept
Get the length of the extent.
Definition extent2.hpp:283
constexpr float & width() noexcept
Access the x-as-width element from the extent.
Definition extent2.hpp:107
constexpr extent2() noexcept
Construct a empty extent / zero length.
Definition extent2.hpp:66
constexpr float & height() noexcept
Access the y-as-height element from the extent.
Definition extent2.hpp:118
constexpr friend extent2 operator+(extent2 const &lhs, extent2 const &rhs) noexcept
Add two extents from each other.
Definition extent2.hpp:165
constexpr bool holds_invariant() const noexcept
Check if the extent is valid.
Definition extent2.hpp:331
constexpr friend extent2 normalize(extent2 const &rhs) noexcept
Normalize a extent to a unit extent.
Definition extent2.hpp:292
constexpr extent2(float width, float height) noexcept
Construct a 3D extent from width, height and depth.
Definition extent2.hpp:73
A high-level geometric vector Part of the high-level vector, point, mat and color types.
Definition vector2.hpp:26
Definition simd_intf.hpp:18
T signaling_NaN(T... args)