| 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 html; | 5 part of html; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * A utility class for representing two-dimensional positions. | 8 * A utility class for representing two-dimensional positions. |
| 9 */ | 9 */ |
| 10 class Point { | 10 class Point { |
| 11 final num x; | 11 final num x; |
| 12 final num y; | 12 final num y; |
| 13 | 13 |
| 14 const Point([num x = 0, num y = 0]): x = x, y = y; | 14 const Point([num x = 0, num y = 0]): x = x, y = y; |
| 15 | 15 |
| 16 String toString() => '($x, $y)'; | 16 String toString() => '($x, $y)'; |
| 17 | 17 |
| 18 bool operator ==(other) { | 18 bool operator ==(other) { |
| 19 if (other is !Point) return false; | 19 if (other is !Point) return false; |
| 20 return x == other.x && y == other.y; | 20 return x == other.x && y == other.y; |
| 21 } | 21 } |
| 22 | 22 |
| 23 int get hashCode => JenkinsSmiHash.hash2(x.hashCode, y.hashCode); |
| 24 |
| 23 Point operator +(Point other) { | 25 Point operator +(Point other) { |
| 24 return new Point(x + other.x, y + other.y); | 26 return new Point(x + other.x, y + other.y); |
| 25 } | 27 } |
| 26 | 28 |
| 27 Point operator -(Point other) { | 29 Point operator -(Point other) { |
| 28 return new Point(x - other.x, y - other.y); | 30 return new Point(x - other.x, y - other.y); |
| 29 } | 31 } |
| 30 | 32 |
| 31 Point operator *(num factor) { | 33 Point operator *(num factor) { |
| 32 return new Point(x * factor, y * factor); | 34 return new Point(x * factor, y * factor); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 55 | 57 |
| 56 Point ceil() => new Point(x.ceil(), y.ceil()); | 58 Point ceil() => new Point(x.ceil(), y.ceil()); |
| 57 Point floor() => new Point(x.floor(), y.floor()); | 59 Point floor() => new Point(x.floor(), y.floor()); |
| 58 Point round() => new Point(x.round(), y.round()); | 60 Point round() => new Point(x.round(), y.round()); |
| 59 | 61 |
| 60 /** | 62 /** |
| 61 * Truncates x and y to integers and returns the result as a new point. | 63 * Truncates x and y to integers and returns the result as a new point. |
| 62 */ | 64 */ |
| 63 Point toInt() => new Point(x.toInt(), y.toInt()); | 65 Point toInt() => new Point(x.toInt(), y.toInt()); |
| 64 } | 66 } |
| OLD | NEW |