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
11#include "../macros.hpp"
12namespace hi {
13inline namespace v1 {
14
20public:
21 constexpr corner_radii(corner_radii const &) noexcept = default;
22 constexpr corner_radii(corner_radii &&) noexcept = default;
23 constexpr corner_radii &operator=(corner_radii const &) noexcept = default;
24 constexpr corner_radii &operator=(corner_radii &&) noexcept = default;
25
27 [[nodiscard]] constexpr corner_radii(float radius) noexcept : _v(radius, radius, radius, radius) {}
28 [[nodiscard]] constexpr corner_radii(float lb, float rb, float lt, float rt) noexcept : _v(lb, rb, lt, rt) {}
29
34 [[nodiscard]] constexpr explicit corner_radii(f32x4 v) noexcept : _v(v) {}
35
36 [[nodiscard]] constexpr explicit operator f32x4() const noexcept
37 {
38 return _v;
39 }
40
41 [[nodiscard]] constexpr float left_bottom() const noexcept
42 {
43 return _v.x();
44 }
45
46 [[nodiscard]] constexpr float right_bottom() const noexcept
47 {
48 return _v.y();
49 }
50
51 [[nodiscard]] constexpr float left_top() const noexcept
52 {
53 return _v.z();
54 }
55
56 [[nodiscard]] constexpr float right_top() const noexcept
57 {
58 return _v.w();
59 }
60
66 template<int I>
67 [[nodiscard]] constexpr friend float get(corner_radii const &rhs) noexcept
68 {
69 return get<I>(rhs._v);
70 }
71
77 [[nodiscard]] constexpr float operator[](std::size_t i) const noexcept
78 {
79 return _v[i];
80 }
81
82 [[nodiscard]] constexpr friend corner_radii operator+(corner_radii const &lhs, float rhs) noexcept
83 {
84 return corner_radii{f32x4{lhs} + rhs};
85 }
86
87 [[nodiscard]] constexpr friend corner_radii operator-(corner_radii const &lhs, float rhs) noexcept
88 {
89 return corner_radii{f32x4{lhs} - rhs};
90 }
91
92
93private:
94 f32x4 _v;
95};
96
97}} // namespace hi::inline v1
98
DOXYGEN BUG.
Definition algorithm.hpp:16
geometry/margins.hpp
Definition lookahead_iterator.hpp:5
constexpr Out narrow_cast(In const &rhs) noexcept
Cast numeric values without loss of precision.
Definition cast.hpp:377
The 4 radii of the corners of a quad or rectangle.
Definition corner_radii.hpp:19
constexpr friend float get(corner_radii const &rhs) noexcept
Get the corner radius by index.
Definition corner_radii.hpp:67
constexpr float operator[](std::size_t i) const noexcept
Get the corner radius by index.
Definition corner_radii.hpp:77
constexpr corner_radii(f32x4 v) noexcept
Construct a corner_radii from a simd.
Definition corner_radii.hpp:34