UdonLibrary
1.0.0
機械システム研究部 C++ ライブラリ
Toggle main menu visibility
読み取り中…
検索中…
一致する文字列を見つけられません
HSV.hpp
[詳解]
1
//
2
// HSV色空間 前方定義
3
//
4
// Copyright (c) 2022 udonrobo
5
//
6
7
#pragma once
8
9
#include <
Udon/Traits/EnumerableMacro.hpp
>
10
#include <
Udon/Serializer/Serializer.hpp
>
11
12
namespace
Udon
13
{
14
15
struct
RGB
;
16
17
19
struct
HSV
20
{
21
23
using
ValueType
= uint8_t;
24
26
ValueType
h
;
27
29
ValueType
s
;
30
32
ValueType
v
;
33
35
constexpr
HSV
() noexcept
36
:
h
()
37
,
s
()
38
,
v
()
39
{
40
}
41
46
constexpr
HSV
(
ValueType
h
,
ValueType
s
,
ValueType
v
) noexcept
47
:
h
(
h
)
48
,
s
(
s
)
49
,
v
(
v
)
50
{
51
}
52
55
HSV
(uint32_t hsv) noexcept
56
:
h
(
static_cast<
ValueType
>
(hsv >> 16))
57
,
s
(
static_cast<
ValueType
>
(hsv >> 8))
58
,
v
(
static_cast<
ValueType
>
(hsv >> 0))
59
{
60
}
61
64
HSV
(
const
RGB
& rgb)
noexcept
;
65
67
HSV
(
const
HSV
&) =
default
;
68
70
HSV
&
operator=
(
const
HSV
&) =
default
;
71
73
friend
constexpr
bool
operator==
(
const
HSV
& lhs,
const
HSV
& rhs)
noexcept
74
{
75
return
lhs.h == rhs.h && lhs.s == rhs.s && lhs.v == rhs.v;
76
}
77
79
friend
constexpr
bool
operator!=
(
const
HSV
& lhs,
const
HSV
& rhs)
noexcept
80
{
81
return
not(lhs == rhs);
82
}
83
84
explicit
constexpr
operator
bool() const noexcept
85
{
86
return
h
or
s
or
v
;
87
}
88
91
uint32_t
to24bit
() const noexcept
92
{
93
return
static_cast<
uint32_t
>
(
h
) << 16 |
static_cast<
uint32_t
>
(
s
) << 8 |
static_cast<
uint32_t
>
(
v
) << 0;
94
}
95
98
RGB
toRGB
() const noexcept;
99
100
#ifdef ARDUINO
102
void
show()
const
103
{
104
Serial.print(
F
(
"h: "
)), Serial.print(
h
), Serial.print(
'\t'
);
105
Serial.print(
F
(
"s: "
)), Serial.print(
s
), Serial.print(
'\t'
);
106
Serial.print(
F
(
"v: "
)), Serial.print(
v
), Serial.print(
'\t'
);
107
}
108
#endif
109
110
UDON_ENUMERABLE
(
h
,
s
,
v
);
111
};
112
113
}
// namespace Udon
EnumerableMacro.hpp
Serializer.hpp
F
#define F(x)
Definition
Show.hpp:17
Udon
Definition
Bit.hpp:12
Udon::HSV::HSV
HSV(uint32_t hsv) noexcept
コンストラクタ
Definition
HSV.hpp:55
Udon::HSV::operator!=
friend constexpr bool operator!=(const HSV &lhs, const HSV &rhs) noexcept
比較演算子
Definition
HSV.hpp:79
Udon::HSV::HSV
constexpr HSV(ValueType h, ValueType s, ValueType v) noexcept
コンストラクタ
Definition
HSV.hpp:46
Udon::HSV::operator=
HSV & operator=(const HSV &)=default
コピー代入演算子
Udon::HSV::h
ValueType h
色相
Definition
HSV.hpp:26
Udon::HSV::UDON_ENUMERABLE
UDON_ENUMERABLE(h, s, v)
Udon::HSV::s
ValueType s
彩度
Definition
HSV.hpp:29
Udon::HSV::v
ValueType v
明度
Definition
HSV.hpp:32
Udon::HSV::toRGB
RGB toRGB() const noexcept
RGB色空間に変換
Definition
HSV.hpp:30
Udon::HSV::to24bit
uint32_t to24bit() const noexcept
24bit値へ変換
Definition
HSV.hpp:91
Udon::HSV::HSV
HSV(const HSV &)=default
コピーコンストラクタ
Udon::HSV::ValueType
uint8_t ValueType
要素の型
Definition
HSV.hpp:23
Udon::HSV::HSV
constexpr HSV() noexcept
デフォルトコンストラクタ
Definition
HSV.hpp:35
Udon::HSV::operator==
friend constexpr bool operator==(const HSV &lhs, const HSV &rhs) noexcept
比較演算子
Definition
HSV.hpp:73
Udon::RGB
RGB色空間
Definition
RGB.hpp:21