X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=src%2Fkaka%2Fcakelight%2Fmode%2FTwoColorNoiseMode.java;h=7e3970550371393be6c306eaee69760be420640a;hb=2b49e4e255f8591fb730f88e71b6b006008ccd3d;hp=6d2dabe8246572483cd8d1aee7e09ec04213bcc3;hpb=eca6fd31ebbf5cc015c0a4acd4f1509de061e3df;p=kaka%2Fcakelight.git diff --git a/src/kaka/cakelight/mode/TwoColorNoiseMode.java b/src/kaka/cakelight/mode/TwoColorNoiseMode.java index 6d2dabe..7e39705 100644 --- a/src/kaka/cakelight/mode/TwoColorNoiseMode.java +++ b/src/kaka/cakelight/mode/TwoColorNoiseMode.java @@ -1,52 +1,13 @@ package kaka.cakelight.mode; -import kaka.cakelight.*; +import kaka.cakelight.Color; +import kaka.cakelight.LedFrame; import kaka.cakelight.util.SimplexNoise3D; public class TwoColorNoiseMode extends AmbientMode { private final Color primary, secondary; private SimplexNoise3D noise = new SimplexNoise3D(0); - public static Console.Command getCommand() { - return new Console.Command() { - public String[] getNames() { - return new String[] {"n", "noise"}; - } - - public void activate(CakeLight cakelight, Configuration config, String[] args) { - if (args.length == 3) { // cmd + col1 + col2 - cakelight.setMode(new TwoColorNoiseMode( - parseColor(args[1]), - parseColor(args[2]) - )); - } - } - - private Color parseColor(String s) { - switch (s.toLowerCase()) { - case "r": return Color.rgb(255, 0, 0); - case "g": return Color.rgb(0, 255, 0); - case "b": return Color.rgb(0, 0, 255); - default: // assume hexadecimal - if (s.length() == 3) { - return Color.rgb( - Integer.parseInt(s.substring(0, 1), 16) * 16 + Integer.parseInt(s.substring(0, 1), 16), - Integer.parseInt(s.substring(1, 2), 16) * 16 + Integer.parseInt(s.substring(1, 2), 16), - Integer.parseInt(s.substring(2, 3), 16) * 16 + Integer.parseInt(s.substring(2, 3), 16) - ); - } else if (s.length() == 6) { - return Color.rgb( - Integer.parseInt(s.substring(0, 2), 16), - Integer.parseInt(s.substring(2, 4), 16), - Integer.parseInt(s.substring(4, 6), 16) - ); - } - } - return Color.BLACK; - } - }; - } - public TwoColorNoiseMode(Color primary, Color secondary) { this.primary = primary; this.secondary = secondary;