13#include "../macros.hpp"
15namespace hi {
inline namespace v1 {
26 constexpr circle() noexcept : _v()
28 hi_axiom(holds_invariant());
31 [[nodiscard]]
constexpr explicit circle(f32x4 v) noexcept : _v(v)
33 hi_axiom(holds_invariant());
36 [[nodiscard]]
constexpr explicit operator f32x4()
const noexcept
41 [[nodiscard]]
constexpr circle(point3 point,
float radius) noexcept : _v(f32x4{point})
44 hi_axiom(holds_invariant());
47 [[nodiscard]]
constexpr circle(
float radius) noexcept : _v()
50 hi_axiom(holds_invariant());
55 hilet square_ = f32x4{square};
58 _v = (addsub<0b0011>(square_.zwzw(), square_.xyxy()) * 0.5f).xy0w();
59 hi_axiom(holds_invariant());
62 [[nodiscard]]
constexpr bool empty()
const noexcept
64 return _v.w() == 0.0f;
67 [[nodiscard]]
explicit operator bool()
const noexcept
72 [[nodiscard]]
constexpr float radius()
const noexcept
77 [[nodiscard]]
constexpr float diameter()
const noexcept
79 return radius() * 2.0f;
82 [[nodiscard]]
constexpr point3 center()
const noexcept
84 return point3{_v.xyz1()};
87 [[nodiscard]]
constexpr friend circle operator+(
circle const& lhs,
float rhs)
noexcept
89 return circle{lhs._v + insert<3>(f32x4{}, rhs)};
92 [[nodiscard]]
constexpr friend circle operator-(
circle const& lhs,
float rhs)
noexcept
94 return circle{lhs._v - insert<3>(f32x4{}, rhs)};
97 [[nodiscard]]
constexpr friend circle operator*(
circle const& lhs,
float rhs)
noexcept
99 return circle{lhs._v * insert<3>(f32x4::broadcast(1.0f), rhs)};
102 [[nodiscard]]
constexpr friend point3 midpoint(
circle const& rhs)
noexcept
104 return point3{rhs.center()};
107 [[nodiscard]]
constexpr friend aarectangle bounding_rectangle(
circle const& rhs)
noexcept
109 hilet p = rhs._v.xyxy();
110 hilet r = neg<0b0011>(rhs._v.wwww());
124 return haystack.left() + needle.radius();
127 return haystack.right() - needle.radius();
130 return haystack.center();
139 return haystack.bottom() + needle.radius();
142 return haystack.top() - needle.radius();
145 return haystack.middle();
152 return circle{point2{x, y}, needle.radius()};
159 [[nodiscard]]
constexpr bool holds_invariant() const noexcept
161 return _v.w() >= 0.0f;
@ middle
Align to the vertical-middle.
Definition alignment.hpp:33
@ bottom
Align to the bottom.
Definition alignment.hpp:37
@ top
Align to the top.
Definition alignment.hpp:29
@ right
Align the text to the right side.
Definition alignment.hpp:137
@ left
Align the text to the left side.
Definition alignment.hpp:119
@ center
Align the text in the center.
Definition alignment.hpp:125
@ other
The gui_event does not have associated data.
Definition gui_event_variant.hpp:22
geometry/margins.hpp
Definition lookahead_iterator.hpp:5
The HikoGUI API version 1.
Definition lookahead_iterator.hpp:6
Class which represents an axis-aligned rectangle.
Definition aarectangle.hpp:29
Horizontal/Vertical alignment combination.
Definition alignment.hpp:242
A type defining a 2D circle.
Definition circle.hpp:19
friend constexpr circle align(aarectangle haystack, circle needle, alignment alignment) noexcept
Align a rectangle within another rectangle.
Definition circle.hpp:120