public Animation Linear <T>( FieldGetFn <T> getter, FieldSetFn <T> setter, LerpFn <T> lerp, T dest, float velocity, Animation.Callback callback = null) { T origin = getter.Invoke(); float t = 0; return(new Animation( () => { origin = getter.Invoke(); t = 0f; return null; }, (object state, float dt) => { t += dt * velocity; setter.Invoke(lerp.Invoke(origin, dest, t)); return state; }, (object state) => t >= 1, (object state) => { if (callback != null) { callback.Invoke(null); } })); }
public Animation Lerp <T>( FieldGetFn <T> getter, FieldSetFn <T> setter, LerpFn <T> lerp, Comparator <T> magnitude, T dest, float velocity, Animation.Callback callback = null) { return(new Animation( () => null, (object state, float t) => { setter.Invoke(lerp.Invoke(getter.Invoke(), dest, velocity * t)); return state; }, (object state) => (magnitude.Invoke(getter.Invoke(), dest) < epsilon), (object state) => { setter.Invoke(dest); if (callback != null) { callback.Invoke(state); } } )); }