7#include "fixed_vector.h"
9#include "fx/detail/fx_layer.h"
15#ifndef FASTLED_FX_ENGINE_MAX_FX
16#define FASTLED_FX_ENGINE_MAX_FX 64
19FASTLED_NAMESPACE_BEGIN
25 mLayers[0] = FxLayerRef::New();
26 mLayers[1] = FxLayerRef::New();
29 void startTransition(uint32_t now, uint32_t duration,
Ref<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 FxLayerRef tmp = mLayers[0];
52 mLayers[0] = mLayers[1];
56 FxLayerRef mLayers[2];
57 const uint16_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 (uint16_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) {
Representation of an RGB pixel (Red, Green, Blue)