Representation of an 8-bit RGB pixel (Red, Green, Blue) @note **Performance Tip**: This struct provides both inline single-pixel methods and references to bulk array operations. For best performance: - **Single pixels or real-time updates**: Use inline methods (setHSV(), nscale8_video(), etc.) - Low latency (avoids function call overhead) - Good for unpredictable, dynamic patterns - **Array opera
| 36 | /// - **See also**: fill_rainbow(), fill_gradient<>(), nscale8_video(), fadeLightBy(), |
| 37 | /// fadeToBlackBy(), blur1d(), blur2d() for high-performance batch operations |
| 38 | struct CRGB { |
| 39 | typedef u8 fp; |
| 40 | union { |
| 41 | struct { |
| 42 | union { |
| 43 | u8 r; ///< Red channel value |
| 44 | u8 red; ///< @copydoc r |
| 45 | }; |
| 46 | union { |
| 47 | u8 g; ///< Green channel value |
| 48 | u8 green; ///< @copydoc g |
| 49 | }; |
| 50 | union { |
| 51 | u8 b; ///< Blue channel value |
| 52 | u8 blue; ///< @copydoc b |
| 53 | }; |
| 54 | }; |
| 55 | /// Access the red, green, and blue data as an array. |
| 56 | /// Where: |
| 57 | /// * `raw[0]` is the red value |
| 58 | /// * `raw[1]` is the green value |
| 59 | /// * `raw[2]` is the blue value |
| 60 | u8 raw[3]; |
| 61 | }; |
| 62 | |
| 63 | static CRGB blend(const CRGB& p1, const CRGB& p2, fract8 amountOfP2) FL_NOEXCEPT; |
| 64 | static CRGB blendAlphaMaxChannel(const CRGB& upper, const CRGB& lower) FL_NOEXCEPT; |
| 65 | |
| 66 | /// Downscale a CRGB matrix (or strip) to the smaller size. |
| 67 | static void downscale(const CRGB* src, const XYMap& srcXY, CRGB* dst, const XYMap& dstXY) FL_NOEXCEPT; |
| 68 | static void upscale(const CRGB* src, const XYMap& srcXY, CRGB* dst, const XYMap& dstXY) FL_NOEXCEPT; |
| 69 | |
| 70 | // Are you using WS2812 (or other RGB8 LEDS) to display video? |
| 71 | // Does it look washed out and under-saturated? |
| 72 | // |
| 73 | // Have you tried gamma correction but hate how it decimates the color into 8 colors per component? |
| 74 | // |
| 75 | // This is an alternative to gamma correction that preserves the hue but boosts the saturation. |
| 76 | // |
| 77 | // decimating the color from 8 bit -> gamma -> 8 bit (leaving only 8 colors for each component). |
| 78 | // work well with WS2812 (and other RGB8) led displays. |
| 79 | // This function converts to HSV16, boosts the saturation, and converts back to RGB8. |
| 80 | // Note that when both boost_saturation and boost_contrast are true the resulting |
| 81 | // pixel will be nearly the same as if you had used gamma correction pow = 2.0. |
| 82 | CRGB colorBoost(EaseType saturation_function = EaseType::EASE_NONE, EaseType luminance_function = EaseType::EASE_NONE) const FL_NOEXCEPT; |
| 83 | static void colorBoost(const CRGB* src, CRGB* dst, size_t count, EaseType saturation_function = EaseType::EASE_NONE, EaseType luminance_function = EaseType::EASE_NONE) FL_NOEXCEPT; |
| 84 | |
| 85 | // Want to do advanced color manipulation in HSV and write back to CRGB? |
| 86 | // You want to use HSV16, which is much better at preservering the color |
| 87 | // space than hsv8. |
| 88 | HSV16 toHSV16() const FL_NOEXCEPT; |
| 89 | |
| 90 | /// Array access operator to index into the CRGB object |
| 91 | /// @param x the index to retrieve (0-2) |
| 92 | /// @returns the CRGB::raw value for the given index |
| 93 | FASTLED_FORCE_INLINE u8& operator[] (u8 x) FL_NOEXCEPT |
| 94 | { |
| 95 | return raw[x]; |