FastLED 3.10.6
Loading...
Searching...
No Matches
draw_visitor.h
Go to the documentation of this file.
1#pragma once
2
3#include "fl/stl/int.h"
4#include "fl/stl/span.h"
5
6#include "fl/gfx/gradient.h"
8#include "fl/math/xymap.h"
9#include "fl/stl/move.h"
10#include "fl/stl/noexcept.h"
11
12namespace fl {
13
14// Draws a fl::u8 value to a CRGB array, blending it with the existing color.
17
18 // Copy constructor (assignment deleted due to const members)
21
22 // Move constructor (assignment deleted due to const members)
24 : mColor(fl::move(other.mColor)), mXYMap(fl::move(other.mXYMap)), mOut(other.mOut) {}
26
27 void draw(const vec2<fl::u16> &pt, fl::u32 index, fl::u8 value);
28 const CRGB mColor;
31};
32
34 XYDrawGradient(const Gradient &gradient, const XYMap &xymap, fl::span<CRGB> out);
35
36 // Copy constructor (assignment deleted due to const members)
38 XYDrawGradient &operator=(const XYDrawGradient &other) = delete;
39
40 // Move constructor (assignment deleted due to const members)
42 : mGradient(fl::move(other.mGradient)), mXYMap(fl::move(other.mXYMap)), mOut(other.mOut) {}
44
45 void draw(const vec2<fl::u16> &pt, fl::u32 index, fl::u8 value);
49};
50
54
55inline void XYDrawComposited::draw(const vec2<fl::u16> &pt, fl::u32 index,
56 fl::u8 value) {
58 CRGB &c = mOut[index];
59 CRGB blended = mColor;
60 blended.fadeToBlackBy(255 - value);
61 c = CRGB::blendAlphaMaxChannel(blended, c);
62}
63
65 const XYMap &xymap, fl::span<CRGB> out)
66 : mGradient(gradient), mXYMap(xymap), mOut(out) {}
67
68inline void XYDrawGradient::draw(const vec2<fl::u16> &pt, fl::u32 index,
69 fl::u8 value) {
71 CRGB c = mGradient.colorAt(value);
72 mOut[index] = c;
73}
74
75} // namespace fl
XYMap xymap
#define FASTLED_UNUSED(x)
unsigned char u8
Definition stdint.h:131
constexpr remove_reference< T >::type && move(T &&t) FL_NO_EXCEPT
Definition move.h:28
constexpr int type_rank< T >::value
InputGamut g FL_NO_EXCEPT
Definition rgbw.h:121
Base definition for an LED controller.
Definition crgb.hpp:179
static CRGB blendAlphaMaxChannel(const CRGB &upper, const CRGB &lower) FL_NO_EXCEPT
Definition crgb.cpp.hpp:59
CRGB & fadeToBlackBy(u8 fadefactor) FL_NO_EXCEPT
fadeToBlackBy is a synonym for nscale8(), as a fade instead of a scale
Definition crgb.cpp.hpp:109
Representation of an 8-bit RGB pixel (Red, Green, Blue)
Definition crgb.h:38
XYDrawComposited(XYDrawComposited &&other) FL_NO_EXCEPT
XYDrawComposited(const XYDrawComposited &other) FL_NO_EXCEPT=default
XYDrawComposited & operator=(XYDrawComposited &&other) FL_NO_EXCEPT=delete
XYDrawComposited(const CRGB &color, const XYMap &xymap, fl::span< CRGB > out)
void draw(const vec2< fl::u16 > &pt, fl::u32 index, fl::u8 value)
XYDrawComposited & operator=(const XYDrawComposited &other)=delete
fl::span< CRGB > mOut
XYDrawGradient(const Gradient &gradient, const XYMap &xymap, fl::span< CRGB > out)
XYDrawGradient & operator=(XYDrawGradient &&other) FL_NO_EXCEPT=delete
XYDrawGradient(const XYDrawGradient &other) FL_NO_EXCEPT=default
const Gradient mGradient
XYDrawGradient & operator=(const XYDrawGradient &other)=delete
XYDrawGradient(XYDrawGradient &&other) FL_NO_EXCEPT
fl::span< CRGB > mOut
void draw(const vec2< fl::u16 > &pt, fl::u32 index, fl::u8 value)
const XYMap mXYMap