FastLED 3.9.15
Loading...
Searching...
No Matches
draw_visitor.h
Go to the documentation of this file.
1#pragma once
2
3#include "fl/stdint.h"
4#include "fl/int.h"
5
6#include "crgb.h"
7#include "fl/geometry.h"
8#include "fl/gradient.h"
9#include "fl/namespace.h"
10#include "fl/unused.h"
11#include "fl/xymap.h"
12#include "fl/move.h"
13
14namespace fl {
15
16// Draws a fl::u8 value to a CRGB array, blending it with the existing color.
18 XYDrawComposited(const CRGB &color, const XYMap &xymap, CRGB *out);
19
20 // Copy constructor (assignment deleted due to const members)
21 XYDrawComposited(const XYDrawComposited &other) = default;
23
24 // Move constructor (assignment deleted due to const members)
26 : mColor(fl::move(other.mColor)), mXYMap(fl::move(other.mXYMap)), mOut(other.mOut) {}
27 XYDrawComposited &operator=(XYDrawComposited &&other) noexcept = delete;
28
29 void draw(const vec2<fl::u16> &pt, fl::u32 index, fl::u8 value);
30 const CRGB mColor;
33};
34
36 XYDrawGradient(const Gradient &gradient, const XYMap &xymap, CRGB *out);
37
38 // Copy constructor (assignment deleted due to const members)
39 XYDrawGradient(const XYDrawGradient &other) = default;
40 XYDrawGradient &operator=(const XYDrawGradient &other) = delete;
41
42 // Move constructor (assignment deleted due to const members)
43 XYDrawGradient(XYDrawGradient &&other) noexcept
44 : mGradient(fl::move(other.mGradient)), mXYMap(fl::move(other.mXYMap)), mOut(other.mOut) {}
45 XYDrawGradient &operator=(XYDrawGradient &&other) noexcept = delete;
46
47 void draw(const vec2<fl::u16> &pt, fl::u32 index, fl::u8 value);
51};
52
54 CRGB *out)
55 : mColor(color), mXYMap(xymap), mOut(out) {}
56
57inline void XYDrawComposited::draw(const vec2<fl::u16> &pt, fl::u32 index,
58 fl::u8 value) {
60 CRGB &c = mOut[index];
61 CRGB blended = mColor;
62 blended.fadeToBlackBy(255 - value);
63 c = CRGB::blendAlphaMaxChannel(blended, c);
64}
65
67 const XYMap &xymap, CRGB *out)
68 : mGradient(gradient), mXYMap(xymap), mOut(out) {}
69
70inline void XYDrawGradient::draw(const vec2<fl::u16> &pt, fl::u32 index,
71 fl::u8 value) {
73 CRGB c = mGradient.colorAt(value);
74 mOut[index] = c;
75}
76
77} // namespace fl
XYMap xymap(WIDTH, HEIGHT, SERPENTINE)
Defines the red, green, and blue (RGB) pixel struct.
Implements the FastLED namespace macros.
constexpr remove_reference< T >::type && move(T &&t) noexcept
Definition move.h:27
unsigned char u8
Definition int.h:17
IMPORTANT!
Definition crgb.h:20
CRGB & fadeToBlackBy(fl::u8 fadefactor)
fadeToBlackBy is a synonym for nscale8(), as a fade instead of a scale
static CRGB blendAlphaMaxChannel(const CRGB &upper, const CRGB &lower)
Definition crgb.cpp:60
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:86
XYDrawComposited & operator=(XYDrawComposited &&other) noexcept=delete
XYDrawComposited(const XYDrawComposited &other)=default
XYDrawComposited(const CRGB &color, const XYMap &xymap, CRGB *out)
XYDrawComposited(XYDrawComposited &&other) noexcept
void draw(const vec2< fl::u16 > &pt, fl::u32 index, fl::u8 value)
XYDrawComposited & operator=(const XYDrawComposited &other)=delete
XYDrawGradient(const XYDrawGradient &other)=default
const Gradient mGradient
XYDrawGradient & operator=(const XYDrawGradient &other)=delete
XYDrawGradient(const Gradient &gradient, const XYMap &xymap, CRGB *out)
void draw(const vec2< fl::u16 > &pt, fl::u32 index, fl::u8 value)
XYDrawGradient & operator=(XYDrawGradient &&other) noexcept=delete
const XYMap mXYMap
XYDrawGradient(XYDrawGradient &&other) noexcept
#define FASTLED_UNUSED(x)
Definition unused.h:4