9#include "../macros.hpp"
11namespace hi {
inline namespace v1 {
15 using array_type = simd<float, 4>;
16 using value_type = array_type::value_type;
20 constexpr scale2& operator=(
scale2 const&)
noexcept =
default;
21 constexpr scale2& operator=(
scale2&&)
noexcept =
default;
23 [[nodiscard]]
constexpr explicit operator f32x4()
const noexcept
28 [[nodiscard]]
constexpr explicit scale2(f32x4
const& v) noexcept : _v(v)
30 hi_axiom(holds_invariant());
33 [[nodiscard]]
constexpr explicit scale2(
vector2 const& v) noexcept : _v(
static_cast<f32x4
>(v).xyz1()) {}
35 [[nodiscard]]
constexpr scale2() noexcept : _v(1.0f, 1.0f, 1.0f, 1.0f) {}
37 [[nodiscard]]
constexpr scale2(
float value) noexcept : _v(value, value, value, 1.0f) {}
39 [[nodiscard]]
constexpr scale2(
float x,
float y) noexcept : _v(x, y, 1.0f, 1.0f) {}
48 hilet non_uniform_scale = f32x4{dst_extent}.xyxy() / f32x4{src_extent}.xyxy();
49 hilet uniform_scale =
std::min(non_uniform_scale.x(), non_uniform_scale.y());
50 return scale2{uniform_scale};
53 [[nodiscard]]
constexpr friend bool operator==(
scale2 const& lhs,
scale2 const& rhs)
noexcept
55 return equal(lhs._v, rhs._v);
58 [[nodiscard]]
constexpr bool holds_invariant() const noexcept
60 return _v.z() == 1.0f and _v.w() == 1.0f;
63 [[nodiscard]]
constexpr float& x() noexcept
68 [[nodiscard]]
constexpr float& y() noexcept
73 [[nodiscard]]
constexpr float x() const noexcept
78 [[nodiscard]]
constexpr float y() const noexcept
89 hi_axiom(rhs.width() > 0.0f and rhs.height() > 0.0f);
90 return scale2{f32x4{lhs}.xy11() / f32x4{rhs}.xy11()};
Defined the geo::extent, extent2 and extent3 types.
geometry/margins.hpp
Definition lookahead_iterator.hpp:5
The HikoGUI API version 1.
Definition lookahead_iterator.hpp:6
A high-level geometric extent.
Definition extent2.hpp:29
static constexpr scale2 uniform(extent2 src_extent, extent2 dst_extent) noexcept
Get a uniform-scale-transform to scale an extent to another extent.
Definition scale2.hpp:46
A high-level geometric vector Part of the high-level vector, point, mat and color types.
Definition vector2.hpp:19