Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Side by Side Diff: sky/engine/core/painting/Rect.dart

Issue 1152213003: Flesh out Rect/Point/Size classes in dart:sky (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sky/engine/core/painting/Point.dart ('k') | sky/engine/core/painting/Size.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 }
OLDNEW
« no previous file with comments | « sky/engine/core/painting/Point.dart ('k') | sky/engine/core/painting/Size.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698