public static async Task AnimateAsync(this IRectangularF rectangular, RectangularAnimationOptions options) { var startX = rectangular.Left; var startY = rectangular.Top; var startW = rectangular.Width; var startH = rectangular.Height; await Animator.AnimateAsync(new FloatAnimatorOptions() { Duration = options.Duration, AutoReverse = options.AutoReverse, AutoReverseDelay = options.AutoReverseDelay, DelayProvider = options.DelayProvider, Loop = options.Loop, EasingFunction = options.EasingFunction, From = 0, To = 1, IsCancelled = options.IsCancelled, Setter = v => { var dest = options.Destination(); var xDelta = dest.Left - startX; var yDelta = dest.Top - startY; var wDelta = dest.Width - startW; var hDelta = dest.Height - startH; var frameX = startX + (v *xDelta); var frameY = startY + (v *yDelta); var frameW = startW + (v *wDelta); var frameH = startH + (v *hDelta); var frameBounds = RectangularF.Create(frameX, frameY, frameW, frameH); options.Setter(rectangular, frameBounds); } }); }
public static Task AnimateAsync(this RectF rectangular, RectangularAnimationOptions options) { return(AnimateAsync(new ColliderBox(rectangular), options)); }