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