Class SKAnimationSpring
A spring-physics animator that smoothly transitions between values. Uses spring physics to animate toward a target value, matching the feel of natural spring motion (as seen in Silverlight's VisualStateKeySpline).
public class SKAnimationSpring
- Inheritance
-
SKAnimationSpring
- Inherited Members
Remarks
The spring can be configured as critically damped (no overshoot), underdamped (bouncy), or overdamped (sluggish) via the DampingRatio property. For critical damping use an exact analytical solution; for other ratios it uses a sub-stepped semi-implicit Euler integration for stability.
Constructors
- SKAnimationSpring(double)
Initializes a new SKAnimationSpring starting at
initialValue.
Properties
- Current
Gets or sets the current animated value. Setting this resets the velocity to zero.
- DampingRatio
Gets or sets the damping ratio.
- 1.0Critically damped — smooth with no overshoot (default).
- <1.0Underdamped — bouncy, oscillates around target.
- >1.0Overdamped — slow to settle.
0.01.
- IsSettled
Gets a value indicating whether the spring has settled (within epsilon of target with near-zero velocity).
- Stiffness
Gets or sets the spring stiffness. Higher values produce a faster snap. Minimum value is
0.1.
- Target
Gets or sets the target value the spring is animating toward.
- Velocity
Gets the current velocity of the spring.
Methods
- Reset(double)
Resets to a new value with no animation (sets both current and target).
- SnapToTarget()
Immediately sets current to target, stopping all animation.
- Update(double)
Updates the spring by a time step. Uses the exact critically-damped spring solution for unconditional stability at any time step.