HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
corner_radii.hpp
Go to the documentation of this file.
1// Copyright Take Vos 2021.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
9#pragma once
10
11namespace hi {
12inline namespace v1 {
13namespace geo {
14
19template<typename T>
21public:
22 using value_type = T;
23 using array_type = simd<value_type, 4>;
24
25 constexpr corner_radii(corner_radii const &) noexcept = default;
26 constexpr corner_radii(corner_radii &&) noexcept = default;
27 constexpr corner_radii &operator=(corner_radii const &) noexcept = default;
28 constexpr corner_radii &operator=(corner_radii &&) noexcept = default;
29
30 [[nodiscard]] constexpr corner_radii() noexcept : corner_radii(-std::numeric_limits<value_type>::lowest()) {}
31 [[nodiscard]] constexpr corner_radii(value_type radius) noexcept : _v(radius, radius, radius, radius) {}
32 [[nodiscard]] constexpr corner_radii(value_type lb, value_type rb, value_type lt, value_type rt) noexcept : _v(lb, rb, lt, rt)
33 {
34 }
35
40 [[nodiscard]] constexpr explicit corner_radii(array_type v) noexcept : _v(v) {}
41
42 [[nodiscard]] constexpr explicit operator array_type() const noexcept
43 {
44 return _v;
45 }
46
47 [[nodiscard]] constexpr value_type left_bottom() const noexcept
48 {
49 return _v.x();
50 }
51
52 [[nodiscard]] constexpr value_type right_bottom() const noexcept
53 {
54 return _v.y();
55 }
56
57 [[nodiscard]] constexpr value_type left_top() const noexcept
58 {
59 return _v.z();
60 }
61
62 [[nodiscard]] constexpr value_type right_top() const noexcept
63 {
64 return _v.w();
65 }
66
72 template<int I>
73 [[nodiscard]] constexpr friend float get(corner_radii const &rhs) noexcept
74 {
75 return get<I>(rhs._v);
76 }
77
83 [[nodiscard]] constexpr float operator[](std::size_t i) const noexcept
84 {
85 return _v[i];
86 }
87
88 [[nodiscard]] constexpr friend corner_radii operator+(corner_radii const& lhs, value_type rhs) noexcept
89 {
90 return corner_radii{array_type{lhs} + rhs};
91 }
92
93 [[nodiscard]] constexpr friend corner_radii operator-(corner_radii const &lhs, value_type rhs) noexcept
94 {
95 return corner_radii{array_type{lhs} - rhs};
96 }
97
98private:
99 array_type _v;
100};
101
102}
103
104using corner_radii = geo::corner_radii<float>;
105using corner_radiii = geo::corner_radii<int>;
106
107}} // namespace hi::inline v1
108
DOXYGEN BUG.
Definition algorithm.hpp:13
geometry/margins.hpp
Definition cache.hpp:11
The 4 radii of the corners of a quad or rectangle.
Definition corner_radii.hpp:20
constexpr friend float get(corner_radii const &rhs) noexcept
Get the corner radius by index.
Definition corner_radii.hpp:73
constexpr float operator[](std::size_t i) const noexcept
Get the corner radius by index.
Definition corner_radii.hpp:83
constexpr corner_radii(array_type v) noexcept
Construct a corner_radii from a simd.
Definition corner_radii.hpp:40