Skip to content

Instantly share code, notes, and snippets.

@cdiggins
Created November 18, 2022 16:59
Show Gist options
  • Save cdiggins/9c64f2924631f1f0d4d4bae2c2740c7d to your computer and use it in GitHub Desktop.
Save cdiggins/9c64f2924631f1f0d4d4bae2c2740c7d to your computer and use it in GitHub Desktop.
Tween / Animation Engine Interface Proposal
public interface IAnimator
{
IArray<IAnimation> Animations { get; }
IAnimator Start(IAnimation anim);
IAnimator End(IAnimation anim);
IAnimator IsRunning();
T Drive<T>(IAnimation animation, Func<T, T, float, T> lerp);
}
public interface IAnimation
{
double Evaluate(double t);
Interval Period { get; }
}
public static class AnimationExtensions
{
public static IAnimation CutAfter(this IAnimation animation, double time) => default;
public static IAnimation CutBefore(this IAnimation animation, double time) => default;
public static IAnimation Splice(this IAnimation animation, double time, IAnimation other) => default;
public static IAnimation Invert(this IAnimation animation) => default;
public static IAnimation Mirror(this IAnimation animation) => default;
public static IAnimation Repeat(this IAnimation animation, double count) => default;
public static IAnimation YoyoLoop(this IAnimation animation, double count) => default;
public static IAnimation SetStartTime(this IAnimation animation, double d) => default;
public static IAnimation SetEase(this IAnimation animation, Func<double, double> func) => default;
public static IAnimation Sequence(this IAnimation animation, IAnimation other) => default;
public static IAnimation SetDuration(this IAnimation animation, double scale) => default;
public static IAnimation Race(this IAnimation animation, IAnimation other) => default;
public static IAnimation Blend(this IAnimation animation, IAnimation other, IAnimation blendCurve) => default;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment