Commit | Line | Data |
---|---|---|
67b0a758 TW |
1 | package kaka.cakelight.mode; |
2 | ||
3 | import kaka.cakelight.Color; | |
4 | import kaka.cakelight.Configuration; | |
5 | import kaka.cakelight.LedFrame; | |
8304abc8 TW |
6 | |
7 | public 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 | } |