FastLED 3.9.3
Loading...
Searching...
No Matches
fx2d.h
1#pragma once
2
3#include <stdint.h>
4
5#include "xymap.h"
6#include "namespace.h"
7#include "fx/fx.h"
8#include "ref.h"
9
10FASTLED_NAMESPACE_BEGIN
11
12FASTLED_SMART_REF(FxGrid);
13
14// Abstract base class for 2D effects that use a grid, which is defined
15// by an XYMap.
16class FxGrid : 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 FxGrid(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
32FASTLED_NAMESPACE_END
Definition fx2d.h:16
Definition fx.h:16
Definition xymap.h:39