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

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

Issue 1162033002: Introduce RenderProxyBox and RenderSizedBox (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Now with test 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 /// 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 11 matching lines...) Expand all
22 ..[3] = point.y + size.height; 22 ..[3] = point.y + size.height;
23 } 23 }
24 24
25 Rect.fromSize(Size size) { 25 Rect.fromSize(Size size) {
26 _value 26 _value
27 ..[2] = size.width 27 ..[2] = size.width
28 ..[3] = size.height; 28 ..[3] = size.height;
29 } 29 }
30 30
31 Rect.fromLTRB(double left, double top, double right, double bottom) { 31 Rect.fromLTRB(double left, double top, double right, double bottom) {
32 setLTRB(left, top, right, bottom); 32 _value
33 ..[0] = left
34 ..[1] = top
35 ..[2] = right
36 ..[3] = bottom;
33 } 37 }
34 38
35 Point get upperLeft => new Point(left, top); 39 Point get upperLeft => new Point(left, top);
36 Point get lowerRight => new Point(right, bottom); 40 Point get lowerRight => new Point(right, bottom);
37 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);
38 42
39 Size get size => new Size(right - left, bottom - top); 43 Size get size => new Size(right - left, bottom - top);
40 44
41 // 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
42 // right edges. 46 // right edges.
43 bool contains(Point point) => 47 bool contains(Point point) =>
44 point.x >= left && point.x < right && point.y >= top && point.y < bottom; 48 point.x >= left && point.x < right && point.y >= top && point.y < bottom;
45 49
46 void setLTRB(double left, double top, double right, double bottom) {
47 _value
48 ..[0] = left
49 ..[1] = top
50 ..[2] = right
51 ..[3] = bottom;
52 }
53
54 bool operator ==(other) { 50 bool operator ==(other) {
55 if (!(other is Rect)) return false; 51 if (!(other is Rect)) return false;
56 for (var i = 0; i < 4; ++i) { 52 for (var i = 0; i < 4; ++i) {
57 if (_value[i] != other._value[i]) return false; 53 if (_value[i] != other._value[i]) return false;
58 } 54 }
59 return true; 55 return true;
60 } 56 }
61 int get hashCode { 57 int get hashCode {
62 return _value.fold(373, (value, item) => (37 * value + item.hashCode)); 58 return _value.fold(373, (value, item) => (37 * value + item.hashCode));
63 } 59 }
64 String toString() => "Rect.LTRB($left, $top, $right, $bottom)"; 60 String toString() => "Rect.LTRB($left, $top, $right, $bottom)";
65 } 61 }
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