Skip to content

Animation

StructChartGuruChartGuru
public struct Animation

Describes how a chart value change animates. Modeled after SwiftUI’s Animation: static factories produce common curves; the fluent Delay/Speed/Repeat modifiers decorate the animation.

Usage:

chart.Animation = Animation.EaseInOut(0.35f);
chart.Animation = Animation.Spring(duration: 0.4f, bounce: 0.2f);
chart.Animation = Animation.Default.Delay(0.1f);

A ChartGuru.Chart with no Animation (null) applies changes instantly, matching Swift Charts’ behavior of not animating unless withAnimation / .animation is used.

public static Animation Linear(float duration = 0.35)

Creates a constant-speed animation with the supplied duration in seconds.

Parameters

Name Type
duration System.Single

Returns

ChartGuru.Animation

public static Animation EaseIn(float duration = 0.35)

Creates an animation that accelerates from rest over the supplied duration in seconds.

Parameters

Name Type
duration System.Single

Returns

ChartGuru.Animation

public static Animation EaseOut(float duration = 0.35)

Creates an animation that decelerates to rest over the supplied duration in seconds.

Parameters

Name Type
duration System.Single

Returns

ChartGuru.Animation

public static Animation EaseInOut(float duration = 0.35)

Creates an animation that accelerates and then decelerates over the supplied duration in seconds.

Parameters

Name Type
duration System.Single

Returns

ChartGuru.Animation

public static Animation Spring(float duration = 0.5, float bounce = 0)

SwiftUI-style spring. bounce ranges from -1 (overdamped) through 0 (critically damped, no overshoot) to 1 (very bouncy). Typical values: 0 to 0.3.

Parameters

Name Type
duration System.Single
bounce System.Single

Returns

ChartGuru.Animation

InterpolatingSpring(float, float, float, float)

Section titled “InterpolatingSpring(float, float, float, float)”
public static Animation InterpolatingSpring(float mass = 1, float stiffness = 100, float damping = 10, float initialVelocity = 0)

Classical spring parameterized by mass/stiffness/damping/initialVelocity.

Parameters

Name Type
mass System.Single
stiffness System.Single
damping System.Single
initialVelocity System.Single

Returns

ChartGuru.Animation

public static Animation Bouncy(float duration = 0.5, float extraBounce = 0)

Creates a spring animation with the supplied duration and bounce amount.

Parameters

Name Type
duration System.Single
extraBounce System.Single

Returns

ChartGuru.Animation

public static Animation Smooth(float duration = 0.5, float extraBounce = 0)

Creates a smooth spring animation with the supplied duration and extra bounce amount.

Parameters

Name Type
duration System.Single
extraBounce System.Single

Returns

ChartGuru.Animation

public static Animation Snappy(float duration = 0.5, float extraBounce = 0)

Creates a fast-settling spring animation with the supplied duration and extra bounce amount.

Parameters

Name Type
duration System.Single
extraBounce System.Single

Returns

ChartGuru.Animation

public static Animation SpringResponse(float response = 0.55, float dampingFraction = 0.825)

A spring animation parameterized by perceptual response and damping fraction. Mirrors SwiftUI’s .spring(response:dampingFraction:blendDuration:). response is the stiffness expressed as a perceptual duration in seconds (lower = snappier). dampingFraction of 1 is critically damped (no bounce), lower values bounce more.

Parameters

Name Type
response System.Single
dampingFraction System.Single

Returns

ChartGuru.Animation

TimingCurve(float, float, float, float, float)

Section titled “TimingCurve(float, float, float, float, float)”
public static Animation TimingCurve(float c1x, float c1y, float c2x, float c2y, float duration = 0.35)

An animation created from a cubic Bézier timing curve. Mirrors SwiftUI’s .timingCurve(::::duration:). Control points are in [0, 1].

Parameters

Name Type
c1x System.Single
c1y System.Single
c2x System.Single
c2y System.Single
duration System.Single

Returns

ChartGuru.Animation

public static Animation FromEasing(Easing easing, float duration = 0.35)

Creates a named easing animation for UI Toolkit and custom authoring surfaces. The named curves use the standard Penner-style formulas behind their labels instead of collapsing to generic ease-in/ease-out/ease-in-out curves.

Parameters

Name Type
easing ChartGuru.Easing
duration System.Single

Returns

ChartGuru.Animation

public Animation Delay(float seconds)

Return a copy that starts seconds after being triggered.

Parameters

Name Type
seconds System.Single

Returns

ChartGuru.Animation

public Animation Speed(float factor)

Return a copy that plays at factor× speed.

Parameters

Name Type
factor System.Single

Returns

ChartGuru.Animation

public Animation RepeatCount(int count, bool autoreverses = true)

Repeat the animation for the given total number of plays. Matches SwiftUI’s repeatCount(_:autoreverses:): autoreverses count toward the total. A value of 1 plays forward once and never reverses (even with autoreverses true); 2 plays forward then in reverse; 3 plays fwd/rev/fwd; etc.

Parameters

Name Type
count System.Int32
autoreverses System.Boolean

Returns

ChartGuru.Animation

public Animation RepeatForever(bool autoreverses = true)

Repeat forever until cancelled, matching SwiftUI’s repeatForever.

Parameters

Name Type
autoreverses System.Boolean

Returns

ChartGuru.Animation

public float Evaluate(float t)

Evaluate the animation curve at t in [0, 1], returning the eased progress value. Spring curves can overshoot beyond 1 before settling.

Parameters

Name Type
t System.Single

Returns

System.Single

public bool Equals(Animation other)

Parameters

Name Type
other ChartGuru.Animation

Returns

System.Boolean

public override bool Equals(object obj)

Parameters

Name Type
obj System.Object

Returns

System.Boolean

public override int GetHashCode()

Returns

System.Int32

public override string ToString()

Returns

System.String

public Animation.Kind Curve { get; }

Returns

ChartGuru.Animation.Kind

public Easing EasingPreset { get; }

Named easing Preset (only used by ChartGuru.Animation.Kind.Easing).

Returns

ChartGuru.Easing

public float Duration { get; }

Base duration in seconds, before speed scaling.

Returns

System.Single

public float Bounce { get; }

Spring bounce amount. Typical range [-0.3, 0.7]. Only used for spring curves.

Returns

System.Single

public float Mass { get; }

Returns

System.Single

public float Stiffness { get; }

Returns

System.Single

public float Damping { get; }

Returns

System.Single

public float InitialVelocity { get; }

Returns

System.Single

public float DelaySeconds { get; }

Returns

System.Single

public float SpeedFactor { get; }

Speed multiplier. >1 = faster, <1 = slower.

Returns

System.Single

public int Repeats { get; }

Total number of plays. Matches Apple’s repeatCount(_:) semantics: an autoreverse counts toward the total. 0 is the default (uninitialized) and is interpreted as “play once”. System.Int32.MaxValue = repeat forever. Example: RepeatCount(2, autoreverses: true) plays forward once, then in reverse.

Returns

System.Int32

public bool Autoreverses { get; }

Returns

System.Boolean

public bool IsRepeating { get; }

True when the animation plays more than one cycle (counting autoreverses).

Returns

System.Boolean

public float C1x { get; }

Cubic Bézier first control-point X (only used by ChartGuru.Animation.Kind.TimingCurve).

Returns

System.Single

public float C1y { get; }

Cubic Bézier first control-point Y (only used by ChartGuru.Animation.Kind.TimingCurve).

Returns

System.Single

public float C2x { get; }

Cubic Bézier second control-point X (only used by ChartGuru.Animation.Kind.TimingCurve).

Returns

System.Single

public float C2y { get; }

Cubic Bézier second control-point Y (only used by ChartGuru.Animation.Kind.TimingCurve).

Returns

System.Single

public float EffectiveDuration { get; }

Effective duration after speed scaling.

Returns

System.Single

public static Animation Default { get; }

SwiftUI .default — since iOS 17 this is a critically damped spring rather than an ease curve. Equivalent to .smooth, i.e. .spring(duration: 0.5, bounce: 0).

Returns

ChartGuru.Animation