Visualize Your Ideas With Code
feat: time parameter for tweens
aarthificial3fe90edc49ab
diff --git a/src/animations/tween.ts b/src/animations/tween.tsindex 4d20d16e..9b990948 100644--- a/src/animations/tween.ts+++ b/src/animations/tween.ts@@ -4,16 +4,17 @@ import {Project} from '../Project';export function* tween(this: Project,duration: number,- callback: (value: TimeTween) => void,+ callback: (value: TimeTween, time: number) => void,): Generator {- const frames = duration * this.framesPerSeconds;+ const frames = this.secondsToFrames(duration);let startFrame = this.frame;const timeTween = new TimeTween(0);while (this.frame - startFrame < frames) {+ const time = this.framesToSeconds(this.frame - startFrame);timeTween.value = (this.frame - startFrame) / frames;- callback(timeTween);+ callback(timeTween, time);yield;}timeTween.value = 1;- callback(timeTween);+ callback(timeTween, this.framesToSeconds(frames));}