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/xymap.h"
6#include "fl/namespace.h"
7#include "fx/fx.h"
8#include "fl/ptr.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 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:
30};
31
32
33
34} // namespace fl
uint32_t x[NUM_LAYERS]
Definition Fire2023.ino:80
uint32_t y[NUM_LAYERS]
Definition Fire2023.ino:81
void setXYMap(const XYMap &xyMap)
Definition fx2d.h:25
XYMap mXyMap
Definition fx2d.h:29
XYMap & getXYMap()
Definition fx2d.h:26
const XYMap & getXYMap() const
Definition fx2d.h:27
uint16_t xyMap(uint16_t x, uint16_t y) const
Definition fx2d.h:20
uint16_t getHeight() const
Definition fx2d.h:23
Fx2d(const XYMap &xyMap)
Definition fx2d.h:19
uint16_t getWidth() const
Definition fx2d.h:24
Fx(uint16_t numLeds)
Definition fx.h:23
#define FASTLED_SMART_PTR(type)
Definition ptr.h:17
Implements the FastLED namespace macros.
Implements a simple red square effect for 2D LED grids.
Definition crgb.h:16