Chromium Code Reviews| Index: sky/engine/core/painting/Rect.dart |
| diff --git a/sky/engine/core/painting/Rect.dart b/sky/engine/core/painting/Rect.dart |
| index cb2afec7d773e004e1ec77a276ea82dce7d6df77..be9cc9906d13175136798098f009cf2073056764 100644 |
| --- a/sky/engine/core/painting/Rect.dart |
| +++ b/sky/engine/core/painting/Rect.dart |
| @@ -11,7 +11,38 @@ class Rect { |
| double get right => _value[2]; |
| double get bottom => _value[3]; |
| + Rect() : new Float32List(4); |
| + |
| + Rect.fromPointAndSize(Point point, Size size) { |
|
Hixie
2015/05/28 17:20:11
why isn't this a constructor?
|
| + _value = new Float32List(4) |
| + ..[0] = point.x |
| + ..[1] = point.y |
| + ..[2] = point.x + size.width |
| + ..[3] = point.y + size.height; |
| + } |
| + |
| + Rect.fromLTRB(double left, double top, double right, double bottom) { |
|
Hixie
2015/05/28 17:20:11
ditto
|
| + _value = new Float32List(4) |
| + ..[0] = left |
| + ..[1] = top |
| + ..[2] = right |
| + ..[3] = bottom; |
| + } |
| + |
| + Point get upperLeft => new Point(left, top); |
| + Point get lowerRight => new Point(right, bottom); |
| + |
| + Size get size => new Rect(right - left, bottom - top); |
|
Matt Perry
2015/05/28 16:41:21
new Size
|
| + |
| + // Rects are inclusive of the top and left edges but exclusive of the bottom |
| + // right edges. |
| + bool contains(Point point) => point.x >= left && point.x < right |
| + && point.y >= top && point.y < bottom; |
| + |
| void setLTRB(double left, double top, double right, double bottom) { |
| - _value = new Float32List.fromList([left, top, right, bottom]); |
| + _value[0] = left |
| + ..[1] = top |
| + ..[2] = right |
| + ..[3] = bottom; |
| } |
| } |