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

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

Issue 1238573002: AnimatedType should hit |end| (Closed) Base URL: git@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
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 a 2D floating-point offset. 7 /// Holds a 2D floating-point offset.
8 /// Think of this as a vector from an unspecified point 8 /// Think of this as a vector from an unspecified point
9 class Offset extends OffsetBase { 9 class Offset extends OffsetBase {
10 const Offset(dx, dy) : super(dx, dy); 10 const Offset(dx, dy) : super(dx, dy);
11 Offset.copy(Offset source) : super(source.dx, source.dy); 11 Offset.copy(Offset source) : super(source.dx, source.dy);
12 12
13 double get dx => _dx; 13 double get dx => _dx;
14 double get dy => _dy; 14 double get dy => _dy;
15 15
16 double get distance => math.sqrt(_dx * _dx + _dy * _dy);
17
16 static const Offset zero = const Offset(0.0, 0.0); 18 static const Offset zero = const Offset(0.0, 0.0);
17 static const Offset infinite = const Offset(double.INFINITY, double.INFINITY); 19 static const Offset infinite = const Offset(double.INFINITY, double.INFINITY);
18 20
19 Offset scale(double scaleX, double scaleY) => new Offset(dx * scaleX, dy * sca leY); 21 Offset scale(double scaleX, double scaleY) => new Offset(dx * scaleX, dy * sca leY);
20 Offset translate(double translateX, double translateY) => new Offset(dx + tran slateX, dy + translateY); 22 Offset translate(double translateX, double translateY) => new Offset(dx + tran slateX, dy + translateY);
21 23
22 Offset operator -() => new Offset(-dx, -dy); 24 Offset operator -() => new Offset(-dx, -dy);
23 Offset operator -(Offset other) => new Offset(dx - other.dx, dy - other.dy); 25 Offset operator -(Offset other) => new Offset(dx - other.dx, dy - other.dy);
24 Offset operator +(Offset other) => new Offset(dx + other.dx, dy + other.dy); 26 Offset operator +(Offset other) => new Offset(dx + other.dx, dy + other.dy);
25 Offset operator *(double operand) => new Offset(dx * operand, dy * operand); 27 Offset operator *(double operand) => new Offset(dx * operand, dy * operand);
26 Offset operator /(double operand) => new Offset(dx / operand, dy / operand); 28 Offset operator /(double operand) => new Offset(dx / operand, dy / operand);
27 Offset operator ~/(double operand) => new Offset((dx ~/ operand).toDouble(), ( dy ~/ operand).toDouble()); 29 Offset operator ~/(double operand) => new Offset((dx ~/ operand).toDouble(), ( dy ~/ operand).toDouble());
28 Offset operator %(double operand) => new Offset(dx % operand, dy % operand); 30 Offset operator %(double operand) => new Offset(dx % operand, dy % operand);
29 Rect operator &(Size other) => new Rect.fromLTWH(dx, dy, other.width, other.he ight); 31 Rect operator &(Size other) => new Rect.fromLTWH(dx, dy, other.width, other.he ight);
30 32
31 // does the equivalent of "return new Point(0,0) + this" 33 // does the equivalent of "return new Point(0,0) + this"
32 Point toPoint() => new Point(this.dx, this.dy); 34 Point toPoint() => new Point(this.dx, this.dy);
33 35
34 String toString() => "Offset($dx, $dy)"; 36 String toString() => "Offset($dx, $dy)";
35 } 37 }
OLDNEW
« no previous file with comments | « sky/engine/bindings/scripts/templates/dart_blink.template ('k') | sky/sdk/lib/animation/animation_performance.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698