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 class Rect { | 7 class Rect { |
| 8 Float32List _value; | 8 Float32List _value; |
|
Hixie
2015/05/28 17:20:11
Move these to below the constructors?
| |
| 9 double get left => _value[0]; | 9 double get left => _value[0]; |
| 10 double get top => _value[1]; | 10 double get top => _value[1]; |
| 11 double get right => _value[2]; | 11 double get right => _value[2]; |
| 12 double get bottom => _value[3]; | 12 double get bottom => _value[3]; |
| 13 | 13 |
| 14 Rect() : new Float32List(4); | |
| 15 | |
| 16 Rect.fromPointAndSize(Point point, Size size) { | |
|
Hixie
2015/05/28 17:20:11
why isn't this a constructor?
| |
| 17 _value = new Float32List(4) | |
| 18 ..[0] = point.x | |
| 19 ..[1] = point.y | |
| 20 ..[2] = point.x + size.width | |
| 21 ..[3] = point.y + size.height; | |
| 22 } | |
| 23 | |
| 24 Rect.fromLTRB(double left, double top, double right, double bottom) { | |
|
Hixie
2015/05/28 17:20:11
ditto
| |
| 25 _value = new Float32List(4) | |
| 26 ..[0] = left | |
| 27 ..[1] = top | |
| 28 ..[2] = right | |
| 29 ..[3] = bottom; | |
| 30 } | |
| 31 | |
| 32 Point get upperLeft => new Point(left, top); | |
| 33 Point get lowerRight => new Point(right, bottom); | |
| 34 | |
| 35 Size get size => new Rect(right - left, bottom - top); | |
|
Matt Perry
2015/05/28 16:41:21
new Size
| |
| 36 | |
| 37 // Rects are inclusive of the top and left edges but exclusive of the bottom | |
| 38 // right edges. | |
| 39 bool contains(Point point) => point.x >= left && point.x < right | |
| 40 && point.y >= top && point.y < bottom; | |
| 41 | |
| 14 void setLTRB(double left, double top, double right, double bottom) { | 42 void setLTRB(double left, double top, double right, double bottom) { |
| 15 _value = new Float32List.fromList([left, top, right, bottom]); | 43 _value[0] = left |
| 44 ..[1] = top | |
| 45 ..[2] = right | |
| 46 ..[3] = bottom; | |
| 16 } | 47 } |
| 17 } | 48 } |
| OLD | NEW |