comparison dwt/graphics/Color.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
121 * @see #hashCode 121 * @see #hashCode
122 */ 122 */
123 public bool equals(Object object) { 123 public bool equals(Object object) {
124 if (object is this) return true; 124 if (object is this) return true;
125 if (!(object instanceof Color)) return false; 125 if (!(object instanceof Color)) return false;
126 Color color = (Color)object; 126 Color color = cast(Color)object;
127 float[] rgbColor = color.handle; 127 float[] rgbColor = color.handle;
128 if (handle is rgbColor) return true; 128 if (handle is rgbColor) return true;
129 return device is color.device && 129 return device is color.device &&
130 (int)(handle[0] * 255) is (int)(rgbColor[0] * 255) && 130 cast(int)(handle[0] * 255) is cast(int)(rgbColor[0] * 255) &&
131 (int)(handle[1] * 255) is (int)(rgbColor[1] * 255) && 131 cast(int)(handle[1] * 255) is cast(int)(rgbColor[1] * 255) &&
132 (int)(handle[2] * 255) is (int)(rgbColor[2] * 255); 132 cast(int)(handle[2] * 255) is cast(int)(rgbColor[2] * 255);
133 } 133 }
134 134
135 /** 135 /**
136 * Returns the amount of blue in the color, from 0 to 255. 136 * Returns the amount of blue in the color, from 0 to 255.
137 * 137 *
141 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> 141 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
142 * </ul> 142 * </ul>
143 */ 143 */
144 public int getBlue() { 144 public int getBlue() {
145 if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); 145 if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
146 return (int)(handle[2] * 255); 146 return cast(int)(handle[2] * 255);
147 } 147 }
148 148
149 /** 149 /**
150 * Returns the amount of green in the color, from 0 to 255. 150 * Returns the amount of green in the color, from 0 to 255.
151 * 151 *
155 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> 155 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
156 * </ul> 156 * </ul>
157 */ 157 */
158 public int getGreen() { 158 public int getGreen() {
159 if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); 159 if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
160 return (int)(handle[1] * 255); 160 return cast(int)(handle[1] * 255);
161 } 161 }
162 162
163 /** 163 /**
164 * Returns the amount of red in the color, from 0 to 255. 164 * Returns the amount of red in the color, from 0 to 255.
165 * 165 *
169 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> 169 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
170 * </ul> 170 * </ul>
171 */ 171 */
172 public int getRed() { 172 public int getRed() {
173 if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); 173 if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
174 return (int)(handle[0] * 255); 174 return cast(int)(handle[0] * 255);
175 } 175 }
176 176
177 /** 177 /**
178 * Returns an integer hash code for the receiver. Any two 178 * Returns an integer hash code for the receiver. Any two
179 * objects that return <code>true</code> when passed to 179 * objects that return <code>true</code> when passed to
184 * 184 *
185 * @see #equals 185 * @see #equals
186 */ 186 */
187 public int hashCode() { 187 public int hashCode() {
188 if (isDisposed()) return 0; 188 if (isDisposed()) return 0;
189 return (int)(handle[0] * 255) ^ (int)(handle[1] * 255) ^ (int)(handle[2] * 255); 189 return cast(int)(handle[0] * 255) ^ cast(int)(handle[1] * 255) ^ cast(int)(handle[2] * 255);
190 } 190 }
191 191
192 /** 192 /**
193 * Returns an <code>RGB</code> representing the receiver. 193 * Returns an <code>RGB</code> representing the receiver.
194 * 194 *