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

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

Issue 1160453006: Provide Point+Size, Point-Point, Point.toSize(), and Rect.toPoint(). (Closed) Base URL: https://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 /// 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
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 }
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