Table of Contents

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

targetProperty string

The name of the property to animate, as registered with PropertyRegistry (see RegisterReferenceAttribute).

duration TimeSpan

How 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

int

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

bool

Duration

Gets how long one playback pass takes.

public TimeSpan Duration { get; }

Property Value

TimeSpan

Easing

Gets the easing function applied to the normalized playback position before evaluating Keyframes.

public EasingFunction Easing { get; init; }

Property Value

EasingFunction

Keyframes

Gets the keyframes this timeline passes through, sorted ascending by Offset.

public IReadOnlyList<AnimationKeyframe> Keyframes { get; }

Property Value

IReadOnlyList<AnimationKeyframe>

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

int

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

string

Methods

AddKeyframe(float, object?)

Adds a keyframe to this timeline.

public Timeline AddKeyframe(float offset, object? value)

Parameters

offset float

The normalized position within the timeline, from 0 (start) to 1 (end).

value object

The 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

targetProperty string

The name of the property to animate.

duration TimeSpan

How long one playback pass takes.

from object

The value at the start of playback.

to object

The value at the end of playback.

easing EasingFunction

The easing function to use, or null for Linear.

repeatCount int

How many times to repeat - see RepeatCount.

autoReverse bool

Whether each repeat plays forward and then backward - see AutoReverse.

Returns

Timeline

The new timeline, with from and to already added as its keyframes.