| OLD | NEW |
| 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 | 4 |
| 5 part of $LIBRARYNAME; | 5 part of $LIBRARYNAME; |
| 6 | 6 |
| 7 @DocsEditable | 7 @DocsEditable |
| 8 $(ANNOTATIONS)class $CLASSNAME$EXTENDS implements Rect$IMPLEMENTS$NATIVESPEC { | 8 $(ANNOTATIONS)class $CLASSNAME$EXTENDS implements Rect$IMPLEMENTS$NATIVESPEC { |
| 9 | 9 |
| 10 // NOTE! All code below should be common with Rect. | 10 // NOTE! All code below should be common with Rect. |
| 11 // TODO(blois): implement with mixins when available. | 11 // TODO(blois): implement with mixins when available. |
| 12 | 12 |
| 13 String toString() { | 13 String toString() { |
| 14 return '($left, $top, $width, $height)'; | 14 return '($left, $top, $width, $height)'; |
| 15 } | 15 } |
| 16 | 16 |
| 17 bool operator ==(other) { | 17 bool operator ==(other) { |
| 18 if (other is !Rect) return false; | 18 if (other is !Rect) return false; |
| 19 return left == other.left && top == other.top && width == other.width && | 19 return left == other.left && top == other.top && width == other.width && |
| 20 height == other.height; | 20 height == other.height; |
| 21 } | 21 } |
| 22 | 22 |
| 23 int get hashCode => JenkinsSmiHash.hash4(left.hashCode, top.hashCode, |
| 24 width.hashCode, height.hashCode); |
| 25 |
| 23 /** | 26 /** |
| 24 * Computes the intersection of this rectangle and the rectangle parameter. | 27 * Computes the intersection of this rectangle and the rectangle parameter. |
| 25 * Returns null if there is no intersection. | 28 * Returns null if there is no intersection. |
| 26 */ | 29 */ |
| 27 Rect intersection(Rect rect) { | 30 Rect intersection(Rect rect) { |
| 28 var x0 = max(left, rect.left); | 31 var x0 = max(left, rect.left); |
| 29 var x1 = min(left + width, rect.left + rect.width); | 32 var x1 = min(left + width, rect.left + rect.width); |
| 30 | 33 |
| 31 if (x0 <= x1) { | 34 if (x0 <= x1) { |
| 32 var y0 = max(top, rect.top); | 35 var y0 = max(top, rect.top); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 * Truncates coordinates to integers and returns the result as a new | 95 * Truncates coordinates to integers and returns the result as a new |
| 93 * rectangle. | 96 * rectangle. |
| 94 */ | 97 */ |
| 95 Rect toInt() => new Rect(left.toInt(), top.toInt(), width.toInt(), | 98 Rect toInt() => new Rect(left.toInt(), top.toInt(), width.toInt(), |
| 96 height.toInt()); | 99 height.toInt()); |
| 97 | 100 |
| 98 Point get topLeft => new Point(this.left, this.top); | 101 Point get topLeft => new Point(this.left, this.top); |
| 99 Point get bottomRight => new Point(this.left + this.width, | 102 Point get bottomRight => new Point(this.left + this.width, |
| 100 this.top + this.height); | 103 this.top + this.height); |
| 101 $!MEMBERS} | 104 $!MEMBERS} |
| OLD | NEW |