FastLED 3.9.7
Loading...
Searching...
No Matches
fx2d.h
1#pragma once
2
3#include <stdint.h>
4
5#include "fl/xymap.h"
6#include "fl/namespace.h"
7#include "fx/fx.h"
8#include "fl/ptr.h"
9
10namespace fl {
11
12FASTLED_SMART_PTR(Fx2d);
13
14// Abstract base class for 2D effects that use a grid, which is defined
15// by an XYMap.
16class Fx2d : public Fx {
17 public:
18 // XYMap holds either a function or a look up table to map x, y coordinates to a 1D index.
19 Fx2d(const XYMap& xyMap): Fx(xyMap.getTotal()), mXyMap(xyMap) {}
20 uint16_t xyMap(uint16_t x, uint16_t y) const {
21 return mXyMap.mapToIndex(x, y);
22 }
23 uint16_t getHeight() const { return mXyMap.getHeight(); }
24 uint16_t 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; }
28protected:
29 XYMap mXyMap;
30};
31
32} // namespace fl
Definition fx.h:18
Implements the FastLED namespace macros.
Implements a simple red square effect for 2D LED grids.
Definition crgb.h:16