public static IObservable <Color> PlayInOut(Color from, Color inEnd, Color outStart, Color to, IAnimator inAnimator, IAnimator outAnimator, IScheduler scheduler) { var inVelocity = inAnimator.CalcFinishVelocity(Vector4.Distance(inEnd, from)).PerSecond; var outVelocity = outAnimator.CalcStartVelocity(Vector4.Distance(to, outStart)).PerSecond; IAnimator linearAnimator; if (Math.Abs(inVelocity - outVelocity) < EqualDelta) { linearAnimator = Motion.Uniform((float)((inVelocity + outVelocity) / 2.0)); } else { var accel = (outVelocity * outVelocity - inVelocity * inVelocity) / (2.0f * Vector4.Distance(outStart, inEnd)); linearAnimator = Motion.Acceleration((float)accel, (float)inVelocity); } var compositeAnimator = new CompositeAnimator(new[] { Tuple.Create(inAnimator, Vector4.Distance(inEnd, from)), Tuple.Create(linearAnimator, Vector4.Distance(outStart, inEnd)), Tuple.Create(outAnimator, Vector4.Distance(to, outStart)), }); return(Play(new[] { from, inEnd, outStart, to }, compositeAnimator, scheduler)); }
public static IObservable <Color> PlayOut(Color from, Color outStart, Color to, IAnimator outAnimator, IScheduler scheduler) { var velocity = outAnimator.CalcStartVelocity(Vector4.Distance(to, outStart)); var linearAnimator = Easing.Linear(velocity); var compositeAnimator = new CompositeAnimator(new[] { Tuple.Create(linearAnimator, Vector4.Distance(outStart, from)), Tuple.Create(outAnimator, Vector4.Distance(to, outStart)), }); return(Play(new[] { from, outStart, to }, compositeAnimator, scheduler)); }
public static IObservable <float> PlayOut(float from, float outStart, float to, IAnimator outAnimator, IScheduler scheduler) { var velocity = outAnimator.CalcStartVelocity(Mathf.Abs(to - outStart)); var linearAnimator = Easing.Linear(velocity); var compositeAnimator = new CompositeAnimator(new[] { Tuple.Create(linearAnimator, Mathf.Abs(outStart - from)), Tuple.Create(outAnimator, Mathf.Abs(to - outStart)), }); return(Play(new[] { from, outStart, to }, compositeAnimator, scheduler)); }
public static IObservable <Color> PlayIn(Color from, Color inEnd, Color to, IAnimator inAnimator, IScheduler scheduler) { var velocity = inAnimator.CalcFinishVelocity(Vector4.Distance(inEnd, from)); var linearAnimator = Easing.Linear(velocity); var compositeAnimator = new CompositeAnimator(new[] { Tuple.Create(inAnimator, Vector4.Distance(inEnd, from)), Tuple.Create(linearAnimator, Vector4.Distance(to, inEnd)), }); return(Play(new[] { from, inEnd, to }, compositeAnimator, scheduler)); }
public static IObservable <float> PlayIn(float from, float inEnd, float to, IAnimator inAnimator, IScheduler scheduler) { var velocity = inAnimator.CalcFinishVelocity(Mathf.Abs(inEnd - from)); var linearAnimator = Easing.Linear(velocity); var compositeAnimator = new CompositeAnimator(new[] { Tuple.Create(inAnimator, Mathf.Abs(inEnd - from)), Tuple.Create(linearAnimator, Mathf.Abs(to - inEnd)), }); return(Play(new[] { from, inEnd, to }, compositeAnimator, scheduler)); }