-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRailSegmentBrightnessPattern.pde
46 lines (39 loc) · 1.39 KB
/
RailSegmentBrightnessPattern.pde
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
class RailSegmentBrightnessPattern extends Pattern {
Segment m_segment = null;
color m_color;
RailSegmentBrightnessPattern(int channel, int pitch, int velocity) {
super(channel, pitch, velocity);
color basecolor;
float ratio;
if (pitch >= 36 && pitch-36 < LeftRailSegments.size()) {
m_segment = LeftRailSegments.get(pitch-36);
ratio = (velocity/127.0);
basecolor = channelColors[channel];
m_color = color(
red(basecolor)*ratio,
green(basecolor)*ratio,
blue(basecolor)*ratio
);
}
else if (pitch == 12 && velocity > 0) {
println("Change channel " + channel + " red to " + velocity);
basecolor = channelColors[channel];
channelColors[channel] = color(velocity*2, green(basecolor), blue(basecolor));
}
else if (pitch == 13 && velocity > 0) {
println("Change channel " + channel + " green to " + velocity);
basecolor = channelColors[channel];
channelColors[channel] = color(red(basecolor), velocity*2, blue(basecolor));
}
else if (pitch == 14 && velocity > 0) {
println("Change channel " + channel + " blue to " + velocity);
basecolor = channelColors[channel];
channelColors[channel] = color(red(basecolor), green(basecolor), velocity*2);
}
}
void draw() {
if (m_segment != null) {
m_segment.draw(m_color);
}
}
}