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

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

Issue 145973005: Change Rectangle.operator== to compare right/bottom instead of width/height. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix typo Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/lib/math/rectangle_test.dart » ('j') | 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 18 matching lines...) Expand all
29 T get right => left + width; 29 T get right => left + width;
30 /** The y-coordinate of the bottom edge. */ 30 /** The y-coordinate of the bottom edge. */
31 T get bottom => top + height; 31 T get bottom => top + height;
32 32
33 String toString() { 33 String toString() {
34 return 'Rectangle ($left, $top) $width x $height'; 34 return 'Rectangle ($left, $top) $width x $height';
35 } 35 }
36 36
37 bool operator ==(other) { 37 bool operator ==(other) {
38 if (other is !Rectangle) return false; 38 if (other is !Rectangle) return false;
39 return left == other.left && top == other.top && width == other.width && 39 return left == other.left && top == other.top && right == other.right &&
40 height == other.height; 40 bottom == other.bottom;
41 } 41 }
42 42
43 int get hashCode => _JenkinsSmiHash.hash4(left.hashCode, top.hashCode, 43 int get hashCode => _JenkinsSmiHash.hash4(left.hashCode, top.hashCode,
44 width.hashCode, height.hashCode); 44 right.hashCode, bottom.hashCode);
45 45
46 /** 46 /**
47 * Computes the intersection of `this` and [other]. 47 * Computes the intersection of `this` and [other].
48 * 48 *
49 * The intersection of two axis-aligned rectangles, if any, is always another 49 * The intersection of two axis-aligned rectangles, if any, is always another
50 * axis-aligned rectangle. 50 * axis-aligned rectangle.
51 * 51 *
52 * Returns the intersection of this and `other`, or `null` if they don't 52 * Returns the intersection of this and `other`, or `null` if they don't
53 * intersect. 53 * intersect.
54 */ 54 */
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 MutableRectangle(this.left, this.top, this.width, this.height); 155 MutableRectangle(this.left, this.top, this.width, this.height);
156 156
157 factory MutableRectangle.fromPoints(Point<T> a, Point<T> b) { 157 factory MutableRectangle.fromPoints(Point<T> a, Point<T> b) {
158 T left = min(a.x, b.x); 158 T left = min(a.x, b.x);
159 T width = max(a.x, b.x) - left; 159 T width = max(a.x, b.x) - left;
160 T top = min(a.y, b.y); 160 T top = min(a.y, b.y);
161 T height = max(a.y, b.y) - top; 161 T height = max(a.y, b.y) - top;
162 return new MutableRectangle<T>(left, top, width, height); 162 return new MutableRectangle<T>(left, top, width, height);
163 } 163 }
164 } 164 }
OLDNEW
« no previous file with comments | « no previous file | tests/lib/math/rectangle_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698