diff options
Diffstat (limited to 'apps/web/src/lib/animation/resolve.ts')
| -rw-r--r-- | apps/web/src/lib/animation/resolve.ts | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/apps/web/src/lib/animation/resolve.ts b/apps/web/src/lib/animation/resolve.ts index 58f292b1..450ae983 100644 --- a/apps/web/src/lib/animation/resolve.ts +++ b/apps/web/src/lib/animation/resolve.ts @@ -1,6 +1,7 @@ -import type { ElementAnimations } from "@/types/animation"; +import type { AnimationPropertyPath, ElementAnimations } from "@/types/animation"; import type { Transform } from "@/types/timeline"; -import { getNumberChannelValueAtTime } from "./interpolation"; +import { getColorValueAtTime, getNumberChannelValueAtTime } from "./interpolation"; +import { getColorChannelForPath } from "./color-channel"; import { getNumberChannelForPath } from "./number-channel"; export function getElementLocalTime({ @@ -91,6 +92,24 @@ export function resolveOpacityAtTime({ }); } +export function resolveColorAtTime({ + baseColor, + animations, + propertyPath, + localTime, +}: { + baseColor: string; + animations: ElementAnimations | undefined; + propertyPath: AnimationPropertyPath; + localTime: number; +}): string { + return getColorValueAtTime({ + channel: getColorChannelForPath({ animations, propertyPath }), + time: Math.max(0, localTime), + fallbackValue: baseColor, + }); +} + export function resolveVolumeAtTime({ baseVolume, animations, |
