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

Unified Diff: sky/engine/core/painting/Size.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
« sky/engine/core/painting/Rect.dart ('K') | « sky/engine/core/painting/Rect.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/engine/core/painting/Size.dart
diff --git a/sky/engine/core/painting/Size.dart b/sky/engine/core/painting/Size.dart
index 4b364bb009d090d0404dce9f03961fa8de31a499..0339cf20a696fe8710aa706c2b04225cf3bb18a9 100644
--- a/sky/engine/core/painting/Size.dart
+++ b/sky/engine/core/painting/Size.dart
@@ -5,6 +5,7 @@
part of dart.sky;
/// Holds a 2D floating-point size.
+/// Think of this as a vector from Point(0,0) to Point(size.width, size.height)
class Size {
final double width;
final double height;
@@ -16,10 +17,11 @@ class Size {
const Size.fromWidth(this.width) : height = double.INFINITY;
const Size.fromHeight(this.height) : width = double.INFINITY;
- bool operator ==(other) {
- if (!(other is Size)) return false;
- return width == other.width && height == other.height;
- }
+ bool operator ==(other) => other is Size && width == other.width && height == other.height;
+
+ // does the equivalent of "return new Point(0,0) + this"
+ Point toPoint() => new Point(this.width, this.height);
+
int get hashCode {
int result = 373;
result = 37 * result + width.hashCode;
« sky/engine/core/painting/Rect.dart ('K') | « sky/engine/core/painting/Rect.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698