FastLED 3.10.8
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_NO_EXCEPT
Definition xymap.cpp.hpp:36
shared_ptr< T > make_shared(Args &&... args) FL_NO_EXCEPT
Definition shared_ptr.h:423
enable_if< is_fixed_point< T >::value, T >::type sin(T angle) FL_NO_EXCEPT
enable_if< is_fixed_point< T >::value, T >::type cos(T angle) FL_NO_EXCEPT
vec2< float > vec2f
Definition geometry.h:333
value_type y
Definition geometry.h:191
value_type x
Definition geometry.h:190

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

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_NO_EXCEPT
 
- 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: