comparison dynamin/painting/color.d @ 104:5c8c1c2e12c0

Change from real to double. double is not dependant on the platform, and it uses less space.
author Jordan Miner <jminer7@gmail.com>
date Fri, 06 Jul 2012 18:39:45 -0500
parents 73060bc3f004
children acdbb30fee7e
comparison
equal deleted inserted replaced
103:73060bc3f004 104:5c8c1c2e12c0
38 this.r = r/255.0; 38 this.r = r/255.0;
39 this.g = g/255.0; 39 this.g = g/255.0;
40 this.b = b/255.0; 40 this.b = b/255.0;
41 this.a = a/255.0; 41 this.a = a/255.0;
42 } 42 }
43 this(real r, real g, real b, real a = 1.0) { 43 this(double r, double g, double b, double a = 1.0) {
44 this.r = r; 44 this.r = r;
45 this.g = g; 45 this.g = g;
46 this.b = b; 46 this.b = b;
47 this.a = a; 47 this.a = a;
48 } 48 }
49 private real getMin() { 49 private double getMin() {
50 } 50 }
51 private real getMax() { 51 private double getMax() {
52 real max = r; 52 double max = r;
53 if(g > max) 53 if(g > max)
54 max = g; 54 max = g;
55 if(b > max) 55 if(b > max)
56 max = b; 56 max = b;
57 return max; 57 return max;
58 } 58 }
59 /** 59 /**
60 * From 0 to 360 degrees. 60 * From 0 to 360 degrees.
61 */ 61 */
62 real gethue() { 62 double gethue() {
63 real min = min(); 63 double min = min();
64 real max = max(); 64 double max = max();
65 real delta = max - min; 65 double delta = max - min;
66 if(max == 0) // r = g = b = 0 = black 66 if(max == 0) // r = g = b = 0 = black
67 return 0; 67 return 0;
68 68
69 real hue; 69 double hue;
70 if(r == max) 70 if(r == max)
71 hue = (g - b) / delta; // between yellow and magenta 71 hue = (g - b) / delta; // between yellow and magenta
72 else if(g == max) 72 else if(g == max)
73 hue = 2 + (b - r) / delta; // between cyan and yellow 73 hue = 2 + (b - r) / delta; // between cyan and yellow
74 else 74 else
77 hue *= 60; 77 hue *= 60;
78 if(hue < 0) 78 if(hue < 0)
79 hue += 360; 79 hue += 360;
80 80
81 } 81 }
82 real getSaturation() { 82 double getSaturation() {
83 } 83 }
84 real getValue() { 84 double getValue() {
85 return getMax(); 85 return getMax();
86 } 86 }
87 +/ 87 +/
88 /** 88 /**
89 * Changes this color to its inverse. 89 * Changes this color to its inverse.