FastLED 3.9.3
Loading...
Searching...
No Matches
chsv.h
1
2#pragma once
3
4#include <stdint.h>
5
6#include "namespace.h"
7
8FASTLED_NAMESPACE_BEGIN
9
11struct CHSV {
12 union {
13 struct {
14 union {
18 uint8_t hue;
19 uint8_t h;
20 };
21 union {
24 uint8_t saturation;
25 uint8_t sat;
26 uint8_t s;
27 };
28 union {
31 uint8_t value;
32 uint8_t val;
33 uint8_t v;
34 };
35 };
41 uint8_t raw[3];
42 };
43
47 inline uint8_t& operator[] (uint8_t x) __attribute__((always_inline))
48 {
49 return raw[x];
50 }
51
53 inline const uint8_t& operator[] (uint8_t x) const __attribute__((always_inline))
54 {
55 return raw[x];
56 }
57
60 constexpr inline CHSV() __attribute__((always_inline)): h(0), s(0), v(0) { }
61
66 constexpr inline CHSV( uint8_t ih, uint8_t is, uint8_t iv) __attribute__((always_inline))
67 : h(ih), s(is), v(iv)
68 {
69 }
70
72 constexpr inline CHSV(const CHSV& rhs) noexcept : h(rhs.h), s(rhs.s), v(rhs.v) { }
73
75 inline CHSV& operator= (const CHSV& rhs) __attribute__((always_inline)) = default;
76
82 inline CHSV& setHSV(uint8_t ih, uint8_t is, uint8_t iv) __attribute__((always_inline))
83 {
84 h = ih;
85 s = is;
86 v = iv;
87 return *this;
88 }
89};
90
92typedef enum {
93 HUE_RED = 0,
94 HUE_ORANGE = 32,
95 HUE_YELLOW = 64,
96 HUE_GREEN = 96,
97 HUE_AQUA = 128,
98 HUE_BLUE = 160,
99 HUE_PURPLE = 192,
100 HUE_PINK = 224
101} HSVHue;
102
103FASTLED_NAMESPACE_END
Representation of an HSV pixel (hue, saturation, value (aka brightness)).
Definition chsv.h:11
CHSV & operator=(const CHSV &rhs)=default
Allow copy construction.
uint8_t v
Color value (brightness).
Definition chsv.h:33
uint8_t raw[3]
Access the hue, saturation, and value data as an array.
Definition chsv.h:41
constexpr CHSV()
Default constructor.
Definition chsv.h:60
uint8_t hue
Color hue.
Definition chsv.h:18
uint8_t sat
Color saturation.
Definition chsv.h:25
constexpr CHSV(const CHSV &rhs) noexcept
Allow copy construction.
Definition chsv.h:72
uint8_t h
Color hue.
Definition chsv.h:19
uint8_t value
Color value (brightness).
Definition chsv.h:31
uint8_t saturation
Color saturation.
Definition chsv.h:24
uint8_t s
Color saturation.
Definition chsv.h:26
constexpr CHSV(uint8_t ih, uint8_t is, uint8_t iv)
Allow construction from hue, saturation, and value.
Definition chsv.h:66
uint8_t val
Color value (brightness).
Definition chsv.h:32
uint8_t & operator[](uint8_t x)
Array access operator to index into the CHSV object.
Definition chsv.h:47
CHSV & setHSV(uint8_t ih, uint8_t is, uint8_t iv)
Assign new HSV values.
Definition chsv.h:82