FastLED 3.9.15
Loading...
Searching...
No Matches
crgb_extra.cpp.hpp
Go to the documentation of this file.
1// ok no header
9
10#define FASTLED_INTERNAL
11#include "crgb.h"
12#include "hsv2rgb.h"
13#include "fl/gfx/hsv16.h"
14#include "fl/stl/noexcept.h"
15
16// Implementations are in fl namespace since CRGB is defined there
17namespace fl {
18
19// ============================================================================
20// HSV8 Methods
21// ============================================================================
22
24CRGB::CRGB(const hsv8& rhs) {
25 CHSV hsv_color(rhs.h, rhs.s, rhs.v);
26 CRGB rgb_result;
27 hsv2rgb_rainbow(hsv_color, rgb_result);
28 r = rgb_result.r;
29 g = rgb_result.g;
30 b = rgb_result.b;
31}
32
35 CHSV hsv_color(rhs.h, rhs.s, rhs.v);
36 CRGB rgb_result;
37 hsv2rgb_rainbow(hsv_color, rgb_result);
38 r = rgb_result.r;
39 g = rgb_result.g;
40 b = rgb_result.b;
41 return *this;
42}
43
44// ============================================================================
45// SetHSV Methods
46// ============================================================================
47
49CRGB& CRGB::setHSV(u8 hue, u8 sat, u8 val) {
50 CHSV hsv_color(hue, sat, val);
51 hsv2rgb_rainbow(hsv_color, *this);
52 return *this;
53}
54
57 CHSV hsv_color(hue, 255, 255);
58 hsv2rgb_rainbow(hsv_color, *this);
59 return *this;
60}
61
62// ============================================================================
63// HSV16 Methods
64// ============================================================================
65
66CRGB CRGB::colorBoost(EaseType saturation_function, EaseType luminance_function) const {
67 HSV16 hsv(*this);
68 return hsv.colorBoost(saturation_function, luminance_function);
69}
70
71void CRGB::colorBoost(const CRGB* src, CRGB* dst, size_t count, EaseType saturation_function, EaseType luminance_function) {
72 for (size_t i = 0; i < count; i++) {
73 dst[i] = src[i].colorBoost(saturation_function, luminance_function);
74 }
75}
76
78 return HSV16(*this);
79}
80
81// Constructor implementation for HSV16 -> CRGB automatic conversion
82CRGB::CRGB(const HSV16& rhs) {
83 *this = rhs.ToRGB();
84}
85
86} // namespace fl
uint8_t hue
Definition advanced.h:94
Defines the 8-bit red, green, and blue (RGB) pixel type in the fl namespace.
fl::hsv8 CHSV
Definition chsv.h:11
CRGB hsv2rgb_rainbow(const CHSV &hsv)
Functions to convert from the HSV colorspace to the RGB colorspace.
unsigned char u8
Definition stdint.h:131
EaseType
Definition ease.h:27
Base definition for an LED controller.
Definition crgb.hpp:179
#define FL_NOEXCEPT
CRGB colorBoost(EaseType saturation_function=EaseType::EASE_NONE, EaseType luminance_function=EaseType::EASE_NONE) const FL_NOEXCEPT
CRGB & setHSV(u8 hue, u8 sat, u8 val) FL_NOEXCEPT
Allow assignment from hue, saturation, and value.
FASTLED_FORCE_INLINE CRGB & operator=(const CRGB &rhs) FL_NOEXCEPT=default
Allow assignment from one RGB struct to another.
FASTLED_FORCE_INLINE CRGB() FL_NOEXCEPT
Default constructor.
Definition crgb.h:111
HSV16 toHSV16() const FL_NOEXCEPT
CRGB & setHue(u8 hue) FL_NOEXCEPT
Allow assignment from just a hue.
CRGB ToRGB() const
CRGB colorBoost(EaseType saturation_function=EaseType::EASE_IN_QUAD, EaseType luminance_function=EaseType::EASE_NONE) const
Representation of an HSV pixel (hue, saturation, value (aka brightness)).
Definition hsv.h:16