-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathvisualization.cpp
More file actions
39 lines (31 loc) · 852 Bytes
/
Copy pathvisualization.cpp
File metadata and controls
39 lines (31 loc) · 852 Bytes
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
#include <assert.h>
#include "pixl.h"
using namespace pixl;
namespace pixl {
CRGB Visualization::getColorByRatio(float ratio) {
assert(ratio >= 0);
assert(ratio <= 1);
float viz_index = (float)(size_ - 1.0) * ratio;
return getColorByIndex(viz_index);
}
CRGB Visualization::getColorByIndex(float index) {
assert(index >= 0);
assert(index < size_);
CRGB color1 = viz_[(int)floor(index)];
CRGB color2 = viz_[(int)ceil(index)];
color1 /= 2;
color2 /= 2;
return color1 + color2;
}
CRGB Visualization::getColorByIndex(int index) {
assert(index >= 0);
assert(index < size_);
return viz_[index];
}
HueVisualization::HueVisualization(Input* input, int size)
: Visualization(input, size) {}
void HueVisualization::update() {
float val = input_->getInput();
viz_[0] = CHSV(val * 255, 255, 255);
}
} // end namespace pixl