| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 part of dart.sky; | 5 part of dart.sky; |
| 6 | 6 |
| 7 /// Holds 2 floating-point coordinates. | 7 /// Holds 2 floating-point coordinates. |
| 8 class Point { | 8 class Point { |
| 9 const Point(this.x, this.y); |
| 10 |
| 9 final double x; | 11 final double x; |
| 10 final double y; | 12 final double y; |
| 11 | 13 |
| 12 const Point(this.x, this.y); | 14 static const Point origin = const Point(0.0, 0.0); |
| 13 | 15 |
| 14 bool operator ==(other) => other is Point && x == other.x && y == other.y; | 16 bool operator ==(other) => other is Point && x == other.x && y == other.y; |
| 15 Size operator -(Point other) => new Size(x - other.x, y - other.y); | 17 Size operator -(Point other) => new Size(x - other.x, y - other.y); |
| 16 Point operator +(Size size) => new Point(x + size.width, y + size.height); | 18 Point operator +(Size size) => new Point(x + size.width, y + size.height); |
| 17 | 19 |
| 18 static const Point origin = const Point(0.0, 0.0); | |
| 19 | |
| 20 // does the equivalent of "return this - Point(0,0)" | 20 // does the equivalent of "return this - Point(0,0)" |
| 21 Size toSize() => new Size(x, y); | 21 Size toSize() => new Size(x, y); |
| 22 | 22 |
| 23 int get hashCode { | 23 int get hashCode { |
| 24 int result = 373; | 24 int result = 373; |
| 25 result = 37 * result + x.hashCode; | 25 result = 37 * result + x.hashCode; |
| 26 result = 37 * result + y.hashCode; | 26 result = 37 * result + y.hashCode; |
| 27 return result; | 27 return result; |
| 28 } | 28 } |
| 29 String toString() => "Point($x, $y)"; | 29 String toString() => "Point($x, $y)"; |
| 30 } | 30 } |
| OLD | NEW |