OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 /** | 5 /** |
6 * A utility class for representing two-dimensional sizes. | 6 * A utility class for representing two-dimensional sizes. |
7 */ | 7 */ |
8 class Size { | 8 class Size { |
9 num width; | 9 num width; |
10 num height; | 10 num height; |
11 | 11 |
12 Size(num this.width, num this.height) { | 12 Size(num this.width, num this.height) { |
13 } | 13 } |
14 | 14 |
15 bool operator ==(Size other) { | 15 bool operator ==(Size other) { |
16 return other !== null && width == other.width && height == other.height; | 16 return other != null && width == other.width && height == other.height; |
17 } | 17 } |
18 | 18 |
19 /** | 19 /** |
20 * Returns the area of the size (width * height). | 20 * Returns the area of the size (width * height). |
21 */ | 21 */ |
22 num area() { | 22 num area() { |
23 return width * height; | 23 return width * height; |
24 } | 24 } |
25 | 25 |
26 /** | 26 /** |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 } | 129 } |
130 | 130 |
131 /** | 131 /** |
132 * Returns a nice string representing size. | 132 * Returns a nice string representing size. |
133 * Returns in the form (50 x 73). | 133 * Returns in the form (50 x 73). |
134 */ | 134 */ |
135 String toString() { | 135 String toString() { |
136 return "(${width} x ${height})"; | 136 return "(${width} x ${height})"; |
137 } | 137 } |
138 } | 138 } |
OLD | NEW |