1 package nl.tudelft.goal.ut2004.visualizer.timeline.map;
2
3 import java.awt.Color;
4
5
6
7
8
9
10
11 public class GlColor {
12
13 public double r;
14 public double g;
15 public double b;
16
17
18
19 public double a;
20
21
22
23
24
25
26
27
28 public GlColor(double r, double g, double b, double a) {
29 this.r = r;
30 this.g = g;
31 this.b = b;
32 this.a = a;
33 }
34
35
36
37
38
39
40
41 public GlColor(double r, double g, double b) {
42 this(r, g, b, 1.0);
43 }
44
45
46
47
48
49
50 public GlColor(Color color, double alpha) {
51 this(color.getRed() / 255.0, color.getGreen() / 255.0, color.getBlue() / 255.0, alpha);
52 }
53
54
55
56
57
58 public GlColor(Color color) {
59 this(color.getRed() / 255.0, color.getGreen() / 255.0, color.getBlue() / 255.0);
60 }
61
62 public GlColor(GlColor color) {
63 this(color.r, color.g, color.b, color.a);
64 }
65
66
67
68
69
70
71
72
73 public GlColor getMixedWith(GlColor mixing, double portion) {
74 double thisPortion = 1 - portion;
75 return new GlColor(
76 thisPortion * r + portion * mixing.r,
77 thisPortion * g + portion * mixing.g,
78 thisPortion * b + portion * mixing.b,
79 thisPortion * a + portion * mixing.a);
80 }
81
82 @Override
83 public String toString() {
84 return "[r:" + r + "; g:" + g + "; b:" + b + "; a: " + a + "]";
85 }
86 }