Merge pull request #1971 from pylaligand/operator

Added a few operators to the Velocity class.
This commit is contained in:
P.Y. Laligand 2016-02-17 16:28:05 -08:00
commit d93a87ee12

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;