Merge pull request #1971 from pylaligand/operator
Added a few operators to the Velocity class.
This commit is contained in:
commit
d93a87ee12
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user