@it-compiles/anima 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/context.d.ts +70 -0
- package/dist/core/define-animation.d.ts +37 -0
- package/dist/core/easing.d.ts +19 -0
- package/dist/core/index.d.ts +9 -0
- package/dist/core/math.d.ts +22 -0
- package/dist/core/player.d.ts +20 -0
- package/dist/core/scene.d.ts +2 -0
- package/dist/core/timeline.d.ts +2 -0
- package/dist/core/types.d.ts +240 -0
- package/dist/core/video-renderer.d.ts +21 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +2420 -0
- package/dist/index.js.map +1 -0
- package/dist/player-MRRNy8I9.js +1458 -0
- package/dist/player-MRRNy8I9.js.map +1 -0
- package/dist/react/AnimaPlayer.d.ts +40 -0
- package/dist/react/index.d.ts +2 -0
- package/dist/react.d.ts +1 -0
- package/dist/react.js +425 -0
- package/dist/react.js.map +1 -0
- package/dist/vite/plugin.d.ts +26 -0
- package/dist/vite.d.ts +2 -0
- package/dist/vite.js +25 -0
- package/dist/vite.js.map +1 -0
- package/package.json +48 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { AlignOpts, Anchor, AnimCtx, BBoxHandle, FitMethods, GroupBuilder, GroupObject, LayoutBuilder, LayoutOpts, ObjRef, PinConstraint, PinMethods, ResizeMethods, ResolvedCtx, Scene, SceneObject, TransformMethods, Vec2 } from './types';
|
|
2
|
+
export interface DebugGroupInfo {
|
|
3
|
+
members: SceneObject[];
|
|
4
|
+
kind: 'group' | 'layout';
|
|
5
|
+
pin?: {
|
|
6
|
+
anchor: Anchor;
|
|
7
|
+
target: Vec2;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export declare class AnimCtxImpl implements AnimCtx {
|
|
11
|
+
private base;
|
|
12
|
+
private channels;
|
|
13
|
+
private pins;
|
|
14
|
+
private scene;
|
|
15
|
+
private debugGroups;
|
|
16
|
+
/** Resolve a Vec2 expression to a concrete Vec2 */
|
|
17
|
+
private resolveVec2;
|
|
18
|
+
/** Resolve a number expression to a concrete number */
|
|
19
|
+
private resolveNum;
|
|
20
|
+
/** Create a ResolvedCtx based on current state */
|
|
21
|
+
private createResolvedCtx;
|
|
22
|
+
reset(scene: Scene): void;
|
|
23
|
+
getDebugGroups(): DebugGroupInfo[];
|
|
24
|
+
getDebugPins(): Map<SceneObject, PinConstraint>;
|
|
25
|
+
/** Get the current world position of a specific anchor on an object */
|
|
26
|
+
private getCurrentAnchorPosition;
|
|
27
|
+
private getGroupBounds;
|
|
28
|
+
/** Get the origin position of an object in world space, accounting for any existing pin */
|
|
29
|
+
private getOriginPosition;
|
|
30
|
+
private resolveGroupAnchor;
|
|
31
|
+
private getGroupCenter;
|
|
32
|
+
scale(obj: SceneObject | GroupObject): TransformMethods;
|
|
33
|
+
scaleX(obj: SceneObject): TransformMethods;
|
|
34
|
+
scaleY(obj: SceneObject): TransformMethods;
|
|
35
|
+
width(obj: SceneObject): TransformMethods;
|
|
36
|
+
height(obj: SceneObject): TransformMethods;
|
|
37
|
+
resize(obj: SceneObject): ResizeMethods;
|
|
38
|
+
fit(obj: SceneObject): FitMethods;
|
|
39
|
+
private computeWorldBounds;
|
|
40
|
+
private computeGroupWorldBounds;
|
|
41
|
+
bbox(obj: SceneObject | GroupObject): BBoxHandle;
|
|
42
|
+
rotate(obj: SceneObject | GroupObject): TransformMethods;
|
|
43
|
+
pin(obj: SceneObject | GroupObject, anchor: Anchor): PinMethods;
|
|
44
|
+
opacity(obj: SceneObject | GroupObject): TransformMethods;
|
|
45
|
+
group(...objects: SceneObject[]): GroupBuilder;
|
|
46
|
+
private trackGroupDebug;
|
|
47
|
+
/** Flatten objects for final result (extracts all SceneObjects from groups) */
|
|
48
|
+
private flattenToSceneObjects;
|
|
49
|
+
/** Get bounds for an ObjRef (single object or group) */
|
|
50
|
+
private getObjRefBounds;
|
|
51
|
+
/** Get the top-left position of an ObjRef (bounds position, not pin position) */
|
|
52
|
+
private getObjRefPosition;
|
|
53
|
+
/** Move an ObjRef by a delta (moves all members of a group together, preserving pin anchors) */
|
|
54
|
+
private moveObjRef;
|
|
55
|
+
private alignOnCrossAxis;
|
|
56
|
+
private calculateLayoutPositions;
|
|
57
|
+
layout(...args: (ObjRef | LayoutOpts)[]): LayoutBuilder;
|
|
58
|
+
inline(...args: (ObjRef | number)[]): LayoutBuilder;
|
|
59
|
+
stack(...args: (ObjRef | number)[]): LayoutBuilder;
|
|
60
|
+
paragraph(...args: (ObjRef | number)[]): LayoutBuilder;
|
|
61
|
+
/** Parse layout args - last arg may be a gap number */
|
|
62
|
+
private parseLayoutArgs;
|
|
63
|
+
/** Get anchor offset within bounds */
|
|
64
|
+
private getAnchorOffsetFromRect;
|
|
65
|
+
/** Get anchor position in world space for an ObjRef */
|
|
66
|
+
private getObjRefAnchorPosition;
|
|
67
|
+
align(...args: (ObjRef | AlignOpts)[]): LayoutBuilder;
|
|
68
|
+
center(...objects: ObjRef[]): LayoutBuilder;
|
|
69
|
+
solve(scene: Scene): ResolvedCtx;
|
|
70
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Scene, TimelineAPI, Timeline, AnimCtx } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Function signature for defining an animation.
|
|
4
|
+
* Receives a Scene to add objects to, returns a function that builds the timeline.
|
|
5
|
+
*/
|
|
6
|
+
export type AnimationFn = (scene: Scene) => (t: TimelineAPI<AnimCtx>) => void;
|
|
7
|
+
/**
|
|
8
|
+
* The result of defineAnimation - contains the scene and timeline.
|
|
9
|
+
*/
|
|
10
|
+
export interface AnimationModule {
|
|
11
|
+
scene: Scene;
|
|
12
|
+
timeline: Timeline<AnimCtx>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Define an animation using a function-style API.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* import { defineAnimation, easeOut, Screen } from '@syma/anima';
|
|
20
|
+
*
|
|
21
|
+
* export default defineAnimation((scene) => {
|
|
22
|
+
* scene.bg('#fff');
|
|
23
|
+
* const title = scene.text('Hello', { size: 48 });
|
|
24
|
+
*
|
|
25
|
+
* return (t) => {
|
|
26
|
+
* t.tween(1000, easeOut, (ctx, u) => {
|
|
27
|
+
* ctx.pin(title, 'center').to(Screen.center(), u);
|
|
28
|
+
* });
|
|
29
|
+
* };
|
|
30
|
+
* });
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare function defineAnimation(fn: AnimationFn): AnimationModule;
|
|
34
|
+
/**
|
|
35
|
+
* Alias for defineAnimation
|
|
36
|
+
*/
|
|
37
|
+
export declare const createAnimation: typeof defineAnimation;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { EaseFn } from './types';
|
|
2
|
+
/** Linear - no easing */
|
|
3
|
+
export declare const linear: EaseFn;
|
|
4
|
+
/** Quadratic ease in - starts slow */
|
|
5
|
+
export declare const easeIn: EaseFn;
|
|
6
|
+
/** Quadratic ease out - ends slow */
|
|
7
|
+
export declare const easeOut: EaseFn;
|
|
8
|
+
/** Quadratic ease in-out - slow at both ends */
|
|
9
|
+
export declare const easeInOut: EaseFn;
|
|
10
|
+
/** Circular ease in - starts very slow, accelerates */
|
|
11
|
+
export declare const easeCirc: EaseFn;
|
|
12
|
+
/** Back ease in - slight overshoot backwards, then forward */
|
|
13
|
+
export declare const easeBack: EaseFn;
|
|
14
|
+
/** Bounce ease out - bounces at the end */
|
|
15
|
+
export declare const easeBounce: EaseFn;
|
|
16
|
+
/** Elastic ease out - springs past target then settles */
|
|
17
|
+
export declare const easeElastic: EaseFn;
|
|
18
|
+
/** Overshoot ease in-out - overshoots at both ends */
|
|
19
|
+
export declare const overShoot: EaseFn;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './types';
|
|
2
|
+
export * from './math';
|
|
3
|
+
export * from './easing';
|
|
4
|
+
export * from './scene';
|
|
5
|
+
export * from './timeline';
|
|
6
|
+
export * from './context';
|
|
7
|
+
export * from './player';
|
|
8
|
+
export * from './video-renderer';
|
|
9
|
+
export * from './define-animation';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Vec2 } from './types';
|
|
2
|
+
export declare const Screen: {
|
|
3
|
+
width: number;
|
|
4
|
+
height: number;
|
|
5
|
+
center: () => Vec2;
|
|
6
|
+
centerX: () => number;
|
|
7
|
+
centerY: () => number;
|
|
8
|
+
topLeft: () => Vec2;
|
|
9
|
+
topRight: () => Vec2;
|
|
10
|
+
bottomLeft: () => Vec2;
|
|
11
|
+
bottomRight: () => Vec2;
|
|
12
|
+
};
|
|
13
|
+
export declare const vec: {
|
|
14
|
+
add: ([x1, y1]: Vec2, [x2, y2]: Vec2) => Vec2;
|
|
15
|
+
sub: ([x1, y1]: Vec2, [x2, y2]: Vec2) => Vec2;
|
|
16
|
+
lerp: ([x1, y1]: Vec2, [x2, y2]: Vec2, u: number) => Vec2;
|
|
17
|
+
};
|
|
18
|
+
export declare const Vec: (x: number, y: number) => Vec2;
|
|
19
|
+
export declare const lerp: (a: number, b: number, u: number) => number;
|
|
20
|
+
export declare const angle: (deg: number) => number;
|
|
21
|
+
export declare function applySR([x, y]: Vec2, scale: number, rotate: number, // radians
|
|
22
|
+
scaleX?: number, scaleY?: number): Vec2;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { AnimCtx, Scene, Timeline } from './types';
|
|
2
|
+
export interface Player {
|
|
3
|
+
play(): void;
|
|
4
|
+
pause(): void;
|
|
5
|
+
stop(): void;
|
|
6
|
+
seek(timeMs: number): void;
|
|
7
|
+
renderAt(timeMs: number): void;
|
|
8
|
+
isPlaying: boolean;
|
|
9
|
+
currentTime: number;
|
|
10
|
+
duration: number;
|
|
11
|
+
debug: boolean;
|
|
12
|
+
onTimeUpdate: ((time: number) => void) | null;
|
|
13
|
+
onError: ((error: Error) => void) | null;
|
|
14
|
+
dispose(): void;
|
|
15
|
+
}
|
|
16
|
+
export interface PlayerOptions {
|
|
17
|
+
scene: Scene;
|
|
18
|
+
timeline: Timeline<AnimCtx>;
|
|
19
|
+
}
|
|
20
|
+
export declare function makePlayer(canvas: HTMLCanvasElement, opts: PlayerOptions): Player;
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
export type Vec2 = readonly [number, number];
|
|
2
|
+
/** Lazy expression that evaluates to Vec2 using resolved context */
|
|
3
|
+
export type Vec2Expr = Vec2 | ((ctx: ResolvedCtx) => Vec2);
|
|
4
|
+
/** Lazy expression that evaluates to Rect using resolved context */
|
|
5
|
+
export type RectExpr = Rect | ((ctx: ResolvedCtx) => Rect);
|
|
6
|
+
/** Lazy expression that evaluates to number using resolved context */
|
|
7
|
+
export type NumExpr = number | ((ctx: ResolvedCtx) => number);
|
|
8
|
+
/** Helper to check if value is an expression (function) */
|
|
9
|
+
export declare function isExpr<T>(v: T | ((ctx: ResolvedCtx) => T)): v is (ctx: ResolvedCtx) => T;
|
|
10
|
+
export type Anchor = "origin" | "topLeft" | "top" | "topRight" | "left" | "center" | "right" | "bottomLeft" | "bottom" | "bottomRight" | "baselineLeft" | "baseline";
|
|
11
|
+
export interface SceneObject {
|
|
12
|
+
readonly id: symbol;
|
|
13
|
+
}
|
|
14
|
+
export interface GroupObject extends SceneObject {
|
|
15
|
+
readonly members: SceneObject[];
|
|
16
|
+
readonly isGroup: true;
|
|
17
|
+
}
|
|
18
|
+
export type ObjRef = SceneObject | GroupObject;
|
|
19
|
+
export declare function isGroup(obj: SceneObject): obj is GroupObject;
|
|
20
|
+
export interface Transform {
|
|
21
|
+
translate: Vec2;
|
|
22
|
+
rotate: number;
|
|
23
|
+
scale: number;
|
|
24
|
+
scaleX?: number;
|
|
25
|
+
scaleY?: number;
|
|
26
|
+
}
|
|
27
|
+
export interface Rect {
|
|
28
|
+
x: number;
|
|
29
|
+
y: number;
|
|
30
|
+
w: number;
|
|
31
|
+
h: number;
|
|
32
|
+
}
|
|
33
|
+
export interface TextOpts {
|
|
34
|
+
at?: Vec2;
|
|
35
|
+
pin?: Anchor;
|
|
36
|
+
font?: string;
|
|
37
|
+
size?: number;
|
|
38
|
+
color?: string;
|
|
39
|
+
}
|
|
40
|
+
export interface ImageOpts {
|
|
41
|
+
at?: Vec2;
|
|
42
|
+
pin?: Anchor;
|
|
43
|
+
width?: number;
|
|
44
|
+
height?: number;
|
|
45
|
+
}
|
|
46
|
+
export interface RectOpts {
|
|
47
|
+
at?: Vec2;
|
|
48
|
+
pin?: Anchor;
|
|
49
|
+
width: number;
|
|
50
|
+
height: number;
|
|
51
|
+
fill?: string;
|
|
52
|
+
stroke?: string;
|
|
53
|
+
strokeWidth?: number;
|
|
54
|
+
cornerRadius?: number;
|
|
55
|
+
}
|
|
56
|
+
export interface ResolvedCtx {
|
|
57
|
+
getTransform(obj: SceneObject): Transform;
|
|
58
|
+
getOpacity(obj: SceneObject): number;
|
|
59
|
+
}
|
|
60
|
+
export type ImageSource = {
|
|
61
|
+
kind: "url";
|
|
62
|
+
src: string;
|
|
63
|
+
} | {
|
|
64
|
+
kind: "image";
|
|
65
|
+
image: HTMLImageElement;
|
|
66
|
+
} | {
|
|
67
|
+
kind: "bitmap";
|
|
68
|
+
bitmap: ImageBitmap;
|
|
69
|
+
} | {
|
|
70
|
+
kind: "canvas";
|
|
71
|
+
canvas: HTMLCanvasElement;
|
|
72
|
+
};
|
|
73
|
+
export interface Scene {
|
|
74
|
+
text(content: string, opts?: TextOpts): SceneObject;
|
|
75
|
+
rect(opts: RectOpts): SceneObject;
|
|
76
|
+
bg(color: string): SceneObject;
|
|
77
|
+
image(src: string | HTMLImageElement | ImageBitmap | HTMLCanvasElement | ImageSource, opts: ImageOpts): SceneObject;
|
|
78
|
+
objects(): Iterable<SceneObject>;
|
|
79
|
+
getBounds(obj: SceneObject): Rect;
|
|
80
|
+
getBaseline(obj: SceneObject): number | null;
|
|
81
|
+
resolveAnchor(obj: SceneObject, anchor: Anchor): Vec2;
|
|
82
|
+
getInitialTransform(obj: SceneObject): Transform;
|
|
83
|
+
render(ctx: ResolvedCtx, canvas: HTMLCanvasElement, dpr?: number): void;
|
|
84
|
+
}
|
|
85
|
+
export type EaseFn = (u: number) => number;
|
|
86
|
+
export type BodyFn<TCtx> = (ctx: TCtx, u: number) => void;
|
|
87
|
+
export type InstantBodyFn<TCtx> = (ctx: TCtx) => void;
|
|
88
|
+
export interface Segment<TCtx> {
|
|
89
|
+
start: number;
|
|
90
|
+
end: number;
|
|
91
|
+
ease: EaseFn;
|
|
92
|
+
body: BodyFn<TCtx>;
|
|
93
|
+
}
|
|
94
|
+
export interface TimelineAPI<TCtx> {
|
|
95
|
+
seq(fn: () => void): void;
|
|
96
|
+
mark(name: string): void;
|
|
97
|
+
tween(dur: number, ease: EaseFn | null | undefined, body: BodyFn<TCtx>): void;
|
|
98
|
+
instant(body: InstantBodyFn<TCtx>): void;
|
|
99
|
+
/** Wait/pause for a duration (sugar for tween with no-op body) */
|
|
100
|
+
wait(dur: number): void;
|
|
101
|
+
with(name: string, offsetMs: number, fn: () => void): void;
|
|
102
|
+
overlap(offsetMs: number, fn: () => void): void;
|
|
103
|
+
par(fn: () => void): void;
|
|
104
|
+
}
|
|
105
|
+
export interface Timeline<TCtx> {
|
|
106
|
+
duration: number;
|
|
107
|
+
segs: Segment<TCtx>[];
|
|
108
|
+
evaluate(tMs: number, ctx: TCtx): void;
|
|
109
|
+
}
|
|
110
|
+
export interface TransformMethods {
|
|
111
|
+
to(v: NumExpr, u: number): void;
|
|
112
|
+
by(delta: NumExpr, u: number): void;
|
|
113
|
+
}
|
|
114
|
+
/** Target for resize - can be a number (width-based uniform) or an object */
|
|
115
|
+
export type ResizeTarget = number | {
|
|
116
|
+
width: number;
|
|
117
|
+
} | {
|
|
118
|
+
height: number;
|
|
119
|
+
} | {
|
|
120
|
+
width: number;
|
|
121
|
+
height: number;
|
|
122
|
+
} | {
|
|
123
|
+
fit: number;
|
|
124
|
+
};
|
|
125
|
+
/** Resize target that supports expressions */
|
|
126
|
+
export type ResizeTargetExpr = NumExpr | {
|
|
127
|
+
width: NumExpr;
|
|
128
|
+
} | {
|
|
129
|
+
height: NumExpr;
|
|
130
|
+
} | {
|
|
131
|
+
width: NumExpr;
|
|
132
|
+
height: NumExpr;
|
|
133
|
+
} | {
|
|
134
|
+
fit: NumExpr;
|
|
135
|
+
};
|
|
136
|
+
/** Methods for pixel-based resizing */
|
|
137
|
+
export interface ResizeMethods {
|
|
138
|
+
to(target: ResizeTargetExpr, u: number): void;
|
|
139
|
+
by(delta: ResizeTargetExpr, u: number): void;
|
|
140
|
+
}
|
|
141
|
+
/** Options for toBBox */
|
|
142
|
+
export interface FitToBBoxOpts {
|
|
143
|
+
pad?: Padding;
|
|
144
|
+
}
|
|
145
|
+
/** Methods for fitting an object to a bounding box (resize + center pin) */
|
|
146
|
+
export interface FitMethods {
|
|
147
|
+
/** Fit to an existing BBoxHandle */
|
|
148
|
+
to(bbox: BBoxHandle, u: number): void;
|
|
149
|
+
/** Measure a group/object and fit to it */
|
|
150
|
+
toBBox(target: SceneObject | GroupObject, u: number, opts?: FitToBBoxOpts): void;
|
|
151
|
+
}
|
|
152
|
+
/** Padding specification - uniform number or per-side values */
|
|
153
|
+
export type Padding = number | {
|
|
154
|
+
top?: number;
|
|
155
|
+
right?: number;
|
|
156
|
+
bottom?: number;
|
|
157
|
+
left?: number;
|
|
158
|
+
};
|
|
159
|
+
/** Handle for measured bounding box - returns lazy expressions */
|
|
160
|
+
export interface BBoxHandle {
|
|
161
|
+
/** Add uniform or per-side padding */
|
|
162
|
+
pad(p: Padding): BBoxHandle;
|
|
163
|
+
/** Get size as [width, height] */
|
|
164
|
+
size(): Vec2Expr;
|
|
165
|
+
/** Get width in pixels */
|
|
166
|
+
width(): NumExpr;
|
|
167
|
+
/** Get height in pixels */
|
|
168
|
+
height(): NumExpr;
|
|
169
|
+
/** Get { width, height } for use with resize().to() */
|
|
170
|
+
whSize(): {
|
|
171
|
+
width: NumExpr;
|
|
172
|
+
height: NumExpr;
|
|
173
|
+
};
|
|
174
|
+
/** Get center point */
|
|
175
|
+
center(): Vec2Expr;
|
|
176
|
+
/** Get position of any anchor on the bbox */
|
|
177
|
+
anchor(a: Anchor): Vec2Expr;
|
|
178
|
+
/** Get the raw rect */
|
|
179
|
+
toRect(): RectExpr;
|
|
180
|
+
}
|
|
181
|
+
export interface PinMethods {
|
|
182
|
+
to(pos: Vec2Expr, u: number): void;
|
|
183
|
+
by(delta: Vec2Expr, u: number): void;
|
|
184
|
+
}
|
|
185
|
+
export interface GroupBuilder extends GroupObject {
|
|
186
|
+
pin(anchor: Anchor): PinMethods;
|
|
187
|
+
scale(): TransformMethods;
|
|
188
|
+
rotate(): TransformMethods;
|
|
189
|
+
opacity(): TransformMethods;
|
|
190
|
+
}
|
|
191
|
+
export interface LayoutOpts {
|
|
192
|
+
axis?: "x" | "y";
|
|
193
|
+
align?: Anchor;
|
|
194
|
+
gap?: number;
|
|
195
|
+
}
|
|
196
|
+
export interface AlignOpts {
|
|
197
|
+
anchor?: Anchor;
|
|
198
|
+
}
|
|
199
|
+
export interface LayoutBuilder {
|
|
200
|
+
to(u: number): GroupBuilder;
|
|
201
|
+
}
|
|
202
|
+
export interface AnimCtx {
|
|
203
|
+
pin(obj: SceneObject | GroupObject, anchor: Anchor): PinMethods;
|
|
204
|
+
scale(obj: SceneObject | GroupObject): TransformMethods;
|
|
205
|
+
scaleX(obj: SceneObject): TransformMethods;
|
|
206
|
+
scaleY(obj: SceneObject): TransformMethods;
|
|
207
|
+
rotate(obj: SceneObject | GroupObject): TransformMethods;
|
|
208
|
+
opacity(obj: SceneObject | GroupObject): TransformMethods;
|
|
209
|
+
/** Set width in pixels (converts to scaleX internally) */
|
|
210
|
+
width(obj: SceneObject): TransformMethods;
|
|
211
|
+
/** Set height in pixels (converts to scaleY internally) */
|
|
212
|
+
height(obj: SceneObject): TransformMethods;
|
|
213
|
+
/** Resize in pixels - uniform or non-uniform */
|
|
214
|
+
resize(obj: SceneObject): ResizeMethods;
|
|
215
|
+
/** Fit object to a bounding box (resize + center pin) */
|
|
216
|
+
fit(obj: SceneObject): FitMethods;
|
|
217
|
+
/** Measure the bounding box of an object or group */
|
|
218
|
+
bbox(obj: SceneObject | GroupObject): BBoxHandle;
|
|
219
|
+
group(...objects: SceneObject[]): GroupBuilder;
|
|
220
|
+
layout(...args: (ObjRef | LayoutOpts)[]): LayoutBuilder;
|
|
221
|
+
inline(...objects: ObjRef[]): LayoutBuilder;
|
|
222
|
+
stack(...objects: ObjRef[]): LayoutBuilder;
|
|
223
|
+
paragraph(...objects: ObjRef[]): LayoutBuilder;
|
|
224
|
+
align(...args: (ObjRef | AlignOpts)[]): LayoutBuilder;
|
|
225
|
+
center(...objects: ObjRef[]): LayoutBuilder;
|
|
226
|
+
}
|
|
227
|
+
export interface PinConstraint {
|
|
228
|
+
anchor: Anchor;
|
|
229
|
+
world: Vec2;
|
|
230
|
+
weight?: number;
|
|
231
|
+
priority?: number;
|
|
232
|
+
source?: string;
|
|
233
|
+
}
|
|
234
|
+
export interface ChannelState {
|
|
235
|
+
scale?: number;
|
|
236
|
+
scaleX?: number;
|
|
237
|
+
scaleY?: number;
|
|
238
|
+
rotate?: number;
|
|
239
|
+
opacity?: number;
|
|
240
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Scene, Timeline, AnimCtx } from './types';
|
|
2
|
+
export interface RenderOptions {
|
|
3
|
+
scene: Scene;
|
|
4
|
+
timeline: Timeline<AnimCtx>;
|
|
5
|
+
fps: number;
|
|
6
|
+
bitrate: number;
|
|
7
|
+
scale: number;
|
|
8
|
+
onProgress: (progress: number, frame: number, totalFrames: number) => void;
|
|
9
|
+
}
|
|
10
|
+
export interface RenderResult {
|
|
11
|
+
blob: Blob;
|
|
12
|
+
duration: number;
|
|
13
|
+
frames: number;
|
|
14
|
+
}
|
|
15
|
+
export interface RenderController {
|
|
16
|
+
start(): Promise<RenderResult>;
|
|
17
|
+
cancel(): void;
|
|
18
|
+
}
|
|
19
|
+
export declare function isWebCodecsSupported(): boolean;
|
|
20
|
+
export declare function createVideoRenderer(options: RenderOptions): RenderController;
|
|
21
|
+
export declare function downloadBlob(blob: Blob, filename: string): void;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type { Vec2, Vec2Expr, NumExpr, RectExpr, Anchor, SceneObject, GroupObject, ObjRef, Scene, Timeline, TimelineAPI, AnimCtx, EaseFn, Transform, Rect, TextOpts, RectOpts, ImageOpts, ImageSource, LayoutOpts, AlignOpts, Padding, PinMethods, TransformMethods, ResizeMethods, FitMethods, BBoxHandle, GroupBuilder, LayoutBuilder, ResolvedCtx, } from './core';
|
|
2
|
+
export { isGroup, isExpr } from './core';
|
|
3
|
+
export { makeScene } from './core';
|
|
4
|
+
export { timeline } from './core';
|
|
5
|
+
export { defineAnimation, createAnimation } from './core';
|
|
6
|
+
export type { AnimationFn, AnimationModule } from './core';
|
|
7
|
+
export { makePlayer } from './core';
|
|
8
|
+
export type { Player, PlayerOptions } from './core';
|
|
9
|
+
export { linear, easeIn, easeOut, easeInOut, easeCirc, easeBack, easeBounce, easeElastic, overShoot, } from './core';
|
|
10
|
+
export { Vec, vec, Screen, lerp, angle } from './core';
|
|
11
|
+
export { createVideoRenderer, isWebCodecsSupported, downloadBlob, } from './core';
|
|
12
|
+
export type { RenderOptions, RenderResult, RenderController } from './core';
|