Working tree is now the canonical repo. Off-chain play-money + trustless on-chain (FPMM AMM + CLOB via UMA settlement), AI market factory, creator/social/distribution, mobile shell + push, one-command demo + deploy-kit. Secrets excluded (see ENV-AND-KEYS.md). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
27 lines
728 B
TypeScript
27 lines
728 B
TypeScript
/* http://paulbourke.net/miscellaneous/interpolation */
|
|
export function cosine(a: number, b: number, factor: number) {
|
|
const mu2 = (1 - Math.cos(factor * Math.PI)) / 2;
|
|
return a * (1 - mu2) + b * mu2;
|
|
}
|
|
|
|
export function lerp(a: number, b: number, factor: number): number {
|
|
return a + (b - a) * factor;
|
|
}
|
|
|
|
export function quartic(a: number, b: number, factor: number): number {
|
|
return a + (b - a) * (1 - Math.pow(1 - factor, 4));
|
|
}
|
|
|
|
export class AnimationTimer {
|
|
private startTime_ms: number;
|
|
constructor() {
|
|
this.reset();
|
|
}
|
|
public getTime_s(cap = Number.POSITIVE_INFINITY) {
|
|
return Math.min((Date.now() - this.startTime_ms) * 0.001, cap);
|
|
}
|
|
public reset() {
|
|
this.startTime_ms = Date.now();
|
|
}
|
|
}
|