X-Git-Url: http://dolda2000.com/gitweb/?p=kaka%2Fcakelight.git;a=blobdiff_plain;f=src%2Fkaka%2Fcakelight%2FAmbientMode.java;h=a6ae8da6294f61c8fe7b55c971066ecffe783cd5;hp=51cb1e693d9903f215c513eb21ffc139e1982114;hb=0bf6c885fdaa8273ab72789f7efcd9477234168a;hpb=fa0f769bf3338643755de3624aa4b6db53cea6e6 diff --git a/src/kaka/cakelight/AmbientMode.java b/src/kaka/cakelight/AmbientMode.java index 51cb1e6..a6ae8da 100644 --- a/src/kaka/cakelight/AmbientMode.java +++ b/src/kaka/cakelight/AmbientMode.java @@ -1,8 +1,17 @@ package kaka.cakelight; +import kaka.cakelight.util.SimplexNoise3D; + public class AmbientMode extends Mode { // TODO split into DynamicAmbient and StaticAmbient? private Thread thread; // TODO move to a dynamic sub class private Configuration config; + private int type = 0; + + public AmbientMode(String[] args) { + if (args.length > 0) { + type = Integer.parseInt(args[0]); + } + } @Override public void enter(Configuration config) { @@ -45,10 +54,20 @@ public class AmbientMode extends Mode { // TODO split into DynamicAmbient and St * @param count Goes from 0 to number of LEDs - 1 */ private void updateFrame(LedFrame frame, long time, int count) { - for (int i = 0; i < config.leds.getCount(); i++) { - double r = Math.sin(2 * i * Math.PI / config.leds.getCount() + time * 0.001) * 0.5 + 0.5; - double g = Math.cos(2 * i * Math.PI / config.leds.getCount() + time * 0.002) * 0.5 + 0.5; - frame.setLedColor(i, Color.rgb(r, g, 0)); + if (type == 0) { + for (int i = 0; i < config.leds.getCount(); i++) { + double r = Math.sin(2 * i * Math.PI / config.leds.getCount() + time * 0.001) * 0.5 + 0.5; + double g = Math.cos(2 * i * Math.PI / config.leds.getCount() + time * 0.002) * 0.5 + 0.5; + frame.setLedColor(i, Color.rgb(r, g, 0)); + } + } else if (type == 1) { + for (int i = 0; i < config.leds.getCount(); i++) { + double g = noise.getr(0, 0.5, 0.5, frame.xOf(i), frame.yOf(i), time / 5000.0); + double b = noise.getr(0, 1, 1, frame.xOf(i), frame.yOf(i), time / 7000.0); + frame.setLedColor(i, Color.rgb(0, g, b)); + } } } + + private SimplexNoise3D noise = new SimplexNoise3D(0); }