Added a few operators to the Velocity class.

#1968
This commit is contained in:
P.Y. Laligand
2016-02-17 15:58:19 -08:00
parent 49c0ec3402
commit a6c4927b27

View File

@@ -218,6 +218,16 @@ class Velocity {
/// The number of pixels per second of velocity in the x and y directions.
final Offset pixelsPerSecond;
Velocity operator -() => new Velocity(pixelsPerSecond: -pixelsPerSecond);
Velocity operator -(Velocity other) {
return new Velocity(
pixelsPerSecond: pixelsPerSecond - other.pixelsPerSecond);
}
Velocity operator +(Velocity other) {
return new Velocity(
pixelsPerSecond: pixelsPerSecond + other.pixelsPerSecond);
}
bool operator ==(dynamic other) {
if (other is! Velocity)
return false;