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

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

Issue 1214833004: Split Size into Size and Offset. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 5 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.cpp ('k') | sky/engine/core/painting/Rect.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 2 floating-point coordinates. 7 /// Holds 2 floating-point coordinates.
8 class Point { 8 class Point {
9 const Point(this.x, this.y); 9 const Point(this.x, this.y);
10 10
11 final double x; 11 final double x;
12 final double y; 12 final double y;
13 13
14 static const Point origin = const Point(0.0, 0.0); 14 static const Point origin = const Point(0.0, 0.0);
15 15
16 bool operator ==(other) => other is Point && x == other.x && y == other.y; 16 bool operator ==(other) => other is Point && x == other.x && y == other.y;
17 Size operator -(Point other) => new Size(x - other.x, y - other.y); 17 Point operator -() => new Point(-x, -y);
18 Point operator +(Size size) => new Point(x + size.width, y + size.height); 18 Offset operator -(Point other) => new Offset(x - other.x, y - other.y);
19 Point operator +(Offset other) => new Point(x + other.dx, y + other.dy);
19 20
20 // does the equivalent of "return this - Point(0,0)" 21 // does the equivalent of "return this - Point.origin"
21 Size toSize() => new Size(x, y); 22 Offset toOffset() => new Offset(x, y);
22 23
23 int get hashCode { 24 int get hashCode {
24 int result = 373; 25 int result = 373;
25 result = 37 * result + x.hashCode; 26 result = 37 * result + x.hashCode;
26 result = 37 * result + y.hashCode; 27 result = 37 * result + y.hashCode;
27 return result; 28 return result;
28 } 29 }
29 String toString() => "Point($x, $y)"; 30 String toString() => "Point($x, $y)";
30 } 31 }
OLDNEW
« no previous file with comments | « sky/engine/core/painting/Point.cpp ('k') | sky/engine/core/painting/Rect.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698