9#include "../macros.hpp"
14hi_export_module(hikogui.geometry : translate2);
16hi_export
namespace hi {
inline namespace v1 {
21 using value_type = array_type::value_type;
28 [[nodiscard]]
constexpr translate2() noexcept : _v(0.0f, 0.0f, 0.0f, 0.0f) {}
30 [[nodiscard]]
constexpr explicit operator array_type()
const noexcept
37 hi_axiom(holds_invariant());
41 _v(
static_cast<array_type
>(get<0>(
other)).xy00())
46 _v(
static_cast<array_type
>(get<0>(
other)).xy00())
53 [[nodiscard]]
constexpr explicit translate2(point2
const&
other) noexcept : _v(
static_cast<array_type
>(
other).xy00()) {}
55 [[nodiscard]]
constexpr translate2(
float x,
float y) noexcept : _v(x, y, 0.0f, 0.0f) {}
57 [[nodiscard]]
constexpr float x()
const noexcept
62 [[nodiscard]]
constexpr float y()
const noexcept
67 [[nodiscard]]
constexpr float& x()
noexcept
72 [[nodiscard]]
constexpr float& y()
noexcept
88 x = dst_rectangle.left();
91 x = dst_rectangle.right() - src_rectangle.width();
94 x = dst_rectangle.center() - src_rectangle.width() * 0.5f;
102 y = dst_rectangle.bottom();
105 y = dst_rectangle.top() - src_rectangle.height();
108 y = dst_rectangle.middle() - src_rectangle.height() * 0.5f;
114 return translate2{x - src_rectangle.left(), y - src_rectangle.bottom()};
117 [[nodiscard]]
constexpr friend bool operator==(
translate2 const& lhs,
translate2 const& rhs)
noexcept
119 return equal(lhs._v, rhs._v);
122 [[nodiscard]]
constexpr translate2 operator~() const noexcept
127 [[nodiscard]]
constexpr bool holds_invariant() const noexcept
129 return _v.z() == 0.0f and _v.w() == 0.0f;
132 [[nodiscard]]
friend constexpr translate2 round(translate2
const& rhs)
noexcept
134 return translate2{round(rhs._v)};
@ 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.
The HikoGUI namespace.
Definition array_generic.hpp:20
DOXYGEN BUG.
Definition algorithm_misc.hpp:20
Definition simd_intf.hpp:18
Class which represents an axis-aligned rectangle.
Definition aarectangle.hpp:33
Horizontal/Vertical alignment combination.
Definition alignment.hpp:244
Definition translate2.hpp:18
static constexpr translate2 align(aarectangle src_rectangle, aarectangle dst_rectangle, alignment alignment) noexcept
Align a rectangle within another rectangle.
Definition translate2.hpp:84
A high-level geometric vector Part of the high-level vector, point, mat and color types.
Definition vector2.hpp:27