FastLED 3.9.15
Loading...
Searching...
No Matches
fx2d.h
Go to the documentation of this file.
1#pragma once
2
3#include <stdint.h>
4
5#include "fl/namespace.h"
6#include "fl/ptr.h"
7#include "fl/xymap.h"
8#include "fx/fx.h"
9
10namespace fl {
11
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
19 // to a 1D index.
20 Fx2d(const XYMap &xyMap) : Fx(xyMap.getTotal()), mXyMap(xyMap) {}
21 uint16_t xyMap(uint16_t x, uint16_t y) const {
22 return mXyMap.mapToIndex(x, y);
23 }
24 uint16_t getHeight() const { return mXyMap.getHeight(); }
25 uint16_t getWidth() const { return mXyMap.getWidth(); }
26 void setXYMap(const XYMap &xyMap) { mXyMap = xyMap; }
27 XYMap &getXYMap() { return mXyMap; }
28 const XYMap &getXYMap() const { return mXyMap; }
29
30 protected:
32};
33
34} // namespace fl
int y
Definition Audio.ino:72
int x
Definition Audio.ino:71
void setXYMap(const XYMap &xyMap)
Definition fx2d.h:26
XYMap mXyMap
Definition fx2d.h:31
XYMap & getXYMap()
Definition fx2d.h:27
const XYMap & getXYMap() const
Definition fx2d.h:28
uint16_t xyMap(uint16_t x, uint16_t y) const
Definition fx2d.h:21
uint16_t getHeight() const
Definition fx2d.h:24
Fx2d(const XYMap &xyMap)
Definition fx2d.h:20
uint16_t getWidth() const
Definition fx2d.h:25
Fx(uint16_t numLeds)
Definition fx.h:23
Implements the FastLED namespace macros.
Implements a simple red square effect for 2D LED grids.
Definition crgb.h:16
#define FASTLED_SMART_PTR(type)
Definition ptr.h:31