@omnimedia/omnitool
Version:
open source video processing tools
63 lines (50 loc) • 1.55 kB
text/typescript
import {Item, VisualAnimatableItem} from "./parts/item.js"
export type Interpolation =
| "linear"
| "ease"
| "easeIn"
| "easeOut"
| "bounce"
| "catmullRom"
export type Keyframe<Value = number> = [time: number, value: Value]
export type Keyframes<Value = number> = Keyframe<Value>[]
export type Vec2 = [x: number, y: number]
export type Transform = [position: Vec2, scale: Vec2, rotation: number]
export type TrackVec2 = {
x: Keyframes
y: Keyframes
}
export type Anim<T> = {
terp: Interpolation
track: T
}
export type TrackTransform = {
position: TrackVec2
scale: TrackVec2
rotation: Keyframes
}
export type ScalarAnimation = Anim<Keyframes>
export type Vec2Animation = Anim<TrackVec2>
export type TransformAnimation = Anim<TrackTransform>
export type VisualAnimations = {
opacity?: ScalarAnimation
transform?: TransformAnimation
}
export type VisualAnimationInput<TKey extends keyof VisualAnimations> =
TKey extends "transform" ? Keyframes<Transform> : Keyframes
export type VisualAnimationValue<TKey extends keyof VisualAnimations> =
TKey extends "transform" ? TransformAnimation : ScalarAnimation
export interface AnimateAction<TKey extends keyof VisualAnimations = keyof VisualAnimations> {
<T extends VisualAnimatableItem>(
item: T,
terp: Interpolation,
track: VisualAnimationInput<TKey>
): T
make(terp: Interpolation, track: VisualAnimationInput<TKey>): Item.Animation
}
// export type Animations = Anim<TrackTransform>
export type TransformOptions = {
position?: Vec2
scale?: Vec2
rotation?: number
}