Added a custom Color class
[kaka/cakelight.git] / src / kaka / cakelight / Color.java
diff --git a/src/kaka/cakelight/Color.java b/src/kaka/cakelight/Color.java
new file mode 100644 (file)
index 0000000..ba85866
--- /dev/null
@@ -0,0 +1,34 @@
+package kaka.cakelight;
+
+public class Color {
+    private int r, g, b;
+
+    public static Color rgb(int r, int g, int b) {
+        Color c = new Color();
+        c.r = r;
+        c.g = g;
+        c.b = b;
+        return c;
+    }
+
+    public int r() {
+        return r;
+    }
+
+    public int g() {
+        return g;
+    }
+
+    public int b() {
+        return b;
+    }
+
+    public Color interpolate(Color other, double value) {
+        double invertedValue = 1 - value;
+        return Color.rgb(
+                (int)(r * invertedValue + other.r * value),
+                (int)(g * invertedValue + other.g * value),
+                (int)(b * invertedValue + other.b * value)
+        );
+    }
+}