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/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.
16 XYDrawComposited(const CRGB &color, const XYMap &xymap, fl::span<CRGB> out);
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)
37 XYDrawGradient(const XYDrawGradient &other) FL_NOEXCEPT = default;
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
53 : mColor(color), mXYMap(xymap), mOut(out) {}
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
constexpr remove_reference< T >::type && move(T &&t) FL_NOEXCEPT
Definition s16x16x4.h:28
unsigned char u8
Definition s16x16x4.h:132
constexpr int type_rank< T >::value
Base definition for an LED controller.
Definition crgb.hpp:179
#define FASTLED_UNUSED(x)
#define FL_NOEXCEPT
static CRGB blendAlphaMaxChannel(const CRGB &upper, const CRGB &lower) FL_NOEXCEPT
Definition crgb.cpp.hpp:59
CRGB & fadeToBlackBy(u8 fadefactor) FL_NOEXCEPT
fadeToBlackBy is a synonym for nscale8(), as a fade instead of a scale
Definition crgb.cpp.hpp:111
Representation of an 8-bit RGB pixel (Red, Green, Blue)
Definition crgb.h:38
XYDrawComposited(XYDrawComposited &&other) FL_NOEXCEPT
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
XYDrawComposited & operator=(XYDrawComposited &&other) FL_NOEXCEPT=delete
XYDrawComposited(const XYDrawComposited &other) FL_NOEXCEPT=default
XYDrawGradient(const Gradient &gradient, const XYMap &xymap, fl::span< CRGB > out)
XYDrawGradient(const XYDrawGradient &other) FL_NOEXCEPT=default
const Gradient mGradient
XYDrawGradient & operator=(const XYDrawGradient &other)=delete
fl::span< CRGB > mOut
XYDrawGradient & operator=(XYDrawGradient &&other) FL_NOEXCEPT=delete
XYDrawGradient(XYDrawGradient &&other) FL_NOEXCEPT
void draw(const vec2< fl::u16 > &pt, fl::u32 index, fl::u8 value)
const XYMap mXYMap