New smooth video mode that mixes the new frame with the previous one
[kaka/cakelight.git] / src / kaka / cakelight / SmoothVideoMode.java
CommitLineData
8304abc8
TW
1package kaka.cakelight;
2
3public class SmoothVideoMode extends VideoMode {
4 private LedFrame frame;
5 private int ledCount;
6
7 @Override
8 public void enter(Configuration config) {
9 super.enter(config);
10 frame = LedFrame.from(config);
11 ledCount = config.leds.getCount();
12 }
13
14 @Override
15 public void updateWithFrame(LedFrame frame) {
16 super.updateWithFrame(smooth(frame));
17 }
18
19 private LedFrame smooth(LedFrame f) {
20 for (int i = 0; i < ledCount; i++) {
21 Color c = frame.getLedColor(i).interpolate(f.getLedColor(i), 0.5);
22 frame.setLedColor(i, c);
23 }
24 return frame;
25 }
26}