Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add transitionFromFrame #91

Merged
merged 1 commit into from
May 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions renin/src/interpolations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,14 @@ export function elasticOut(b: number, c: number, d: number, t: number) {
const tc = ts * t;
return b + c * (33 * tc * ts + -106 * ts * ts + 126 * tc + -67 * ts + 15 * t);
}

/**
* Transition from 0 to 1 from a specific startFrame for duration duration.
* @param frame The current frame
* @param duration How many frames the transition takes
* @param startFrame What frame to start the transition at
* @returns value in [0, 1) representing the progression into the interval.
*/
export function transitionFromFrame(frame: number, duration: number, startFrame: number) {
return lerp(0, 1, (frame - startFrame) / duration);
}