| 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 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 abstract class _RectangleBase<T extends num> { | 9 abstract class _RectangleBase<T extends num> { |
| 10 const _RectangleBase(); | 10 const _RectangleBase(); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 | 80 |
| 81 var left = min(this.left, other.left); | 81 var left = min(this.left, other.left); |
| 82 var top = min(this.top, other.top); | 82 var top = min(this.top, other.top); |
| 83 | 83 |
| 84 return new Rectangle<T>(left, top, right - left, bottom - top); | 84 return new Rectangle<T>(left, top, right - left, bottom - top); |
| 85 } | 85 } |
| 86 | 86 |
| 87 /** | 87 /** |
| 88 * Tests whether `this` entirely contains [another]. | 88 * Tests whether `this` entirely contains [another]. |
| 89 */ | 89 */ |
| 90 bool contains(Rectangle<num> another) { | 90 bool containsRectangle(Rectangle<num> another) { |
| 91 return left <= another.left && | 91 return left <= another.left && |
| 92 left + width >= another.left + another.width && | 92 left + width >= another.left + another.width && |
| 93 top <= another.top && | 93 top <= another.top && |
| 94 top + height >= another.top + another.height; | 94 top + height >= another.top + another.height; |
| 95 } | 95 } |
| 96 | 96 |
| 97 /** | 97 /** |
| 98 * Tests whether [another] is inside or along the edges of `this`. | 98 * Tests whether [another] is inside or along the edges of `this`. |
| 99 */ | 99 */ |
| 100 bool containsPoint(Point<num> another) { | 100 bool containsPoint(Point<num> another) { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 MutableRectangle(this.left, this.top, this.width, this.height); | 148 MutableRectangle(this.left, this.top, this.width, this.height); |
| 149 | 149 |
| 150 factory MutableRectangle.fromPoints(Point<T> a, Point<T> b) { | 150 factory MutableRectangle.fromPoints(Point<T> a, Point<T> b) { |
| 151 T left = min(a.x, b.x); | 151 T left = min(a.x, b.x); |
| 152 T width = max(a.x, b.x) - left; | 152 T width = max(a.x, b.x) - left; |
| 153 T top = min(a.y, b.y); | 153 T top = min(a.y, b.y); |
| 154 T height = max(a.y, b.y) - top; | 154 T height = max(a.y, b.y) - top; |
| 155 return new MutableRectangle<T>(left, top, width, height); | 155 return new MutableRectangle<T>(left, top, width, height); |
| 156 } | 156 } |
| 157 } | 157 } |
| OLD | NEW |