-
Notifications
You must be signed in to change notification settings - Fork 7
/
visualization.h
45 lines (39 loc) · 1.09 KB
/
visualization.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#pragma once
#include <FastLED.h>
#include "input.h"
namespace pixl {
/* A Visualization is an interface to an n-dimensional set of colors to be used
in Animations. Colors are stored as FastLED's CHSV class to make it easier
for animations to map the colors to a set of LEDs */
class Visualization {
public:
Visualization(Input* input, int size = 1)
: input_(input),
size_(size)
{
viz_ = new CRGB[size];
};
~Visualization() { delete[] viz_; }
virtual void update()=0;
int getSize() { return size_; };
void setInput(Input* input) { input_ = input; }
CRGB getColorByRatio(float ratio);
CRGB getColorByIndex(float index);
CRGB getColorByIndex(int index);
protected:
CRGB* viz_;
Input* input_;
int size_;
};
class HueVisualization : public Visualization {
public:
HueVisualization(Input* input, int size = 1);
void update();
};
class NullVisualization : public Visualization {
public:
NullVisualization(Input* input, int size = 1) :
Visualization(input, size) {}
void update() {};
};
} // end namespace pixl