| 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 part of base; |    5 part of base; | 
|    6  |    6  | 
|    7 /** |    7 /** | 
|    8  * A utility class for representing two-dimensional sizes. |    8  * A utility class for representing two-dimensional sizes. | 
|    9  */ |    9  */ | 
|   10 class Size { |   10 class Size { | 
|   11   num width; |   11   num width; | 
|   12   num height; |   12   num height; | 
|   13  |   13  | 
|   14   Size(num this.width, num this.height) { |   14   Size(num this.width, num this.height) {} | 
|   15   } |  | 
|   16  |   15  | 
|   17   bool operator ==(Size other) { |   16   bool operator ==(Size other) { | 
|   18     return other != null && width == other.width && height == other.height; |   17     return other != null && width == other.width && height == other.height; | 
|   19   } |   18   } | 
|   20  |   19  | 
|   21   int get hashCode => throw new UnimplementedError(); |   20   int get hashCode => throw new UnimplementedError(); | 
|   22  |   21  | 
|   23   /** |   22   /** | 
|   24    * Returns the area of the size (width * height). |   23    * Returns the area of the size (width * height). | 
|   25    */ |   24    */ | 
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  120   } |  119   } | 
|  121  |  120  | 
|  122   /** |  121   /** | 
|  123    * Uniformly scales the size to fit inside the dimensions of a given size. The |  122    * Uniformly scales the size to fit inside the dimensions of a given size. The | 
|  124    * original aspect ratio will be preserved. |  123    * original aspect ratio will be preserved. | 
|  125    * |  124    * | 
|  126    * This function assumes that both Sizes contain strictly positive dimensions. |  125    * This function assumes that both Sizes contain strictly positive dimensions. | 
|  127    * Returns this Size object, after optional scaling. |  126    * Returns this Size object, after optional scaling. | 
|  128    */ |  127    */ | 
|  129   Size scaleToFit(Size target) { |  128   Size scaleToFit(Size target) { | 
|  130     num s = aspectRatio() > target.aspectRatio() ? |  129     num s = aspectRatio() > target.aspectRatio() | 
|  131         target.width / width : target.height / height; |  130         ? target.width / width | 
 |  131         : target.height / height; | 
|  132     return scale(s); |  132     return scale(s); | 
|  133   } |  133   } | 
|  134  |  134  | 
|  135   /** |  135   /** | 
|  136    * Returns a nice string representing size. |  136    * Returns a nice string representing size. | 
|  137    * Returns in the form (50 x 73). |  137    * Returns in the form (50 x 73). | 
|  138    */ |  138    */ | 
|  139   String toString() { |  139   String toString() { | 
|  140     return "(${width} x ${height})"; |  140     return "(${width} x ${height})"; | 
|  141   } |  141   } | 
|  142 } |  142 } | 
| OLD | NEW |