Commit | Line | Data |
---|---|---|
242486dc TW |
1 | package kaka.cakelight; |
2 | ||
3 | public class Color { | |
4 | private int r, g, b; | |
5 | ||
6 | public static Color rgb(int r, int g, int b) { | |
7 | Color c = new Color(); | |
8 | c.r = r; | |
9 | c.g = g; | |
10 | c.b = b; | |
11 | return c; | |
12 | } | |
13 | ||
14 | public int r() { | |
15 | return r; | |
16 | } | |
17 | ||
18 | public int g() { | |
19 | return g; | |
20 | } | |
21 | ||
22 | public int b() { | |
23 | return b; | |
24 | } | |
25 | ||
26 | public Color interpolate(Color other, double value) { | |
27 | double invertedValue = 1 - value; | |
28 | return Color.rgb( | |
29 | (int)(r * invertedValue + other.r * value), | |
30 | (int)(g * invertedValue + other.g * value), | |
31 | (int)(b * invertedValue + other.b * value) | |
32 | ); | |
33 | } | |
34 | } |