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

Unified Diff: sky/engine/core/painting/Point.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, 7 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 side-by-side diff with in-line comments
Download patch
Index: sky/engine/core/painting/Point.dart
diff --git a/sky/engine/core/painting/Point.dart b/sky/engine/core/painting/Point.dart
index 62cd87d7b805ba769b4a96b7922e41e06796813c..418660537be7c5d2abe6f0cd2fff947609ddce59 100644
--- a/sky/engine/core/painting/Point.dart
+++ b/sky/engine/core/painting/Point.dart
@@ -11,10 +11,13 @@ class Point {
const Point(this.x, this.y);
- bool operator ==(other) {
- if (!(other is Point)) return false;
- return x == other.x && y == other.y;
- }
+ bool operator ==(other) => other is Point && x == other.x && y == other.y;
+ Size operator -(Point other) => new Size(x - other.x, y - other.y);
+ Point operator +(Size size) => new Point(x + size.width, y + size.height);
+
+ // does the equivalent of "return this - Point(0,0)"
+ Size toSize() => new Size(x, y);
+
int get hashCode {
int result = 373;
result = 37 * result + x.hashCode;

Powered by Google App Engine
This is Rietveld 408576698