FastLED 3.9.15
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
65 constexpr hsv8() FL_NOEXCEPT : h(0), s(0), v(0) { }
66
71 constexpr hsv8( fl::u8 ih, fl::u8 is, fl::u8 iv) FL_NOEXCEPT
72 : h(ih), s(is), v(iv)
73 {
74 }
75
77 constexpr hsv8(const hsv8& rhs) FL_NOEXCEPT : h(rhs.h), s(rhs.s), v(rhs.v) { }
78
80 hsv8& operator= (const hsv8& rhs) FL_NOEXCEPT = default;
81
88 {
89 h = ih;
90 s = is;
91 v = iv;
92 return *this;
93 }
94};
95
97typedef enum {
98 HUE_RED = 0,
102 HUE_AQUA = 128,
103 HUE_BLUE = 160,
105 HUE_PINK = 224
106} HSVHue;
107
109
110} // namespace fl
HSVHue
Pre-defined hue values for hsv8 objects.
Definition hsv.h:97
@ HUE_BLUE
Blue (225°)
Definition hsv.h:103
@ HUE_RED
Red (0°)
Definition hsv.h:98
@ HUE_AQUA
Aqua (180°)
Definition hsv.h:102
@ HUE_PINK
Pink (315°)
Definition hsv.h:105
@ HUE_GREEN
Green (135°)
Definition hsv.h:101
@ HUE_YELLOW
Yellow (90°)
Definition hsv.h:100
@ HUE_ORANGE
Orange (45°)
Definition hsv.h:99
@ HUE_PURPLE
Purple (270°)
Definition hsv.h:104
fl::u8 value
Color value (brightness).
unsigned char u8
Definition s16x16x4.h:132
unsigned char u8
Definition stdint.h:131
Base definition for an LED controller.
Definition crgb.hpp:179
#define FASTLED_FORCE_INLINE
#define FL_NOEXCEPT
constexpr hsv8(fl::u8 ih, fl::u8 is, fl::u8 iv) FL_NOEXCEPT
Allow construction from hue, saturation, and value.
Definition hsv.h:71
constexpr hsv8(const hsv8 &rhs) FL_NOEXCEPT
Allow copy construction.
Definition hsv.h:77
FASTLED_FORCE_INLINE hsv8 & setHSV(fl::u8 ih, fl::u8 is, fl::u8 iv) FL_NOEXCEPT
Assign new HSV values.
Definition hsv.h:87
hsv8 & operator=(const hsv8 &rhs) FL_NOEXCEPT=default
Allow copy construction.
constexpr hsv8() FL_NOEXCEPT
Default constructor.
Definition hsv.h:65
FASTLED_FORCE_INLINE fl::u8 & operator[](fl::u8 x) FL_NOEXCEPT
Array access operator to index into the hsv8 object.
Definition hsv.h:52