X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=src%2Fkaka%2Fcakelight%2Fmode%2FSmoothVideoMode.java;fp=src%2Fkaka%2Fcakelight%2Fmode%2FSmoothVideoMode.java;h=53b486018936576f93e7a032427634ecd1a08503;hb=67b0a75891f19e91cc35e23fa56915cfd7cd52de;hp=0000000000000000000000000000000000000000;hpb=8304abc8107c4c4d7334ddc7276e95b8f535ee55;p=kaka%2Fcakelight.git diff --git a/src/kaka/cakelight/mode/SmoothVideoMode.java b/src/kaka/cakelight/mode/SmoothVideoMode.java new file mode 100644 index 0000000..53b4860 --- /dev/null +++ b/src/kaka/cakelight/mode/SmoothVideoMode.java @@ -0,0 +1,30 @@ +package kaka.cakelight.mode; + +import kaka.cakelight.Color; +import kaka.cakelight.Configuration; +import kaka.cakelight.LedFrame; + +public class SmoothVideoMode extends VideoMode { + private LedFrame frame; + private int ledCount; + + @Override + public void enter(Configuration config) { + super.enter(config); + frame = LedFrame.from(config); + ledCount = config.leds.getCount(); + } + + @Override + public void updateWithFrame(LedFrame frame) { + super.updateWithFrame(smooth(frame)); + } + + private LedFrame smooth(LedFrame f) { + for (int i = 0; i < ledCount; i++) { + Color c = frame.getLedColor(i).interpolate(f.getLedColor(i), 0.5); + frame.setLedColor(i, c); + } + return frame; + } +}