| 1 | package kaka.cakelight; |
| 2 | |
| 3 | public 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 | } |