MCPcopy Create free account
hub / github.com/FastLED/FastLED / draw

Method draw

src/fl/fx/2d/blend.cpp.hpp:56–102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54}
55
56void Blend2d::draw(DrawContext context) {
57 mFrame->clear();
58 mFrameTransform->clear();
59
60 // Draw each layer in reverse order and applying the blending.
61 bool first = true;
62 for (auto it = mLayers.begin(); it != mLayers.end(); ++it) {
63 DrawContext tmp_ctx = context;
64 tmp_ctx.leds = mFrame->rgb();
65 auto &fx = it->fx;
66 fx->draw(tmp_ctx);
67 DrawMode mode = first ? DrawMode::DRAW_MODE_OVERWRITE
68 : DrawMode::DRAW_MODE_BLEND_BY_MAX_BRIGHTNESS;
69 first = false;
70 // Apply the blur effect per effect.
71 u8 blur_amount = it->blur_amount;
72 if (blur_amount > 0) {
73 const XYMap &xyMap = fx->getXYMap();
74 u8 blur_passes = fl::max(1, it->blur_passes);
75 for (u8 i = 0; i < blur_passes; ++i) {
76 // Apply the blur effect
77 blur2d(mFrame->rgb().data(), mXyMap.getWidth(), mXyMap.getHeight(),
78 blur_amount, xyMap);
79 }
80 }
81 mFrame->draw(mFrameTransform->rgb(), mode);
82 }
83
84 if (mGlobalBlurAmount > 0) {
85 // Apply the blur effect
86 u16 width = mXyMap.getWidth();
87 u16 height = mXyMap.getHeight();
88 XYMap rect = XYMap::constructRectangularGrid(width, height);
89 fl::span<CRGB> rgb = mFrameTransform->rgb();
90 u8 blur_passes = fl::max(1, mGlobalBlurPasses);
91 for (u8 i = 0; i < blur_passes; ++i) {
92 // Apply the blur effect
93 blur2d(rgb, width, height, mGlobalBlurAmount, rect);
94 }
95 }
96
97 // Copy the final result to the output
98 // memcpy(mFrameTransform->rgb(), context.leds, sizeof(CRGB) *
99 // mXyMap.getTotal());
100 mFrameTransform->drawXY(context.leds, mXyMap,
101 DrawMode::DRAW_MODE_OVERWRITE);
102}
103
104void Blend2d::clear() { mLayers.clear(); }
105

Calls 11

maxFunction · 0.85
getXYMapMethod · 0.80
drawXYMethod · 0.80
blur2dFunction · 0.50
clearMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
rgbMethod · 0.45
dataMethod · 0.45
getWidthMethod · 0.45
getHeightMethod · 0.45

Tested by

no test coverage detected