FastLED 3.9.15
Loading...
Searching...
No Matches
fl::Fx2dTo1d Class Reference

Detailed Description

Fx2dTo1d samples a 2D effect into a 1D LED strip using a ScreenMap.

This class wraps any Fx2d effect and samples it into a 1D LED strip based on a ScreenMap that defines the coordinate mapping. This is useful for creating effects like sampling a circle from a rectangular grid, or any other arbitrary path through 2D space.

Example usage:

// Create circular sampling pattern
fl::ScreenMap screenmap = fl::ScreenMap(60, 0.5f, [](int index, fl::vec2f& pt_out) {
float angle = (TWO_PI * index) / 60;
pt_out.x = 16.0f + cos(angle) * 15.0f;
pt_out.y = 16.0f + sin(angle) * 15.0f;
});
fl::Animartrix animartrix(xyMap, FIRST_ANIMATION)
#define TWO_PI
XYMap xymap
fl::ScreenMap screenmap
static XYMap constructRectangularGrid(u16 width, u16 height, u16 offset=0) FL_NOEXCEPT
Definition xymap.cpp.hpp:35
vec2< float > vec2f
Definition geometry.h:333
shared_ptr< T > make_shared(Args &&... args) FL_NOEXCEPT
Definition shared_ptr.h:414
enable_if< is_fixed_point< T >::value, T >::type cos(T angle) FL_NOEXCEPT
enable_if< is_fixed_point< T >::value, T >::type sin(T angle) FL_NOEXCEPT
value_type y
Definition geometry.h:191
value_type x
Definition geometry.h:190

Definition at line 36 of file fx2d_to_1d.h.

#include <fx2d_to_1d.h>

+ Inheritance diagram for fl::Fx2dTo1d:
+ Collaboration diagram for fl::Fx2dTo1d:

Public Types

enum  InterpolationMode { NEAREST = int(SampleMode::SAMPLE_NEAREST) , BILINEAR = int(SampleMode::SAMPLE_BILINEAR) }
 Interpolation mode for sampling the 2D grid. More...
 
- Public Types inherited from fl::Fx
using DrawContext = ::fl::DrawContext
 

Public Member Functions

 Fx2dTo1d (u16 numLeds, Fx2dPtr fx2d, const ScreenMap &screenMap, InterpolationMode mode=BILINEAR)
 Construct a 2D-to-1D sampling effect.
 
void draw (DrawContext context) override
 
fl::string fxName () const override
 
Fx2dPtr getFx2d () const
 Get the underlying 2D effect.
 
bool hasFixedFrameRate (float *fps) const override
 
void pause (u32 now) override
 
void resume (u32 now) override
 
void setFx2d (Fx2dPtr fx2d)
 Replace the underlying 2D effect.
 
void setInterpolationMode (InterpolationMode mode)
 Set the interpolation mode.
 
void setScreenMap (const ScreenMap &screenMap)
 Set the screen map for coordinate mapping.
 
- Public Member Functions inherited from fl::Fx1d
 Fx1d (u16 numLeds)
 
void setXmap (const XMap &xMap)
 
u16 xyMap (u16 x) const
 
- Public Member Functions inherited from fl::Fx
 Fx (u16 numLeds)
 
u16 getNumLeds () const
 
virtual void pause (fl::u32 now)
 
virtual void resume (fl::u32 now)
 

Private Attributes

Fx2dPtr mFx2d
 
fl::unique_ptr< CRGB[]> mGrid
 
InterpolationMode mInterpolationMode
 
ScreenMap mScreenMap
 

Additional Inherited Members

- Protected Member Functions inherited from fl::Fx
virtual ~Fx () FL_NOEXCEPT
 
- Protected Attributes inherited from fl::Fx1d
XMap mXMap
 
- Protected Attributes inherited from fl::Fx
u16 mNumLeds
 

The documentation for this class was generated from the following files: