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 a 2D floating-point size. | 7 /// Holds a 2D floating-point size. |
8 class Size { | 8 class Size { |
9 final double width; | 9 final double width; |
10 final double height; | 10 final double height; |
11 | 11 |
12 const Size(this.width, this.height); | 12 const Size(this.width, this.height); |
13 | 13 |
| 14 Point toPoint() { return new Point(width, height); } |
| 15 |
14 const Size.infinite() : width = double.INFINITY, height = double.INFINITY; | 16 const Size.infinite() : width = double.INFINITY, height = double.INFINITY; |
15 | 17 |
16 bool operator ==(other) { | 18 bool operator ==(other) { |
17 if (!(other is Size)) return false; | 19 if (!(other is Size)) return false; |
18 return width == other.width && height == other.height; | 20 return width == other.width && height == other.height; |
19 } | 21 } |
20 int get hashCode { | 22 int get hashCode { |
21 int result = 373; | 23 int result = 373; |
22 result = 37 * result + width.hashCode; | 24 result = 37 * result + width.hashCode; |
23 result = 37 * result + height.hashCode; | 25 result = 37 * result + height.hashCode; |
24 return result; | 26 return result; |
25 } | 27 } |
26 String toString() => "Size($width, $height)"; | 28 String toString() => "Size($width, $height)"; |
27 } | 29 } |
OLD | NEW |