Class Timeline
- Namespace
- Icy.Animations
- Assembly
- IcyUI.dll
Describes how a single property should be animated: which property, over how long, through which AnimationKeyframe values, with which EasingFunction, and how many times to repeat.
[ContentProperty("Keyframes")]
public class Timeline
- Inheritance
-
Timeline
- Inherited Members
- Extension Methods
Remarks
A Timeline is a reusable description, not a running animation - construct an Animation from it (or call Animate(UIElement, Timeline)) to actually play it against a target object.
Constructors
Timeline(string, TimeSpan)
Initializes a new instance of the Timeline class.
public Timeline(string targetProperty, TimeSpan duration)
Parameters
targetPropertystringThe name of the property to animate, as registered with PropertyRegistry (see RegisterReferenceAttribute).
durationTimeSpanHow long one playback pass takes.
Fields
Forever
A RepeatCount value indicating the timeline should repeat indefinitely until explicitly stopped.
public const int Forever = -1
Field Value
Properties
AutoReverse
Gets a value indicating whether each repeat plays forward and then backward, instead of always forward.
public bool AutoReverse { get; init; }
Property Value
Duration
Gets how long one playback pass takes.
public TimeSpan Duration { get; }
Property Value
Easing
Gets the easing function applied to the normalized playback position before evaluating Keyframes.
public EasingFunction Easing { get; init; }
Property Value
Keyframes
Gets the keyframes this timeline passes through, sorted ascending by Offset.
public IReadOnlyList<AnimationKeyframe> Keyframes { get; }
Property Value
Remarks
Between two keyframes whose values are both a type Animation knows how to interpolate (currently float, double, int, Vector2/Vector3/Vector4, and Color), the effective value is linearly interpolated between them. For any other type (e.g. an enum or string), the earlier keyframe's value holds until playback reaches the later one, which it then snaps to.
RepeatCount
Gets how many times this timeline plays before stopping on its own, or Forever to repeat indefinitely until explicitly stopped.
public int RepeatCount { get; init; }
Property Value
Remarks
With AutoReverse set, each repeat is one forward-then-backward round trip.
-1 in markup - see Forever.
TargetProperty
Gets the name of the property this timeline animates.
public string TargetProperty { get; }
Property Value
Methods
AddKeyframe(float, object?)
Adds a keyframe to this timeline.
public Timeline AddKeyframe(float offset, object? value)
Parameters
offsetfloatThe normalized position within the timeline, from 0 (start) to 1 (end).
valueobjectThe value at this position.
Returns
- Timeline
This instance, for chaining.
FromTo(string, TimeSpan, object?, object?, EasingFunction?, int, bool)
Creates a timeline that animates directly from one value to another - the common case, covering the vast majority of animations (a fade, a slide, a color transition).
public static Timeline FromTo(string targetProperty, TimeSpan duration, object? from, object? to, EasingFunction? easing = null, int repeatCount = 1, bool autoReverse = false)
Parameters
targetPropertystringThe name of the property to animate.
durationTimeSpanHow long one playback pass takes.
fromobjectThe value at the start of playback.
toobjectThe value at the end of playback.
easingEasingFunctionrepeatCountintHow many times to repeat - see RepeatCount.
autoReverseboolWhether each repeat plays forward and then backward - see AutoReverse.
Returns
- Timeline
The new timeline, with
fromandtoalready added as its keyframes.