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

Unified Diff: sky/engine/core/painting/Offset.dart

Issue 1214833004: Split Size into Size and Offset. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: add the new files also 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 side-by-side diff with in-line comments
Download patch
Index: sky/engine/core/painting/Offset.dart
diff --git a/sky/engine/core/painting/Offset.dart b/sky/engine/core/painting/Offset.dart
new file mode 100644
index 0000000000000000000000000000000000000000..161bd754c5ca2637d09219f4bb6eea5fb4ab1cf9
--- /dev/null
+++ b/sky/engine/core/painting/Offset.dart
@@ -0,0 +1,29 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+part of dart.sky;
+
+/// Holds a 2D floating-point offset.
+/// Think of this as a vector from an unspecified point
+class Offset extends OffsetBase {
+ const Offset(dx, dy) : super(dx, dy);
+ Offset.copy(Offset source) : super(source.dx, source.dy);
+
+ double get dx => _dx;
+ double get dy => _dy;
+
+ static const Offset zero = const Offset(0.0, 0.0);
+ static const Offset infinite = const Offset(double.INFINITY, double.INFINITY);
+
+ Offset scale(double scaleX, double scaleY) => new Offset(dx * scaleX, dy * scaleY);
+
+ Offset operator -() => new Offset(-dx, -dy);
+ Offset operator -(Offset other) => new Offset(dx - other.dx, dy - other.dy);
+ Offset operator +(Offset other) => new Offset(dx + other.dx, dy + other.dy);
+
+ // does the equivalent of "return new Point(0,0) + this"
abarth-chromium 2015/06/26 22:04:42 s/new Point(0,0)/Point.origin/
+ Point toPoint() => new Point(this.dx, this.dy);
+
+ String toString() => "Offset($dx, $dy)";
+}

Powered by Google App Engine
This is Rietveld 408576698