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 26 of file fx_engine.cpp.hpp.

26 {
27 float fps = 0;
28 if (mInterpolate && effect->hasFixedFrameRate(&fps)) {
29 // Wrap the effect in a VideoFxWrapper so that we can get
30 // interpolation.
31 VideoFxWrapperPtr vid_fx = fl::make_shared<VideoFxWrapper>(effect);
32 vid_fx->setFade(0, 0); // No fade for interpolated effects
33 effect = vid_fx;
34 }
35 bool auto_set = mEffects.empty();
36 bool ok = mEffects.insert(mCounter, effect);
37 if (!ok) {
38 return -1;
39 }
40 if (auto_set) {
42 mCompositor.startTransition(0, 0, effect);
43 }
44 return mCounter++;
45}
FxCompositor mCompositor
Handles effect transitions and rendering.
Definition fx_engine.h:137
int mCurrId
Id of the current effect.
Definition fx_engine.h:138
IntFxMap mEffects
Collection of effects.
Definition fx_engine.h:136
bool mInterpolate
Definition fx_engine.h:142
shared_ptr< T > make_shared(Args &&... args) FL_NOEXCEPT
Definition shared_ptr.h:414

References fl::make_shared(), mCompositor, mCounter, mCurrId, mEffects, and mInterpolate.

Referenced by addFx().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: