import { type EasingFunction } from '../types'; type EasingFunc = (t: number) => number; /** * 이징 함수 구현 맵 */ const easingFunctions: Record = { linear: (t) => t, easeIn: (t) => t * t, easeOut: (t) => t * (2 - t), easeInOut: (t) => (t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t), easeInQuad: (t) => t * t, easeOutQuad: (t) => t * (2 - t), easeInCubic: (t) => t * t * t, easeOutCubic: (t) => 1 - Math.pow(1 - t, 3), }; /** * 진행도에 이징 함수를 적용 * @param progress 진행도 (0.0 - 1.0) * @param easingType 적용할 이징 함수 타입 * @returns 이징이 적용된 진행도 (0.0 - 1.0) */ export const applyEasing = ( progress: number, easingType: EasingFunction ): number => { const clampedProgress = Math.max(0, Math.min(1, progress)); return easingFunctions[easingType](clampedProgress); };