FastLED 3.10.8
Loading...
Searching...
No Matches

◆ draw()

void fl::Blend2d::draw ( DrawContext context)
overridevirtual
Parameters
nowThe current time in milliseconds. Fx writers are encouraged to use this instead of millis() directly as this will more deterministic behavior.

Implements fl::Fx.

Definition at line 57 of file blend.cpp.hpp.

57 {
58 mFrame->clear();
59 mFrameTransform->clear();
60
61 // Draw each layer in reverse order and applying the blending.
62 bool first = true;
63 for (auto it = mLayers.begin(); it != mLayers.end(); ++it) {
64 DrawContext tmp_ctx = context;
65 tmp_ctx.leds = mFrame->rgb();
66 auto &fx = it->fx;
67 fx->draw(tmp_ctx);
70 first = false;
71 // Apply the blur effect per effect.
72 u8 blur_amount = it->blur_amount;
73 if (blur_amount > 0) {
74 const XYMap &xyMap = fx->getXYMap();
75 u8 blur_passes = fl::max(1, it->blur_passes);
76 for (u8 i = 0; i < blur_passes; ++i) {
77 // Apply the blur effect
78 blur2d(mFrame->rgb().data(), mXyMap.getWidth(), mXyMap.getHeight(),
79 blur_amount, xyMap);
80 }
81 }
82 mFrame->draw(mFrameTransform->rgb(), mode);
83 }
84
85 if (mGlobalBlurAmount > 0) {
86 // Apply the blur effect
87 u16 width = mXyMap.getWidth();
88 u16 height = mXyMap.getHeight();
90 fl::span<CRGB> rgb = mFrameTransform->rgb();
91 u8 blur_passes = fl::max(1, mGlobalBlurPasses);
92 for (u8 i = 0; i < blur_passes; ++i) {
93 // Apply the blur effect
95 }
96 }
97
98 // Copy the final result to the output
99 // memcpy(mFrameTransform->rgb(), context.leds, sizeof(CRGB) *
100 // mXyMap.getTotal());
101 mFrameTransform->drawXY(context.leds, mXyMap,
103}
fl::shared_ptr< Frame > mFrameTransform
Definition blend.h:59
u8 mGlobalBlurAmount
Definition blend.h:60
fl::shared_ptr< Frame > mFrame
Definition blend.h:58
u8 mGlobalBlurPasses
Definition blend.h:61
vector< Entry > mLayers
Definition blend.h:57
XYMap mXyMap
Definition fx2d.h:31
u16 xyMap(u16 x, u16 y) const FL_NO_EXCEPT
Definition fx2d.h:21
::fl::DrawContext DrawContext
Definition fx.h:21
static XYMap constructRectangularGrid(u16 width, u16 height, u16 offset=0) FL_NO_EXCEPT
Definition xymap.cpp.hpp:36
unsigned char u8
Definition stdint.h:131
constexpr common_type_t< T, U > max(T a, U b) FL_NO_EXCEPT
Definition math.h:75
void blur2d(fl::span< CRGB > leds, u8 width, u8 height, fract8 blur_amount, const XYMap &xymap) FL_NO_EXCEPT
Definition blur.h:153
u8 u8 height
Definition blur.h:186
u8 width
Definition blur.h:186
DrawMode
Definition draw_mode.h:5
@ DRAW_MODE_OVERWRITE
Definition draw_mode.h:5
@ DRAW_MODE_BLEND_BY_MAX_BRIGHTNESS
Definition draw_mode.h:5

References fl::blur2d(), fl::XYMap::constructRectangularGrid(), fl::DRAW_MODE_BLEND_BY_MAX_BRIGHTNESS, fl::DRAW_MODE_OVERWRITE, fl::FL_NO_EXCEPT, fl::height, fl::DrawContext::leds, fl::max(), mFrame, mFrameTransform, mGlobalBlurAmount, mGlobalBlurPasses, mLayers, fl::Fx2d::mXyMap, fl::width, and fl::Fx2d::xyMap().

+ Here is the call graph for this function: