Added a rainbow noise mode
[kaka/cakelight.git] / src / kaka / cakelight / AmbientMode.java
index 0b41b4c..35ec322 100644 (file)
@@ -35,7 +35,7 @@ public class AmbientMode extends Mode { // TODO split into DynamicAmbient and St
                         updateFrame(frame, System.currentTimeMillis() - start, index);
                         updateWithFrame(frame);
                         index = (index + 1) % config.leds.getCount();
-                        Thread.sleep(0);
+                        Thread.sleep(20);
                     }
                 } catch (InterruptedException e) {
                 }
@@ -64,8 +64,8 @@ public class AmbientMode extends Mode { // TODO split into DynamicAmbient and St
             for (int i = 0; i < config.leds.getCount(); i++) {
                 double x = frame.xOf(i);
                 double y = frame.yOf(i);
-                double g = Math.min(1, Math.max(0, noise.getr(-0.5, 0.5, 0.5, x, y, time / 5000.0)));
-                double b = Math.pow(Math.min(1, Math.max(0, noise.getr(0, 0.9, 1, x, y, time / 7000.0))), 2);
+                double b = Math.pow(Math.min(1, Math.max(0, noise.getr(0.0, 1.0, 1, x, y, time / 7000.0))), 1.5);
+                double g = Math.min(1, Math.max(0, noise.getr(-b, b, 0.5, x*3, y*3, time / 5000.0)));
                 frame.setLedColor(i, Color.rgb(0, g, b));
             }
         } else if (type == 2) {
@@ -77,6 +77,27 @@ public class AmbientMode extends Mode { // TODO split into DynamicAmbient and St
                 double value = Math.abs((ledOffset * 2 - ledCount) / ledCount); // 1 to 0 to 1
                 frame.setLedColor(i, Color.hsv(value * hueLength + hueOffset, 1, 1));
             }
+        } else if (type == 3) {
+            for (int i = 0; i < config.leds.getCount(); i++) {
+                double x = frame.xOf(i);
+                double y = frame.yOf(i);
+                double g = Math.pow(Math.min(1, Math.max(0, noise.getr(0.0, 1.0, 1, x, y, time / 7000.0))), 1.5);
+                frame.setLedColor(i, Color.rgb(0, g, 1 - g * 0.5));
+            }
+        } else if (type == 4) {
+            for (int i = 0; i < config.leds.getCount(); i++) {
+                double x = frame.xOf(i);
+                double y = frame.yOf(i);
+                double g = Math.pow(Math.min(1, Math.max(0, noise.getr(0.0, 1.0, 1, x, y, time / 7000.0))), 1.5);
+                frame.setLedColor(i, Color.rgb(1, g, 0));
+            }
+        } else if (type == 5) {
+            for (int i = 0; i < config.leds.getCount(); i++) {
+                double x = frame.xOf(i);
+                double y = frame.yOf(i);
+                double hue = (Math.min(1, Math.max(0, noise.getr(0.0, 1.0, 4, x, y, time / 7000.0))) + (time / 100000.0)) % 1.0;
+                frame.setLedColor(i, Color.hsv(hue, 1, 1));
+            }
         }
     }