Skip to content

EffectBase

Source: EffectBase.h

EffectBase

class EffectBase
src/light/effects/EffectBase.h:66

Inherits: MoonModule

Light-domain MoonModule subclass for effects — adds the rendering context.

Design. A zero-state convenience layer: it holds no data of its own, just accessors (buffer(), width(), height(), depth(), elapsed(), …) that forward to the parent Layer. An effect reads its rendering context through these instead of caching a Layer* and the dimensions itself. DriverBase plays the same role for drivers against the Drivers container.

Animation guidelines. Effects use BPM (beats per minute) for speed controls, not abstract 0–255 ranges, giving users a musical reference (60 BPM = one beat per second, 120 BPM = two; default 60). Animation must be resolution-independent: multiply the time offset by the panel dimension (width or height) so the perceived visual speed is the same regardless of display size — otherwise large displays look sluggish and small ones frantic at the same BPM. Animation is driven by elapsed millis (via elapsed()), not frame count, so speed stays consistent regardless of FPS; the speed slider controls the animation dynamics, never the framerate, which should always be maximal for smooth motion.

Prior art: MoonLight's Node + VirtualLayer — effects access layer->width()/height()/depth() directly via the VirtualLayer pointer (no separate EffectBase), buffer access via layer->virtualChannels, time via timeMicros() (https://github.com/ewowi/MoonLight/blob/main/src/MoonBase/Nodes.h, https://github.com/ewowi/MoonLight/blob/main/src/MoonLight/Layers/VirtualLayer.h).

Public Methods

virtual inline ModuleRole role() const override : Role for type identification (no RTTI needed).

virtual inline Dim dimensions() const : Which axes the effect iterates — a claim, not a guarantee about the layer.

inline Layer * layer() const : Parent is always a Layer (defined in [Layer.h] after Layer is complete).

inline uint8_t * buffer()

inline lengthType width() const

inline lengthType height() const

inline lengthType depth() const

inline uint8_t channelsPerLight() const

inline nrOfLightsType nrOfLights() const

inline uint32_t elapsed() const : Milliseconds since render start — drive animation off this, not frame count.