9#include "fx/detail/fx_layer.h"
15#ifndef FASTLED_FX_ENGINE_MAX_FX
16#define FASTLED_FX_ENGINE_MAX_FX 64
25 mLayers[0] = FxLayerPtr::New();
26 mLayers[1] = FxLayerPtr::New();
29 void startTransition(uint32_t now, uint32_t duration,
fl::Ptr<Fx> nextFx) {
32 mLayers[0]->setFx(nextFx);
35 mLayers[1]->setFx(nextFx);
36 mTransition.start(now, duration);
39 void completeTransition() {
40 if (mLayers[1]->getFx()) {
42 mLayers[1]->release();
47 void draw(uint32_t now, uint32_t warpedTime,
CRGB *finalBuffer);
51 FxLayerPtr tmp = mLayers[0];
52 mLayers[0] = mLayers[1];
56 FxLayerPtr mLayers[2];
57 const uint32_t mNumLeds;
61inline void FxCompositor::draw(uint32_t now, uint32_t warpedTime,
CRGB *finalBuffer) {
62 if (!mLayers[0]->getFx()) {
65 mLayers[0]->draw(warpedTime);
66 uint8_t progress = mTransition.getProgress(now);
68 memcpy(finalBuffer, mLayers[0]->getSurface(),
sizeof(
CRGB) * mNumLeds);
71 mLayers[1]->draw(warpedTime);
72 const CRGB* surface0 = mLayers[0]->getSurface();
73 const CRGB* surface1 = mLayers[1]->getSurface();
75 for (uint32_t i = 0; i < mNumLeds; i++) {
76 const CRGB& p0 = surface0[i];
77 const CRGB& p1 = surface1[i];
78 CRGB out = CRGB::blend(p0, p1, progress);
81 if (progress == 255) {
Defines the red, green, and blue (RGB) pixel struct.
Implements the FastLED namespace macros.
Implements a simple red square effect for 2D LED grids.
Representation of an RGB pixel (Red, Green, Blue)