OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| 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. |
| 4 |
1 import 'dart:math' hide Rectangle; | 5 import 'dart:math' hide Rectangle; |
2 import 'dart:math' as math show Point, Rectangle, MutableRectangle; | 6 import 'dart:math' as math show Point, Rectangle, MutableRectangle; |
3 import 'package:expect/expect.dart' show Expect; | 7 import 'package:expect/expect.dart' show Expect; |
4 | 8 |
5 void main() { | 9 void main() { |
6 verifyRectable(new Rectangle(1, 2, 3, 4)); | 10 verifyRectable(new Rectangle(1, 2, 3, 4)); |
7 } | 11 } |
8 | 12 |
9 void verifyRectable(math.Rectangle rect) { | 13 void verifyRectable(math.Rectangle rect) { |
10 Expect.equals(1.0, rect.left.toDouble()); | 14 Expect.equals(1.0, rect.left.toDouble()); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 } | 71 } |
68 | 72 |
69 Rectangle<T> intersection(math.Rectangle<T> rect) { | 73 Rectangle<T> intersection(math.Rectangle<T> rect) { |
70 T rLeft = max(left, rect.left); | 74 T rLeft = max(left, rect.left); |
71 T rTop = max(top, rect.top); | 75 T rTop = max(top, rect.top); |
72 T rRight = min(right, rect.right); | 76 T rRight = min(right, rect.right); |
73 T rBottom = min(bottom, rect.bottom); | 77 T rBottom = min(bottom, rect.bottom); |
74 return new Rectangle<T>(rLeft, rTop, rRight - rLeft, rBottom - rTop); | 78 return new Rectangle<T>(rLeft, rTop, rRight - rLeft, rBottom - rTop); |
75 } | 79 } |
76 } | 80 } |
OLD | NEW |