Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | 58x 57x 57x 57x | type Point = [number, number];
interface TimedMovement {
from: Point;
to: Point;
started: number;
}
export const easeOutCubic = (progress: number) => 1 - (1 - progress) ** 3;
export function vehiclePoint(moving: TimedMovement, now: number, durationMs: number): Point {
const progress = Math.max(0, Math.min(1, (now - moving.started) / durationMs));
const eased = easeOutCubic(progress);
return [
moving.from[0] + (moving.to[0] - moving.from[0]) * eased,
moving.from[1] + (moving.to[1] - moving.from[1]) * eased,
];
}
|