Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 static const Offset zero = const Offset(0.0, 0.0); | 16 static const Offset zero = const Offset(0.0, 0.0); |
| 17 static const Offset infinite = const Offset(double.INFINITY, double.INFINITY); | 17 static const Offset infinite = const Offset(double.INFINITY, double.INFINITY); |
| 18 | 18 |
| 19 Offset scale(double scaleX, double scaleY) => new Offset(dx * scaleX, dy * sca leY); | 19 Offset scale(double scaleX, double scaleY) => new Offset(dx * scaleX, dy * sca leY); |
| 20 | 20 |
| 21 Offset operator -() => new Offset(-dx, -dy); | 21 Offset operator -() => new Offset(-dx, -dy); |
| 22 Offset operator -(Offset other) => new Offset(dx - other.dx, dy - other.dy); | 22 Offset operator -(Offset other) => new Offset(dx - other.dx, dy - other.dy); |
| 23 Offset operator +(Offset other) => new Offset(dx + other.dx, dy + other.dy); | 23 Offset operator +(Offset other) => new Offset(dx + other.dx, dy + other.dy); |
| 24 Offset operator *(double scale) => new Offset(dx * scale, dy * scale); | |
|
Hixie
2015/06/30 23:11:56
If you add *, also add /, ~/, and %. See Size.dart
Matt Perry
2015/07/01 18:17:43
Done.
| |
| 24 Rect operator &(Size other) => new Rect.fromLTWH(dx, dy, other.width, other.he ight); | 25 Rect operator &(Size other) => new Rect.fromLTWH(dx, dy, other.width, other.he ight); |
| 25 | 26 |
| 26 // does the equivalent of "return new Point(0,0) + this" | 27 // does the equivalent of "return new Point(0,0) + this" |
| 27 Point toPoint() => new Point(this.dx, this.dy); | 28 Point toPoint() => new Point(this.dx, this.dy); |
| 28 | 29 |
| 29 String toString() => "Offset($dx, $dy)"; | 30 String toString() => "Offset($dx, $dy)"; |
| 30 } | 31 } |
| OLD | NEW |