Vixen
02b45cc4
csharp
public readonly record struct TimingFunction

Maps progress through a duration onto progress through a change.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

The two are not the same thing and conflating them is what makes UI motion feel wrong. Halfway through the time is not halfway through the movement — real things accelerate and settle — and a timing function is the curve that says by how much.

Springs are Vixen's extension, and the case for them in a game UI is that they are the only easing whose parameters are physical. A designer asking for "snappier" adjusts a stiffness; the same request against a cubic-bezier is four numbers found by guessing. They also compose properly with an interruption — a spring retargeted mid-flight carries its velocity, where a Bézier restarts from a standstill and visibly stutters.

Fields and properties (15)

  • public TimingFunctionKind Kind

    What shape it is.

  • public float X1

    The first control point's x.

  • public float Y1

    The first control point's y.

  • public float X2

    The second control point's x.

  • public float Y2

    The second control point's y.

  • public int Steps

    How many steps.

  • public StepPosition Position

    Where a step jumps.

  • public float Mass

    The spring's mass.

  • public float Stiffness

    The spring's stiffness.

  • public float Damping

    The spring's damping coefficient.

  • public static TimingFunction Linear

    Constant speed. CSS's linear.

  • public static TimingFunction Ease

    CSS's ease.

  • public static TimingFunction EaseIn

    CSS's ease-in.

  • public static TimingFunction EaseOut

    CSS's ease-out.

  • public static TimingFunction EaseInOut

    CSS's ease-in-out.

Methods (6)

  • public static TimingFunction Bezier(float x1, float y1, float x2, float y2)

    A cubic Bézier.

  • public static TimingFunction Step(int count, StepPosition position)

    A step function.

  • public static TimingFunction Spring(float mass, float stiffness, float damping)

    A damped spring.

  • public float Evaluate(float progress)

    Maps elapsed progress onto progress through the change.

  • public float SettlingDuration()

    How long a spring takes to settle.

  • public override string ToString()

    Returns the fully qualified type name of this instance.

Used by (7)

  • AnimationSpecVixen.Ui.Styling
  • AnimatorVixen.Ui.Styling
  • RunningTransitionVixen.Ui.Styling
  • TimingFunctionTestsVixen.Ui.Styling.Tests
  • TransitionParserVixen.Ui.Styling
  • TransitionSpecVixen.Ui.Styling
  • TransitionTestsVixen.Ui.Styling.Tests