HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
sfloat_rgb32.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 "../geometry/numeric_array.hpp"
8#include <algorithm>
9
10namespace tt {
11
13 // Red, Green, Blue in binary32 (native endian).
15
16public:
17 sfloat_rgb32() = default;
18 sfloat_rgb32(sfloat_rgb32 const &rhs) noexcept = default;
19 sfloat_rgb32(sfloat_rgb32 &&rhs) noexcept = default;
20 sfloat_rgb32 &operator=(sfloat_rgb32 const &rhs) noexcept = default;
21 sfloat_rgb32 &operator=(sfloat_rgb32 &&rhs) noexcept = default;
22
23 sfloat_rgb32(f32x4 const &rhs) noexcept : v{rhs.r(), rhs.g(), rhs.b()} {}
24
25 sfloat_rgb32 &operator=(f32x4 const &rhs) noexcept {
26 v = {rhs.r(), rhs.g(), rhs.b()};
27 return *this;
28 }
29
30 operator f32x4 () const noexcept {
31 return f32x4{std::get<0>(v), std::get<1>(v), std::get<2>(v), 0.0f};
32 }
33
34 sfloat_rgb32(point3 const &rhs) noexcept : sfloat_rgb32(static_cast<f32x4>(rhs)) {}
35
36 sfloat_rgb32 &operator=(point3 const &rhs) noexcept
37 {
38 return *this = static_cast<f32x4>(rhs);
39 }
40
41 operator point3() const noexcept
42 {
43 return point3{f32x4{*this}};
44 }
45
46 [[nodiscard]] friend bool operator==(sfloat_rgb32 const &lhs, sfloat_rgb32 const &rhs) noexcept {
47 return lhs.v == rhs.v;
48 }
49 [[nodiscard]] friend bool operator!=(sfloat_rgb32 const &lhs, sfloat_rgb32 const &rhs) noexcept {
50 return !(lhs == rhs);
51 }
52};
53
54}
Definition sfloat_rgb32.hpp:12