Made saturation configuration
[kaka/cakelight.git] / src / kaka / cakelight / VideoFrame.java
index e77dcd9..931237d 100644 (file)
@@ -104,7 +104,10 @@ public class VideoFrame {
     private Color wrappedGetLedColor(ListPosition listPosition, int xy) {
         Color c = getLedColor(listPosition, xy);
         double[] hsv = c.toHSV();
-        return Color.hsv(hsv[0], 1, 1);
+        double saturation = config.video.saturation >= 0.5
+                ? hsv[1] + (config.video.saturation - 0.5) * 2 * (1 - hsv[1])
+                : hsv[1] - (1 - config.video.saturation * 2) * hsv[1];
+        return Color.hsv(hsv[0], saturation, hsv[2]);
     }
 
     private Color getLedColor(ListPosition listPosition, int xy) {
@@ -172,10 +175,27 @@ public class VideoFrame {
     public LedFrame getLedFrame() {
         LedFrame frame = LedFrame.from(config);
         int led = 0;
-        if (config.video.list.bottom) for (int i = 0; i < config.leds.cols; i++)      frame.setLedColor(led++, wrappedGetLedColor(ListPosition.BOTTOM, i));
-        if (config.video.list.right)  for (int i = config.leds.rows - 1; i >= 0; i--) frame.setLedColor(led++, wrappedGetLedColor(ListPosition.RIGHT, i));
-        if (config.video.list.top)    for (int i = config.leds.cols - 1; i >= 0; i--) frame.setLedColor(led++, wrappedGetLedColor(ListPosition.TOP, i));
-        if (config.video.list.left)   for (int i = 0; i < config.leds.rows; i++)      frame.setLedColor(led++, wrappedGetLedColor(ListPosition.LEFT, i));
+
+        if (config.video.list.bottom)
+            for (int i = 0; i < config.leds.cols; i++)      frame.setLedColor(led++, wrappedGetLedColor(ListPosition.BOTTOM, i));
+       else
+           for (int i = 0; i < config.leds.cols; i++)      frame.setLedColor(led++, Color.BLACK);
+
+        if (config.video.list.right)
+            for (int i = config.leds.rows - 1; i >= 0; i--) frame.setLedColor(led++, wrappedGetLedColor(ListPosition.RIGHT, i));
+        else
+            for (int i = config.leds.rows - 1; i >= 0; i--) frame.setLedColor(led++, Color.BLACK);
+
+        if (config.video.list.top)
+            for (int i = config.leds.cols - 1; i >= 0; i--) frame.setLedColor(led++, wrappedGetLedColor(ListPosition.TOP, i));
+        else
+            for (int i = config.leds.cols - 1; i >= 0; i--) frame.setLedColor(led++, Color.BLACK);
+
+        if (config.video.list.left)
+            for (int i = 0; i < config.leds.rows; i++)      frame.setLedColor(led++, wrappedGetLedColor(ListPosition.LEFT, i));
+        else
+            for (int i = 0; i < config.leds.rows; i++)      frame.setLedColor(led++, Color.BLACK);
+
         return frame;
     }
 }