FastLED 3.9.15
Loading...
Searching...
No Matches
fx2d.h
Go to the documentation of this file.
1#pragma once
2
3#include "fl/stl/stdint.h"
4
5#include "fl/stl/shared_ptr.h" // For FASTLED_SHARED_PTR macros
6#include "fl/math/xymap.h"
7#include "fl/fx/fx.h"
8
9namespace fl {
10
12
13// Abstract base class for 2D effects that use a grid, which is defined
14// by an XYMap.
15class Fx2d : public Fx {
16 public:
17 // XYMap holds either a function or a look up table to map x, y coordinates
18 // to a 1D index.
19 Fx2d(const XYMap &xyMap) : Fx(xyMap.getTotal()), mXyMap(xyMap) {}
20 u16 xyMap(u16 x, u16 y) const {
21 return mXyMap.mapToIndex(x, y);
22 }
23 u16 getHeight() const { return mXyMap.getHeight(); }
24 u16 getWidth() const { return mXyMap.getWidth(); }
25 void setXYMap(const XYMap &xyMap) { mXyMap = xyMap; }
26 XYMap &getXYMap() { return mXyMap; }
27 const XYMap &getXYMap() const { return mXyMap; }
28
29 protected:
31};
32
33} // namespace fl
void setXYMap(const XYMap &xyMap)
Definition fx2d.h:25
XYMap mXyMap
Definition fx2d.h:30
XYMap & getXYMap()
Definition fx2d.h:26
const XYMap & getXYMap() const
Definition fx2d.h:27
Fx2d(const XYMap &xyMap)
Definition fx2d.h:19
u16 getWidth() const
Definition fx2d.h:24
u16 getHeight() const
Definition fx2d.h:23
u16 xyMap(u16 x, u16 y) const
Definition fx2d.h:20
Fx(u16 numLeds)
Definition fx.h:23
Base definition for an LED controller.
Definition crgb.hpp:179
#define FASTLED_SHARED_PTR(type)
Definition shared_ptr.h:535