comparison dwt/graphics/RGB.d @ 7:e831403a80a9

Add 'cast' to casts
author Frank Benoit <benoit@tionex.de>
date Wed, 27 Aug 2008 14:30:35 +0200
parents 1a8b3cb347e0
children a9ab4c738ed8
comparison
equal deleted inserted replaced
6:b903c16b6f48 7:e831403a80a9
103 if (saturation is 0) { 103 if (saturation is 0) {
104 r = g = b = brightness; 104 r = g = b = brightness;
105 } else { 105 } else {
106 if (hue is 360) hue = 0; 106 if (hue is 360) hue = 0;
107 hue /= 60; 107 hue /= 60;
108 int i = (int)hue; 108 int i = cast(int)hue;
109 float f = hue - i; 109 float f = hue - i;
110 float p = brightness * (1 - saturation); 110 float p = brightness * (1 - saturation);
111 float q = brightness * (1 - saturation * f); 111 float q = brightness * (1 - saturation * f);
112 float t = brightness * (1 - saturation * (1 - f)); 112 float t = brightness * (1 - saturation * (1 - f));
113 switch(i) { 113 switch(i) {
142 g = p; 142 g = p;
143 b = q; 143 b = q;
144 break; 144 break;
145 } 145 }
146 } 146 }
147 red = (int)(r * 255 + 0.5); 147 red = cast(int)(r * 255 + 0.5);
148 green = (int)(g * 255 + 0.5); 148 green = cast(int)(g * 255 + 0.5);
149 blue = (int)(b * 255 + 0.5); 149 blue = cast(int)(b * 255 + 0.5);
150 } 150 }
151 151
152 /** 152 /**
153 * Returns the hue, saturation, and brightness of the color. 153 * Returns the hue, saturation, and brightness of the color.
154 * 154 *
193 * @see #hashCode() 193 * @see #hashCode()
194 */ 194 */
195 public bool equals(Object object) { 195 public bool equals(Object object) {
196 if (object is this) return true; 196 if (object is this) return true;
197 if (!(object instanceof RGB)) return false; 197 if (!(object instanceof RGB)) return false;
198 RGB rgb = (RGB)object; 198 RGB rgb = cast(RGB)object;
199 return (rgb.red is this.red) && (rgb.green is this.green) && (rgb.blue is this.blue); 199 return (rgb.red is this.red) && (rgb.green is this.green) && (rgb.blue is this.blue);
200 } 200 }
201 201
202 /** 202 /**
203 * Returns an integer hash code for the receiver. Any two 203 * Returns an integer hash code for the receiver. Any two