FastLED 3.9.7
Loading...
Searching...
No Matches
chsv.h
Go to the documentation of this file.
1
3
4#pragma once
5
6#include <stdint.h>
7
8#include "fl/namespace.h"
9
11
14
16struct CHSV {
17 union {
18 struct {
19 union {
23 uint8_t hue;
24 uint8_t h;
25 };
26 union {
29 uint8_t saturation;
30 uint8_t sat;
31 uint8_t s;
32 };
33 union {
36 uint8_t value;
37 uint8_t val;
38 uint8_t v;
39 };
40 };
46 uint8_t raw[3];
47 };
48
52 inline uint8_t& operator[] (uint8_t x) __attribute__((always_inline))
53 {
54 return raw[x];
55 }
56
58 inline const uint8_t& operator[] (uint8_t x) const __attribute__((always_inline))
59 {
60 return raw[x];
61 }
62
65 constexpr inline CHSV() __attribute__((always_inline)): h(0), s(0), v(0) { }
66
71 constexpr inline CHSV( uint8_t ih, uint8_t is, uint8_t iv) __attribute__((always_inline))
72 : h(ih), s(is), v(iv)
73 {
74 }
75
77 constexpr inline CHSV(const CHSV& rhs) noexcept : h(rhs.h), s(rhs.s), v(rhs.v) { }
78
80 inline CHSV& operator= (const CHSV& rhs) __attribute__((always_inline)) = default;
81
87 inline CHSV& setHSV(uint8_t ih, uint8_t is, uint8_t iv) __attribute__((always_inline))
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
107
109
HSVHue
Pre-defined hue values for CHSV objects.
Definition chsv.h:97
@ HUE_ORANGE
Orange (45°)
Definition chsv.h:99
@ HUE_BLUE
Blue (225°)
Definition chsv.h:103
@ HUE_PINK
Pink (315°)
Definition chsv.h:105
@ HUE_YELLOW
Yellow (90°)
Definition chsv.h:100
@ HUE_PURPLE
Purple (270°)
Definition chsv.h:104
@ HUE_AQUA
Aqua (180°)
Definition chsv.h:102
@ HUE_GREEN
Green (135°)
Definition chsv.h:101
@ HUE_RED
Red (0°)
Definition chsv.h:98
Implements the FastLED namespace macros.
#define FASTLED_NAMESPACE_END
End of the FastLED namespace.
Definition namespace.h:16
#define FASTLED_NAMESPACE_BEGIN
Start of the FastLED namespace.
Definition namespace.h:14
Representation of an HSV pixel (hue, saturation, value (aka brightness)).
Definition chsv.h:16
CHSV & operator=(const CHSV &rhs)=default
Allow copy construction.
uint8_t v
Color value (brightness).
Definition chsv.h:38
uint8_t raw[3]
Access the hue, saturation, and value data as an array.
Definition chsv.h:46
constexpr CHSV()
Default constructor.
Definition chsv.h:65
uint8_t hue
Color hue.
Definition chsv.h:23
uint8_t sat
Color saturation.
Definition chsv.h:30
constexpr CHSV(const CHSV &rhs) noexcept
Allow copy construction.
Definition chsv.h:77
uint8_t h
Color hue.
Definition chsv.h:24
uint8_t value
Color value (brightness).
Definition chsv.h:36
uint8_t saturation
Color saturation.
Definition chsv.h:29
uint8_t s
Color saturation.
Definition chsv.h:31
constexpr CHSV(uint8_t ih, uint8_t is, uint8_t iv)
Allow construction from hue, saturation, and value.
Definition chsv.h:71
uint8_t val
Color value (brightness).
Definition chsv.h:37
uint8_t & operator[](uint8_t x)
Array access operator to index into the CHSV object.
Definition chsv.h:52
CHSV & setHSV(uint8_t ih, uint8_t is, uint8_t iv)
Assign new HSV values.
Definition chsv.h:87