Home

Awesome

Reactive-Animation

Small, simple C# animation library built using the reactive extensions framework, utilizing Robert Penner's easing functions. Does not make use of reflection, instead allowing the caller to use a function/monad/observer to update their desired object.

Available as a NuGet package at https://www.nuget.org/packages/ReactiveAnimation/

Why use reactive extensions?

Observables are very useful, because it allows you to easily react to events like resizes or repositions etc. For example, you can animate an object to chase another object that is being animated, and have the animations scale automatically when the Form they are on changes size. All the hard work is being done on separate threads, so you don't have to worry about it. For Windows Forms, Rx can ensure that your subscribed observer executes on the Control thread, so it's super easy to update properties etc. without worrying about using Invoke.

Principles

Examples

var a = new Animation {
  DurationInFrames = Animation.FromTimeSpanToDurationInFrames(3),
  EasingFunction = ef => Easing.EaseInOut(ef, EasingType.Quadratic)
};
a.AnimateOnControlThread(
  form, 
  ObservableHelper.FixedValue((float)0.8),
  ObservableHelper.FixedValue((float)1),
  v => f.Opacity = v.CurrentValue
);
a.Start();
var cts = LinearAnimation.AnimateControl(
  button, // control to animate
  ObservableHelper.FixedValue(new Point(0, 150)), // animate until at this position
  ObservableHelper.FixedValue(5), // speed to move at
  true); // keep in same relative position when the control's parent resizes
// returns a CancellationTokenSource that you can use to cancel the animation

MyGet Build Status