DecayAnimation
public struct DecayAnimation<Value: VectorConvertible>: ValueAnimationType
Given a starting velocity, DecayAnimation
will slowly bring the value
to a stop (where velocity
== Value.zero
).
DecayAnimation
uses a DynamicSolver
containing a DecayFunction
internally.
-
Creates a new
DecayAnimation
instance.Declaration
Swift
public init(threshold: Scalar = 0.1, from: Value = Value.zero, velocity: Value = Value.zero)
Parameters
threshold
The minimum velocity, below which the animation will finish.
from
The initial value of the animation.
velocity
The velocity at time
0
. -
Advances the animation.
Declaration
Swift
public mutating func advance(_ elapsed: Double)
Parameters
elapsed
The time (in seconds) to advance the animation.
-
Returns
true
if the velocity has settled at 0.Declaration
Swift
public var finished: Bool
-
The current value.
Declaration
Swift
public var value: Value
-
The current velocity.
Declaration
Swift
public var velocity: Value
-
Each component of the simulation’s velocity must be within this distance of 0.0 for the animation to complete.
Declaration
Swift
public var threshold: Scalar
-
The strength with which the velocity will be reduced. The acceleration for the simulation is calculated as
-drag * velocity
. Default:3.0
.Declaration
Swift
public var drag: Scalar