HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
src
ttauri
rapid
sfloat_rgba32.hpp
1
// Copyright Take Vos 2020.
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
5
#pragma once
6
7
#include "numeric_array.hpp"
8
#include "../geometry/corner_shapes.hpp"
9
#include "../geometry/axis_aligned_rectangle.hpp"
10
#include "../color/color.hpp"
11
#include <algorithm>
12
13
namespace
tt {
14
15
class
sfloat_rgba32
{
16
// Red, Green, Blue, Alpha in binary32 (native endian).
17
std::array<float, 4>
v;
18
19
public
:
20
sfloat_rgba32
() =
default
;
21
sfloat_rgba32
(
sfloat_rgba32
const
&rhs)
noexcept
=
default
;
22
sfloat_rgba32
(
sfloat_rgba32
&&rhs)
noexcept
=
default
;
23
sfloat_rgba32
&operator=(
sfloat_rgba32
const
&rhs)
noexcept
=
default
;
24
sfloat_rgba32
&operator=(
sfloat_rgba32
&&rhs)
noexcept
=
default
;
25
26
sfloat_rgba32
(
f32x4
const
&rhs) noexcept : v(
static_cast<
std::array<float, 4>
>
(rhs)) {}
27
28
sfloat_rgba32
&operator=(
f32x4
const
&rhs)
noexcept
29
{
30
v =
static_cast<
std::array<float, 4>
>
(rhs);
31
return
*
this
;
32
}
33
34
operator
f32x4
()
const
noexcept
35
{
36
return
f32x4
{v};
37
}
38
39
sfloat_rgba32
(
aarectangle
const
&rhs) noexcept :
sfloat_rgba32
(rhs.v) {}
40
41
sfloat_rgba32
(
corner_shapes
const
&rhs) noexcept :
sfloat_rgba32
(
static_cast<
f32x4
>
(rhs)) {}
42
43
sfloat_rgba32
&operator=(
aarectangle
const
&rhs)
noexcept
44
{
45
*
this
= rhs.v;
46
return
*
this
;
47
}
48
49
operator
aarectangle
()
const
noexcept
50
{
51
return
aarectangle
{
f32x4
{v}};
52
}
53
54
[[nodiscard]]
friend
bool
operator==(
sfloat_rgba32
const
&lhs,
sfloat_rgba32
const
&rhs)
noexcept
55
{
56
return
lhs.v == rhs.v;
57
}
58
[[nodiscard]]
friend
bool
operator!=(
sfloat_rgba32
const
&lhs,
sfloat_rgba32
const
&rhs)
noexcept
59
{
60
return
!(lhs == rhs);
61
}
62
};
63
64
}
// namespace tt
tt::axis_aligned_rectangle
Class which represents an axis-aligned rectangle.
Definition
axis_aligned_rectangle.hpp:20
tt::corner_shapes
Definition
corner_shapes.hpp:9
tt::numeric_array< float, 4 >
tt::sfloat_rgba32
Definition
sfloat_rgba32.hpp:15
std::array
Generated on Mon Apr 22 2024 12:53:30 for HikoGUI by
1.10.0