Made the ambient mode nicer
[kaka/cakelight.git] / src / kaka / cakelight / Color.java
1 package kaka.cakelight;
2
3 public class Color {
4     private int r, g, b;
5
6     public static Color rgb(double r, double g, double b) {
7         return rgb((int)(255 * r), (int)(255 * g), (int)(255 * b));
8     }
9
10     public static Color rgb(int r, int g, int b) {
11         Color c = new Color();
12         c.r = r;
13         c.g = g;
14         c.b = b;
15         return c;
16     }
17
18     public int r() {
19         return r;
20     }
21
22     public int g() {
23         return g;
24     }
25
26     public int b() {
27         return b;
28     }
29
30     public Color interpolate(Color other, double value) {
31         double invertedValue = 1 - value;
32         return Color.rgb(
33                 (int)(r * invertedValue + other.r * value),
34                 (int)(g * invertedValue + other.g * value),
35                 (int)(b * invertedValue + other.b * value)
36         );
37     }
38 }