9#include "../macros.hpp"
12namespace hi {
inline namespace v1 {
16 using array_type = simd<float, 4>;
17 using value_type = array_type::value_type;
24 [[nodiscard]]
constexpr translate2() noexcept : _v(0.0f, 0.0f, 0.0f, 0.0f) {}
26 [[nodiscard]]
constexpr explicit operator array_type()
const noexcept
33 hi_axiom(holds_invariant());
37 _v(
static_cast<array_type
>(get<0>(
other)).xy00())
42 _v(
static_cast<array_type
>(get<0>(
other)).xy00())
49 [[nodiscard]]
constexpr explicit translate2(point2
const&
other) noexcept : _v(
static_cast<array_type
>(
other).xy00()) {}
51 [[nodiscard]]
constexpr translate2(
float x,
float y) noexcept : _v(x, y, 0.0f, 0.0f) {}
53 [[nodiscard]]
constexpr float x()
const noexcept
58 [[nodiscard]]
constexpr float y()
const noexcept
63 [[nodiscard]]
constexpr float& x()
noexcept
68 [[nodiscard]]
constexpr float& y()
noexcept
84 x = dst_rectangle.left();
87 x = dst_rectangle.right() - src_rectangle.width();
90 x = dst_rectangle.center() - src_rectangle.width() * 0.5f;
98 y = dst_rectangle.bottom();
101 y = dst_rectangle.top() - src_rectangle.height();
104 y = dst_rectangle.middle() - src_rectangle.height() * 0.5f;
110 return translate2{x - src_rectangle.left(), y - src_rectangle.bottom()};
113 [[nodiscard]]
constexpr friend bool operator==(
translate2 const& lhs,
translate2 const& rhs)
noexcept
115 return equal(lhs._v, rhs._v);
118 [[nodiscard]]
constexpr translate2 operator~() const noexcept
123 [[nodiscard]]
constexpr bool holds_invariant() const noexcept
125 return _v.z() == 0.0f and _v.w() == 0.0f;
128 [[nodiscard]]
friend constexpr translate2 round(translate2
const& rhs)
noexcept
130 return translate2{round(rhs._v)};
@ 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
Definition translate2.hpp:14
static constexpr translate2 align(aarectangle src_rectangle, aarectangle dst_rectangle, alignment alignment) noexcept
Align a rectangle within another rectangle.
Definition translate2.hpp:80
A high-level geometric vector Part of the high-level vector, point, mat and color types.
Definition vector2.hpp:19