Chromium Code Reviews| 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 final Float32List _value = new Float32List(4); | 9 final Float32List _value = new Float32List(4); |
| 10 double get left => _value[0]; | 10 double get left => _value[0]; |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 37 } | 37 } |
| 38 | 38 |
| 39 Point get upperLeft => new Point(left, top); | 39 Point get upperLeft => new Point(left, top); |
| 40 Point get lowerRight => new Point(right, bottom); | 40 Point get lowerRight => new Point(right, bottom); |
| 41 Point get center => new Point(left + right / 2.0, top + bottom / 2.0); | 41 Point get center => new Point(left + right / 2.0, top + bottom / 2.0); |
| 42 | 42 |
| 43 Size get size => new Size(right - left, bottom - top); | 43 Size get size => new Size(right - left, bottom - top); |
| 44 | 44 |
| 45 // Rects are inclusive of the top and left edges but exclusive of the bottom | 45 // Rects are inclusive of the top and left edges but exclusive of the bottom |
| 46 // right edges. | 46 // right edges. |
| 47 bool contains(Point point) => | 47 bool contains(Point point) { |
|
Matt Perry
2015/06/03 21:15:25
why this change?
Hixie
2015/06/09 21:06:49
Consistency. When it fits on one line, =>, when it
| |
| 48 point.x >= left && point.x < right && point.y >= top && point.y < bottom; | 48 return point.x >= left && point.x < right && point.y >= top && point.y < bot tom; |
| 49 } | |
| 49 | 50 |
| 50 bool operator ==(other) { | 51 bool operator ==(other) { |
| 51 if (!(other is Rect)) return false; | 52 if (other is! Rect) |
| 53 return false; | |
| 52 for (var i = 0; i < 4; ++i) { | 54 for (var i = 0; i < 4; ++i) { |
| 53 if (_value[i] != other._value[i]) return false; | 55 if (_value[i] != other._value[i]) |
| 56 return false; | |
|
Matt Perry
2015/06/03 21:15:25
ditto?
Some of the formatting in this file was a
Hixie
2015/06/09 21:06:49
Having the if statement on the same line as the st
| |
| 54 } | 57 } |
| 55 return true; | 58 return true; |
| 56 } | 59 } |
| 60 | |
| 57 int get hashCode { | 61 int get hashCode { |
| 58 return _value.fold(373, (value, item) => (37 * value + item.hashCode)); | 62 return _value.fold(373, (value, item) => (37 * value + item.hashCode)); |
| 59 } | 63 } |
| 60 String toString() => "Rect.LTRB($left, $top, $right, $bottom)"; | 64 String toString() => "Rect.fromLTRB($left, $top, $right, $bottom)"; |
| 61 } | 65 } |
| OLD | NEW |