FastLED 3.10.6
Loading...
Searching...
No Matches
hsv.h
Go to the documentation of this file.
1
3
4#pragma once
5
6#include "fl/stl/int.h"
8#include "fl/stl/noexcept.h"
9
10namespace fl {
11
14
16struct hsv8 {
17 union {
18 struct {
19 union {
23 fl::u8 hue;
24 fl::u8 h;
25 };
26 union {
30 fl::u8 sat;
31 fl::u8 s;
32 };
33 union {
37 fl::u8 val;
38 fl::u8 v;
39 };
40 };
41
46 fl::u8 raw[3];
47 };
48
56
59 {
60 return raw[x];
61 }
62
76 friend FASTLED_FORCE_INLINE bool operator==(const hsv8& lhs,
77 const hsv8& rhs) FL_NO_EXCEPT
78 {
79 return lhs.h == rhs.h && lhs.s == rhs.s && lhs.v == rhs.v;
80 }
81
83 friend FASTLED_FORCE_INLINE bool operator!=(const hsv8& lhs,
84 const hsv8& rhs) FL_NO_EXCEPT
85 {
86 return !(lhs == rhs);
87 }
88
91 constexpr hsv8() FL_NO_EXCEPT : h(0), s(0), v(0) { }
92
97 constexpr hsv8( fl::u8 ih, fl::u8 is, fl::u8 iv) FL_NO_EXCEPT
98 : h(ih), s(is), v(iv)
99 {
100 }
101
103 constexpr hsv8(const hsv8& rhs) FL_NO_EXCEPT : h(rhs.h), s(rhs.s), v(rhs.v) { }
104
106 hsv8& operator= (const hsv8& rhs) FL_NO_EXCEPT = default;
107
114 {
115 h = ih;
116 s = is;
117 v = iv;
118 return *this;
119 }
120};
121
123typedef enum {
128 HUE_AQUA = 128,
129 HUE_BLUE = 160,
131 HUE_PINK = 224
132} HSVHue;
133
135
136} // namespace fl
HSVHue
Pre-defined hue values for hsv8 objects.
Definition hsv.h:123
#define FASTLED_FORCE_INLINE
@ HUE_BLUE
Blue (225°)
Definition hsv.h:129
@ HUE_RED
Red (0°)
Definition hsv.h:124
@ HUE_AQUA
Aqua (180°)
Definition hsv.h:128
@ HUE_PINK
Pink (315°)
Definition hsv.h:131
@ HUE_GREEN
Green (135°)
Definition hsv.h:127
@ HUE_YELLOW
Yellow (90°)
Definition hsv.h:126
@ HUE_ORANGE
Orange (45°)
Definition hsv.h:125
@ HUE_PURPLE
Purple (270°)
Definition hsv.h:130
fl::u8 value
Color value (brightness).
unsigned char u8
Definition stdint.h:131
InputGamut g FL_NO_EXCEPT
Definition rgbw.h:121
Base definition for an LED controller.
Definition crgb.hpp:179
FASTLED_FORCE_INLINE fl::u8 & operator[](fl::u8 x) FL_NO_EXCEPT
Array access operator to index into the hsv8 object.
Definition hsv.h:52
friend FASTLED_FORCE_INLINE bool operator==(const hsv8 &lhs, const hsv8 &rhs) FL_NO_EXCEPT
Compare two HSV colors field by field.
Definition hsv.h:76
constexpr hsv8() FL_NO_EXCEPT
Default constructor.
Definition hsv.h:91
FASTLED_FORCE_INLINE hsv8 & setHSV(fl::u8 ih, fl::u8 is, fl::u8 iv) FL_NO_EXCEPT
Assign new HSV values.
Definition hsv.h:113
constexpr hsv8(fl::u8 ih, fl::u8 is, fl::u8 iv) FL_NO_EXCEPT
Allow construction from hue, saturation, and value.
Definition hsv.h:97
constexpr hsv8(const hsv8 &rhs) FL_NO_EXCEPT
Allow copy construction.
Definition hsv.h:103
friend FASTLED_FORCE_INLINE bool operator!=(const hsv8 &lhs, const hsv8 &rhs) FL_NO_EXCEPT
Compare two HSV colors field by field.
Definition hsv.h:83
hsv8 & operator=(const hsv8 &rhs) FL_NO_EXCEPT=default
Allow copy construction.