| 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 4 floating-point coordinates for a rectangle. | 7 /// Holds 4 floating-point coordinates for a rectangle. |
| 8 class Rect { | 8 class Rect { |
| 9 Rect(); | 9 Rect(); |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 ..[2] = left + width | 23 ..[2] = left + width |
| 24 ..[3] = top + height; | 24 ..[3] = top + height; |
| 25 } | 25 } |
| 26 | 26 |
| 27 final Float32List _value = new Float32List(4); | 27 final Float32List _value = new Float32List(4); |
| 28 double get left => _value[0]; | 28 double get left => _value[0]; |
| 29 double get top => _value[1]; | 29 double get top => _value[1]; |
| 30 double get right => _value[2]; | 30 double get right => _value[2]; |
| 31 double get bottom => _value[3]; | 31 double get bottom => _value[3]; |
| 32 | 32 |
| 33 Rect shift(Offset offset) { |
| 34 return new Rect.fromLTRB(left + offset.dx, top + offset.dy, right + offset.d
x, bottom + offset.dy); |
| 35 } |
| 36 Rect inflate(double delta) { |
| 37 return new Rect.fromLTRB(left - delta, top - delta, right + delta, bottom +
delta); |
| 38 } |
| 39 |
| 33 double get width => right - left; | 40 double get width => right - left; |
| 34 double get height => bottom - top; | 41 double get height => bottom - top; |
| 35 | 42 |
| 36 Size get size => new Size(width, height); | 43 Size get size => new Size(width, height); |
| 37 | 44 |
| 38 double get shortestSide { | 45 double get shortestSide { |
| 39 double w = width.abs(); | 46 double w = width.abs(); |
| 40 double h = height.abs(); | 47 double h = height.abs(); |
| 41 return w < h ? w : h; | 48 return w < h ? w : h; |
| 42 } | 49 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 58 return false; | 65 return false; |
| 59 for (var i = 0; i < 4; ++i) { | 66 for (var i = 0; i < 4; ++i) { |
| 60 if (_value[i] != other._value[i]) | 67 if (_value[i] != other._value[i]) |
| 61 return false; | 68 return false; |
| 62 } | 69 } |
| 63 return true; | 70 return true; |
| 64 } | 71 } |
| 65 int get hashCode =>_value.fold(373, (value, item) => (37 * value + item.hashCo
de)); | 72 int get hashCode =>_value.fold(373, (value, item) => (37 * value + item.hashCo
de)); |
| 66 String toString() => "Rect.fromLTRB($left, $top, $right, $bottom)"; | 73 String toString() => "Rect.fromLTRB($left, $top, $right, $bottom)"; |
| 67 } | 74 } |
| OLD | NEW |