FastLED 3.9.15
Loading...
Searching...
No Matches

◆ addFx() [2/2]

int fl::FxEngine::addFx ( FxPtr effect)

Adds a new effect to the engine.

Parameters
effectPointer to the effect to be added.
Returns
The index of the added effect, or -1 if the effect couldn't be added.

Definition at line 16 of file fx_engine.cpp.

16 {
17 float fps = 0;
18 if (mInterpolate && effect->hasFixedFrameRate(&fps)) {
19 // Wrap the effect in a VideoFxWrapper so that we can get
20 // interpolation.
21 VideoFxWrapperPtr vid_fx = VideoFxWrapperPtr::New(effect);
22 vid_fx->setFade(0, 0); // No fade for interpolated effects
23 effect = vid_fx;
24 }
25 bool auto_set = mEffects.empty();
26 bool ok = mEffects.insert(mCounter, effect).first;
27 if (!ok) {
28 return -1;
29 }
30 if (auto_set) {
32 mCompositor.startTransition(0, 0, effect);
33 }
34 return mCounter++;
35}
FxCompositor mCompositor
Handles effect transitions and rendering.
Definition fx_engine.h:122
int mCurrId
Id of the current effect.
Definition fx_engine.h:123
IntFxMap mEffects
Collection of effects.
Definition fx_engine.h:121
bool mInterpolate
Definition fx_engine.h:126

References mCompositor, mCounter, mCurrId, mEffects, and mInterpolate.