Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Side by Side Diff: sdk/lib/math/rectangle.dart

Issue 1961993002: Make dart:math strong mode clean. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sdk/lib/math/point.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 part of dart.math; 4 part of dart.math;
5 5
6 /** 6 /**
7 * A base class for representing two-dimensional axis-aligned rectangles. 7 * A base class for representing two-dimensional axis-aligned rectangles.
8 * 8 *
9 * This rectangle uses a left-handed Cartesian coordinate system, with x 9 * This rectangle uses a left-handed Cartesian coordinate system, with x
10 * directed to the right and y directed down, as per the convention in 2D 10 * directed to the right and y directed down, as per the convention in 2D
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 * with x-coordinate between `left` and `left + width`, and 202 * with x-coordinate between `left` and `left + width`, and
203 * with y-coordinate between `top` and `top + height`, both inclusive. 203 * with y-coordinate between `top` and `top + height`, both inclusive.
204 * 204 *
205 * The `width` and `height` should be non-negative. 205 * The `width` and `height` should be non-negative.
206 * If `width` or `height` are negative, they are clamped to zero. 206 * If `width` or `height` are negative, they are clamped to zero.
207 * 207 *
208 * If `width` and `height` are zero, the "rectangle" comprises only the single 208 * If `width` and `height` are zero, the "rectangle" comprises only the single
209 * point `(left, top)`. 209 * point `(left, top)`.
210 */ 210 */
211 MutableRectangle(this.left, this.top, T width, T height) 211 MutableRectangle(this.left, this.top, T width, T height)
212 : this._width = (width < 0) ? _clampToZero(width) : width, 212 : this._width = (width < 0) ? _clampToZero/*<T>*/(width) : width,
213 this._height = (height < 0) ? _clampToZero(height) : height; 213 this._height = (height < 0) ? _clampToZero/*<T>*/(height) : height;
214 214
215 /** 215 /**
216 * Create a mutable rectangle spanned by the points [a] and [b]; 216 * Create a mutable rectangle spanned by the points [a] and [b];
217 * 217 *
218 * The rectangle contains the points 218 * The rectangle contains the points
219 * with x-coordinate between `a.x` and `b.x`, and 219 * with x-coordinate between `a.x` and `b.x`, and
220 * with y-coordinate between `a.y` and `b.y`, both inclusive. 220 * with y-coordinate between `a.y` and `b.y`, both inclusive.
221 * 221 *
222 * If the distance between `a.x` and `b.x` is not representable 222 * If the distance between `a.x` and `b.x` is not representable
223 * (which can happen if one or both is a double), 223 * (which can happen if one or both is a double),
(...skipping 13 matching lines...) Expand all
237 /** 237 /**
238 * Sets the width of the rectangle. 238 * Sets the width of the rectangle.
239 * 239 *
240 * The width must be non-negative. 240 * The width must be non-negative.
241 * If a negative width is supplied, it is clamped to zero. 241 * If a negative width is supplied, it is clamped to zero.
242 * 242 *
243 * Setting the value will change the right edge of the rectangle, 243 * Setting the value will change the right edge of the rectangle,
244 * but will not change [left]. 244 * but will not change [left].
245 */ 245 */
246 void set width(T width) { 246 void set width(T width) {
247 if (width < 0) width = _clampToZero(width); 247 if (width < 0) width = _clampToZero/*<T>*/(width);
248 _width = width; 248 _width = width;
249 } 249 }
250 250
251 T get height => _height; 251 T get height => _height;
252 252
253 /** 253 /**
254 * Sets the height of the rectangle. 254 * Sets the height of the rectangle.
255 * 255 *
256 * The height must be non-negative. 256 * The height must be non-negative.
257 * If a negative height is supplied, it is clamped to zero. 257 * If a negative height is supplied, it is clamped to zero.
258 * 258 *
259 * Setting the value will change the bottom edge of the rectangle, 259 * Setting the value will change the bottom edge of the rectangle,
260 * but will not change [top]. 260 * but will not change [top].
261 */ 261 */
262 void set height(T height) { 262 void set height(T height) {
263 if (height < 0) height = _clampToZero(height); 263 if (height < 0) height = _clampToZero/*<T>*/(height);
264 _height = height; 264 _height = height;
265 } 265 }
266 } 266 }
267 267
268 /** 268 /**
269 * Converts a negative [int] or [double] to a zero-value of the same type. 269 * Converts a negative [int] or [double] to a zero-value of the same type.
270 * 270 *
271 * Returns `0` if value is int, `0.0` if value is double. 271 * Returns `0` if value is int, `0.0` if value is double.
272 */ 272 */
273 num _clampToZero(num value) { 273 num/*=T*/ _clampToZero/*<T extends num>*/(num/*=T*/ value) {
274 assert(value < 0); 274 assert(value < 0);
275 return -value * 0; 275 return -value * 0;
276 } 276 }
OLDNEW
« no previous file with comments | « sdk/lib/math/point.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698