@clypra-studio/engine 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/LICENSE +9 -0
- package/README.md +677 -0
- package/dist/chunk-5JOAEDIQ.js +446 -0
- package/dist/chunk-5JOAEDIQ.js.map +1 -0
- package/dist/chunk-CJRH4PAV.js +2826 -0
- package/dist/chunk-CJRH4PAV.js.map +1 -0
- package/dist/chunk-EVQAI3P3.js +3725 -0
- package/dist/chunk-EVQAI3P3.js.map +1 -0
- package/dist/chunk-PZ5AY32C.js +10 -0
- package/dist/chunk-PZ5AY32C.js.map +1 -0
- package/dist/chunk-QMRMNH52.js +811 -0
- package/dist/chunk-QMRMNH52.js.map +1 -0
- package/dist/index-BWo6qV_z.d.cts +139 -0
- package/dist/index-BWo6qV_z.d.ts +139 -0
- package/dist/index-lNWEWqab.d.cts +633 -0
- package/dist/index-lNWEWqab.d.ts +633 -0
- package/dist/index.cjs +21232 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +12254 -0
- package/dist/index.d.ts +12254 -0
- package/dist/index.js +13320 -0
- package/dist/index.js.map +1 -0
- package/dist/textEffects/index.cjs +3341 -0
- package/dist/textEffects/index.cjs.map +1 -0
- package/dist/textEffects/index.d.cts +1 -0
- package/dist/textEffects/index.d.ts +1 -0
- package/dist/textEffects/index.js +30 -0
- package/dist/textEffects/index.js.map +1 -0
- package/dist/transitions/index.cjs +848 -0
- package/dist/transitions/index.cjs.map +1 -0
- package/dist/transitions/index.d.cts +170 -0
- package/dist/transitions/index.d.ts +170 -0
- package/dist/transitions/index.js +32 -0
- package/dist/transitions/index.js.map +1 -0
- package/dist/v2/backends/index.cjs +480 -0
- package/dist/v2/backends/index.cjs.map +1 -0
- package/dist/v2/backends/index.d.cts +3 -0
- package/dist/v2/backends/index.d.ts +3 -0
- package/dist/v2/backends/index.js +8 -0
- package/dist/v2/backends/index.js.map +1 -0
- package/dist/v2/contract/index.cjs +18 -0
- package/dist/v2/contract/index.cjs.map +1 -0
- package/dist/v2/contract/index.d.cts +165 -0
- package/dist/v2/contract/index.d.ts +165 -0
- package/dist/v2/contract/index.js +1 -0
- package/dist/v2/contract/index.js.map +1 -0
- package/dist/videoEffects/index.cjs +2883 -0
- package/dist/videoEffects/index.cjs.map +1 -0
- package/dist/videoEffects/index.d.cts +801 -0
- package/dist/videoEffects/index.d.ts +801 -0
- package/dist/videoEffects/index.js +68 -0
- package/dist/videoEffects/index.js.map +1 -0
- package/package.json +119 -0
|
@@ -0,0 +1,801 @@
|
|
|
1
|
+
import { Filter, Application, Container, Ticker, Sprite } from 'pixi.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Video Effects Type System
|
|
5
|
+
*
|
|
6
|
+
* Distinguishes between:
|
|
7
|
+
* - Overlay Assets: Actual video files (smoke.mov, fire.mov)
|
|
8
|
+
* - Effect Presets: JSON behavior definitions (shake, blur)
|
|
9
|
+
*
|
|
10
|
+
* NOTE: Transitions have been moved to @clypra/engine/transitions
|
|
11
|
+
*/
|
|
12
|
+
type EffectCategory$1 = "overlay" | "effect" | "filter";
|
|
13
|
+
interface OverlayAsset {
|
|
14
|
+
id: string;
|
|
15
|
+
name: string;
|
|
16
|
+
type: "overlay";
|
|
17
|
+
category: string;
|
|
18
|
+
description: string;
|
|
19
|
+
thumbnail: string;
|
|
20
|
+
url: string;
|
|
21
|
+
duration: number;
|
|
22
|
+
width: number;
|
|
23
|
+
height: number;
|
|
24
|
+
hasAlpha: boolean;
|
|
25
|
+
fileFormat: "mov" | "webm" | "mp4" | "png-sequence";
|
|
26
|
+
fileSize: number;
|
|
27
|
+
tags: string[];
|
|
28
|
+
isPremium?: boolean;
|
|
29
|
+
blendMode?: BlendMode;
|
|
30
|
+
loopable: boolean;
|
|
31
|
+
recommended: {
|
|
32
|
+
opacity?: number;
|
|
33
|
+
blendMode?: BlendMode;
|
|
34
|
+
placement?: "fullscreen" | "overlay";
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
type EffectRenderer$1 = "shake" | "zoom" | "pan" | "rotate" | "dolly" | "blur" | "motion_blur" | "radial_blur" | "zoom_blur" | "motion-blur" | "gaussian-blur" | "kawase-blur" | "zoom-blur" | "radial-blur" | "drop-shadow" | "vhs" | "glitch" | "rgb_split" | "chromatic_aberration" | "film_grain" | "scanlines" | "crt" | "pixelate" | "rgb-split" | "film-grain" | "glitch-band" | "color-gradient" | "color-overlay" | "hsl-adjustment" | "alpha" | "color-matrix" | "color-adjustments" | "neon-glow" | "static-noise" | "old-film" | "displacement" | "outline" | "grayscale" | "dot" | "emboss" | "cross-hatch" | "ascii" | "wave" | "ripple" | "bulge" | "twist" | "fisheye" | "shockwave" | "bulge-pinch" | "reflection" | "flash" | "flicker" | "vignette" | "glow" | "light_leak" | "light_leak_2" | "fire" | "particles" | "dust_particles" | "light-leak" | "lens-flare" | "tilt-shift" | "cinematic-lut" | "speed_ramp" | "freeze_frame" | "echo" | "strobe" | "body-segmentation-glow" | "body_glow" | "body_outline" | "body_particles";
|
|
38
|
+
interface EffectPreset {
|
|
39
|
+
id: string;
|
|
40
|
+
name: string;
|
|
41
|
+
type: "effect" | "video-effect" | "body-effect";
|
|
42
|
+
category: string;
|
|
43
|
+
description: string;
|
|
44
|
+
thumbnail: string;
|
|
45
|
+
renderer: EffectRenderer$1;
|
|
46
|
+
params: EffectParameters;
|
|
47
|
+
tags: string[];
|
|
48
|
+
isPremium?: boolean;
|
|
49
|
+
intensity: {
|
|
50
|
+
min: number;
|
|
51
|
+
max: number;
|
|
52
|
+
default: number;
|
|
53
|
+
step: number;
|
|
54
|
+
};
|
|
55
|
+
requirements?: {
|
|
56
|
+
bodySegmentation?: boolean;
|
|
57
|
+
minConfidence?: number;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
type BlendMode = "normal" | "multiply" | "screen" | "overlay" | "darken" | "lighten" | "color-dodge" | "color-burn" | "hard-light" | "soft-light" | "difference" | "exclusion" | "add" | "subtract";
|
|
61
|
+
type EasingFunction = "linear" | "ease" | "ease-in" | "ease-out" | "ease-in-out" | "ease-in-quad" | "ease-out-quad" | "ease-in-out-quad" | "ease-in-cubic" | "ease-out-cubic" | "ease-in-out-cubic" | "ease-in-quart" | "ease-out-quart" | "ease-in-out-quart" | "spring" | "bounce";
|
|
62
|
+
interface EffectParameters {
|
|
63
|
+
intensity?: number;
|
|
64
|
+
frequency?: number;
|
|
65
|
+
blurAmount?: number;
|
|
66
|
+
direction?: number;
|
|
67
|
+
glitchIntensity?: number;
|
|
68
|
+
scanlineCount?: number;
|
|
69
|
+
noiseAmount?: number;
|
|
70
|
+
colorOffset?: number;
|
|
71
|
+
splitDistance?: number;
|
|
72
|
+
angle?: number;
|
|
73
|
+
startSpeed?: number;
|
|
74
|
+
endSpeed?: number;
|
|
75
|
+
curve?: EasingFunction;
|
|
76
|
+
scale?: number;
|
|
77
|
+
centerX?: number;
|
|
78
|
+
centerY?: number;
|
|
79
|
+
flashColor?: string;
|
|
80
|
+
flashIntensity?: number;
|
|
81
|
+
grainSize?: number;
|
|
82
|
+
grainIntensity?: number;
|
|
83
|
+
duration?: number;
|
|
84
|
+
size?: number;
|
|
85
|
+
color1?: string;
|
|
86
|
+
color2?: string;
|
|
87
|
+
color3?: string;
|
|
88
|
+
[key: string]: any;
|
|
89
|
+
}
|
|
90
|
+
interface FilterAsset {
|
|
91
|
+
id: string;
|
|
92
|
+
name: string;
|
|
93
|
+
type: "filter";
|
|
94
|
+
category: string;
|
|
95
|
+
description: string;
|
|
96
|
+
thumbnail: string;
|
|
97
|
+
swatch?: string;
|
|
98
|
+
status?: string;
|
|
99
|
+
intensity: {
|
|
100
|
+
min: number;
|
|
101
|
+
max: number;
|
|
102
|
+
default: number;
|
|
103
|
+
step: number;
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
type VideoEffectItem = OverlayAsset | EffectPreset | FilterAsset;
|
|
107
|
+
interface VideoEffectCategory {
|
|
108
|
+
id: string;
|
|
109
|
+
name: string;
|
|
110
|
+
type: EffectCategory$1;
|
|
111
|
+
description: string;
|
|
112
|
+
thumbnail: string;
|
|
113
|
+
itemCount: number;
|
|
114
|
+
}
|
|
115
|
+
interface VideoEffectManifest {
|
|
116
|
+
categories: VideoEffectCategory[];
|
|
117
|
+
featured: VideoEffectItem[];
|
|
118
|
+
version: string;
|
|
119
|
+
}
|
|
120
|
+
interface AppliedOverlay {
|
|
121
|
+
id: string;
|
|
122
|
+
effectId: string;
|
|
123
|
+
type: "overlay";
|
|
124
|
+
url: string;
|
|
125
|
+
x: number;
|
|
126
|
+
y: number;
|
|
127
|
+
width: number;
|
|
128
|
+
height: number;
|
|
129
|
+
rotation: number;
|
|
130
|
+
opacity: number;
|
|
131
|
+
blendMode: BlendMode;
|
|
132
|
+
startTime: number;
|
|
133
|
+
duration: number;
|
|
134
|
+
loop: boolean;
|
|
135
|
+
}
|
|
136
|
+
interface AppliedEffect {
|
|
137
|
+
id: string;
|
|
138
|
+
effectId: string;
|
|
139
|
+
type: "effect";
|
|
140
|
+
renderer: EffectRenderer$1;
|
|
141
|
+
params: EffectParameters;
|
|
142
|
+
startTime: number;
|
|
143
|
+
duration: number;
|
|
144
|
+
intensity: number;
|
|
145
|
+
keyframes?: Array<{
|
|
146
|
+
time: number;
|
|
147
|
+
intensity: number;
|
|
148
|
+
easing: EasingFunction;
|
|
149
|
+
}>;
|
|
150
|
+
}
|
|
151
|
+
interface VideoEffectState {
|
|
152
|
+
manifest: VideoEffectManifest | null;
|
|
153
|
+
categories: Record<string, VideoEffectItem[]>;
|
|
154
|
+
loading: Record<string, boolean>;
|
|
155
|
+
errors: Record<string, string | null>;
|
|
156
|
+
overlayCache: Map<string, Blob>;
|
|
157
|
+
favorites: Set<string>;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Effect Renderer
|
|
162
|
+
*
|
|
163
|
+
* Applies behavior-driven effects to canvas contexts.
|
|
164
|
+
* These are NOT video files - they are algorithmic transformations.
|
|
165
|
+
*/
|
|
166
|
+
|
|
167
|
+
declare class EffectRenderer {
|
|
168
|
+
/**
|
|
169
|
+
* Apply an effect to a canvas context
|
|
170
|
+
*
|
|
171
|
+
* @param ctx - Canvas 2D context
|
|
172
|
+
* @param renderer - Effect type
|
|
173
|
+
* @param params - Effect parameters
|
|
174
|
+
* @param intensity - Effect intensity (0-1)
|
|
175
|
+
* @param time - Current time for animated effects
|
|
176
|
+
*/
|
|
177
|
+
static apply(ctx: CanvasRenderingContext2D, renderer: EffectRenderer$1, params: EffectParameters, intensity?: number, time?: number, bodyMask?: ImageData): void;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* @clypra/engine — EffectDefinition
|
|
182
|
+
*
|
|
183
|
+
* Unified type system for all Clypra video effects.
|
|
184
|
+
* Supports two rendering backends:
|
|
185
|
+
* - 'canvas2d' → existing text/overlay effects (EffectEngine class pattern)
|
|
186
|
+
* - 'pixi' → new GPU-accelerated video/motion/filter effects (PixiJS)
|
|
187
|
+
*
|
|
188
|
+
* Both backends are consumed identically by EffectGraph and EffectRenderer.
|
|
189
|
+
* The Studio and Desktop Editor import from this single package — same code, same output.
|
|
190
|
+
*/
|
|
191
|
+
|
|
192
|
+
type ParamType = 'range' | 'color' | 'toggle' | 'select' | 'text';
|
|
193
|
+
interface ParamSchema {
|
|
194
|
+
key: string;
|
|
195
|
+
label: string;
|
|
196
|
+
type: ParamType;
|
|
197
|
+
value: number | string | boolean;
|
|
198
|
+
min?: number;
|
|
199
|
+
max?: number;
|
|
200
|
+
step?: number;
|
|
201
|
+
options?: string[];
|
|
202
|
+
}
|
|
203
|
+
type ParamValues = Record<string, number | string | boolean>;
|
|
204
|
+
type EffectCategory = 'light' | 'glitch' | 'cinematic' | 'neon' | 'retro' | 'motion' | 'color' | 'blur' | 'distortion' | 'particle' | 'custom';
|
|
205
|
+
interface Canvas2DEngine {
|
|
206
|
+
/** Advance internal animation state by N steps */
|
|
207
|
+
advanceSteps(steps: number): void;
|
|
208
|
+
/** Draw one frame onto the provided context */
|
|
209
|
+
drawFrame(ctx: CanvasRenderingContext2D, ghostFrames?: ImageData[]): void;
|
|
210
|
+
}
|
|
211
|
+
type Canvas2DEngineConstructor = new (config: ParamValues) => Canvas2DEngine;
|
|
212
|
+
interface Canvas2DEffectDefinition {
|
|
213
|
+
backend: 'canvas2d';
|
|
214
|
+
id: string;
|
|
215
|
+
name: string;
|
|
216
|
+
category: EffectCategory;
|
|
217
|
+
description: string;
|
|
218
|
+
tags: string[];
|
|
219
|
+
thumbnail?: string;
|
|
220
|
+
/** Static param schema — parsed by Studio to build sliders */
|
|
221
|
+
params: ParamSchema[];
|
|
222
|
+
/** The engine class that renders this effect */
|
|
223
|
+
engineClass: Canvas2DEngineConstructor;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* PixiJS effect subtypes:
|
|
227
|
+
*
|
|
228
|
+
* 'filter' — one or more GLSL shaders applied as a filter chain on a sprite/container.
|
|
229
|
+
* Pure GPU, no per-frame JS. Uniform values are updated from param changes.
|
|
230
|
+
*
|
|
231
|
+
* 'motion' — animated overlay managed via PixiJS Ticker. Particles, sweeps, pulses.
|
|
232
|
+
* Has full scene-graph access (can add/remove children).
|
|
233
|
+
*
|
|
234
|
+
* 'composite' — combines filter + motion in one effect (e.g. neon glow + particle burst).
|
|
235
|
+
*/
|
|
236
|
+
type PixiEffectSubtype = 'filter' | 'motion' | 'composite';
|
|
237
|
+
/** Context passed to every PixiJS effect lifecycle method */
|
|
238
|
+
interface PixiEffectContext {
|
|
239
|
+
/** The PixiJS Application instance (shared, do not destroy) */
|
|
240
|
+
app: Application;
|
|
241
|
+
/** The container to attach overlays or receive filters */
|
|
242
|
+
container: Container;
|
|
243
|
+
/** PixiJS ticker — subscribe for per-frame updates */
|
|
244
|
+
ticker: Ticker;
|
|
245
|
+
/** Current param values (updated when user moves a slider) */
|
|
246
|
+
params: ParamValues;
|
|
247
|
+
/** Canvas dimensions */
|
|
248
|
+
width: number;
|
|
249
|
+
height: number;
|
|
250
|
+
}
|
|
251
|
+
/** A single PixiJS Filter definition (for 'filter' and 'composite' subtypes) */
|
|
252
|
+
interface PixiFilterSpec {
|
|
253
|
+
/**
|
|
254
|
+
* Factory that returns a configured PixiJS Filter.
|
|
255
|
+
* Called once on mount, and again when params change significantly.
|
|
256
|
+
* Import Filter types lazily inside the factory to keep the engine tree-shakeable.
|
|
257
|
+
*/
|
|
258
|
+
create: (params: ParamValues) => Filter | Filter[];
|
|
259
|
+
/**
|
|
260
|
+
* Called every frame (if the filter has animated uniforms).
|
|
261
|
+
* Mutate filter.resources / uniforms here instead of re-creating the filter.
|
|
262
|
+
* Return false to skip uniform update this frame (for static filters).
|
|
263
|
+
*/
|
|
264
|
+
updateUniforms?: (filter: Filter | Filter[], params: ParamValues, elapsed: number) => void;
|
|
265
|
+
}
|
|
266
|
+
interface PixiEffectDefinition {
|
|
267
|
+
backend: 'pixi';
|
|
268
|
+
subtype: PixiEffectSubtype;
|
|
269
|
+
id: string;
|
|
270
|
+
name: string;
|
|
271
|
+
category: EffectCategory;
|
|
272
|
+
description: string;
|
|
273
|
+
tags: string[];
|
|
274
|
+
thumbnail?: string;
|
|
275
|
+
/** Static param schema — same shape as Canvas2D, drives Studio sliders */
|
|
276
|
+
params: ParamSchema[];
|
|
277
|
+
/**
|
|
278
|
+
* Filter spec — required for 'filter' and 'composite' subtypes.
|
|
279
|
+
* For 'motion' only, omit this.
|
|
280
|
+
*/
|
|
281
|
+
filterSpec?: PixiFilterSpec;
|
|
282
|
+
/**
|
|
283
|
+
* Lifecycle hooks for motion and composite subtypes.
|
|
284
|
+
* mount → called once when effect is activated (add sprites, subscribe ticker)
|
|
285
|
+
* unmount → called when effect is removed (clean up ALL resources — critical)
|
|
286
|
+
* update → called when param values change (slider moved)
|
|
287
|
+
*/
|
|
288
|
+
mount?: (ctx: PixiEffectContext) => void;
|
|
289
|
+
unmount?: (ctx: PixiEffectContext) => void;
|
|
290
|
+
onParamChange?: (ctx: PixiEffectContext, key: string, value: ParamValues[string]) => void;
|
|
291
|
+
}
|
|
292
|
+
type EffectDefinition = Canvas2DEffectDefinition | PixiEffectDefinition;
|
|
293
|
+
declare function isCanvas2DEffect(e: EffectDefinition): e is Canvas2DEffectDefinition;
|
|
294
|
+
declare function isPixiEffect(e: EffectDefinition): e is PixiEffectDefinition;
|
|
295
|
+
declare function isFilterEffect(e: EffectDefinition): e is PixiEffectDefinition & {
|
|
296
|
+
subtype: 'filter';
|
|
297
|
+
};
|
|
298
|
+
declare function isMotionEffect(e: EffectDefinition): e is PixiEffectDefinition & {
|
|
299
|
+
subtype: 'motion';
|
|
300
|
+
};
|
|
301
|
+
declare function isCompositeEffect(e: EffectDefinition): e is PixiEffectDefinition & {
|
|
302
|
+
subtype: 'composite';
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* @clypra/engine — EffectGraph
|
|
307
|
+
*
|
|
308
|
+
* Directed Acyclic Graph evaluator for effect chains.
|
|
309
|
+
* Uses Kahn's algorithm for topological ordering.
|
|
310
|
+
* Supports both Canvas2D and PixiJS effect nodes transparently.
|
|
311
|
+
*
|
|
312
|
+
* Unchanged public API from v1 — new PixiJS nodes slot in automatically.
|
|
313
|
+
*/
|
|
314
|
+
|
|
315
|
+
interface KeyframePoint {
|
|
316
|
+
time: number;
|
|
317
|
+
value: number | string | number[];
|
|
318
|
+
easing: EasingFunction;
|
|
319
|
+
}
|
|
320
|
+
interface GraphNode {
|
|
321
|
+
id: string;
|
|
322
|
+
effect?: EffectDefinition;
|
|
323
|
+
type?: string;
|
|
324
|
+
params?: Record<string, any>;
|
|
325
|
+
keyframes?: Record<string, KeyframePoint[]>;
|
|
326
|
+
/** IDs of nodes this node depends on (must render before this one) */
|
|
327
|
+
dependencies?: string[];
|
|
328
|
+
}
|
|
329
|
+
interface GraphEdge {
|
|
330
|
+
from: string;
|
|
331
|
+
to: string;
|
|
332
|
+
}
|
|
333
|
+
interface GraphConnection {
|
|
334
|
+
fromNode: string;
|
|
335
|
+
fromOutput: string;
|
|
336
|
+
toNode: string;
|
|
337
|
+
toInput: string;
|
|
338
|
+
}
|
|
339
|
+
interface GraphDefinition {
|
|
340
|
+
schemaVersion: string;
|
|
341
|
+
graphId: string;
|
|
342
|
+
name: string;
|
|
343
|
+
nodes: GraphNode[];
|
|
344
|
+
connections: GraphConnection[];
|
|
345
|
+
}
|
|
346
|
+
declare class EffectGraph {
|
|
347
|
+
schemaVersion?: string;
|
|
348
|
+
graphId?: string;
|
|
349
|
+
name?: string;
|
|
350
|
+
nodes: Map<string, GraphNode>;
|
|
351
|
+
edges: GraphEdge[];
|
|
352
|
+
connections: GraphConnection[];
|
|
353
|
+
constructor(definition?: GraphDefinition);
|
|
354
|
+
addNode(node: GraphNode): this;
|
|
355
|
+
addEdge(from: string, to: string): this;
|
|
356
|
+
removeNode(id: string): this;
|
|
357
|
+
/**
|
|
358
|
+
* Topological sort via Kahn's algorithm.
|
|
359
|
+
* Returns nodes in render order or throws on circular dependency.
|
|
360
|
+
*/
|
|
361
|
+
resolve(): GraphNode[];
|
|
362
|
+
getExecutionOrder(): string[];
|
|
363
|
+
getUpstreamNodes(nodeId: string): string[];
|
|
364
|
+
/**
|
|
365
|
+
* Returns only the PixiJS nodes in resolved order.
|
|
366
|
+
* Used by EffectRenderer to build the PixiJS filter + motion pipeline.
|
|
367
|
+
*/
|
|
368
|
+
resolvePixi(): GraphNode[];
|
|
369
|
+
/**
|
|
370
|
+
* Returns only the Canvas2D nodes in resolved order.
|
|
371
|
+
* Used by EffectRenderer for text effect overlays.
|
|
372
|
+
*/
|
|
373
|
+
resolveCanvas2D(): GraphNode[];
|
|
374
|
+
get size(): number;
|
|
375
|
+
clear(): this;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* Effect Runtime Engine
|
|
380
|
+
*
|
|
381
|
+
* Manages the lifecycle of active effect graphs,
|
|
382
|
+
* interpolates keyframe parameters, and coordinates rendering passes.
|
|
383
|
+
*/
|
|
384
|
+
|
|
385
|
+
declare class EffectEngine {
|
|
386
|
+
private activeGraph;
|
|
387
|
+
private canvasPool;
|
|
388
|
+
constructor();
|
|
389
|
+
/**
|
|
390
|
+
* Set the active effect graph to execute
|
|
391
|
+
*/
|
|
392
|
+
loadGraph(graph: EffectGraph): void;
|
|
393
|
+
/**
|
|
394
|
+
* Clear active graph and associated canvases
|
|
395
|
+
*/
|
|
396
|
+
unloadGraph(): void;
|
|
397
|
+
/**
|
|
398
|
+
* Evaluate node parameters at specific timestamp `t`
|
|
399
|
+
*/
|
|
400
|
+
evaluateParameters(node: GraphNode, time: number): Record<string, any>;
|
|
401
|
+
/**
|
|
402
|
+
* Render the active graph onto a Canvas 2D Context
|
|
403
|
+
*
|
|
404
|
+
* @param ctx Target canvas context
|
|
405
|
+
* @param time Timestamp relative to effect start
|
|
406
|
+
* @param sourceTexture Optional raw image source
|
|
407
|
+
*/
|
|
408
|
+
render(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, time: number, sourceTexture?: CanvasImageSource): void;
|
|
409
|
+
/**
|
|
410
|
+
* Interpolate values (numbers or colors)
|
|
411
|
+
*/
|
|
412
|
+
private interpolate;
|
|
413
|
+
/**
|
|
414
|
+
* Easing curves mapping
|
|
415
|
+
*/
|
|
416
|
+
private applyEasing;
|
|
417
|
+
/**
|
|
418
|
+
* Acquire Offscreen Canvas context from reuse pool
|
|
419
|
+
*/
|
|
420
|
+
private acquireCanvas;
|
|
421
|
+
private clearPool;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* Effects Registry
|
|
426
|
+
* Central registry for all available video effects
|
|
427
|
+
*/
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* Effect metadata for UI and documentation
|
|
431
|
+
*/
|
|
432
|
+
interface EffectMetadata {
|
|
433
|
+
id: EffectRenderer$1;
|
|
434
|
+
name: string;
|
|
435
|
+
category: "essentials" | "glitch" | "retro" | "light" | "motion" | "color" | "body" | "cinematic" | "distortion";
|
|
436
|
+
description: string;
|
|
437
|
+
defaultParams: EffectParameters;
|
|
438
|
+
parameterSchema: {
|
|
439
|
+
[key: string]: {
|
|
440
|
+
type: "number" | "string" | "boolean" | "color";
|
|
441
|
+
label: string;
|
|
442
|
+
min?: number;
|
|
443
|
+
max?: number;
|
|
444
|
+
default: any;
|
|
445
|
+
step?: number;
|
|
446
|
+
};
|
|
447
|
+
};
|
|
448
|
+
tags: string[];
|
|
449
|
+
premium?: boolean;
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Registry of all available effects with their metadata
|
|
453
|
+
*/
|
|
454
|
+
declare const EFFECTS_REGISTRY: Record<string, EffectMetadata>;
|
|
455
|
+
/**
|
|
456
|
+
* Get effect metadata by ID
|
|
457
|
+
*/
|
|
458
|
+
declare function getEffectMetadata(id: EffectRenderer$1): EffectMetadata | undefined;
|
|
459
|
+
/**
|
|
460
|
+
* Get all effects by category
|
|
461
|
+
*/
|
|
462
|
+
declare function getEffectsByCategory(category: EffectMetadata["category"]): EffectMetadata[];
|
|
463
|
+
/**
|
|
464
|
+
* Get effect renderer function by ID
|
|
465
|
+
*/
|
|
466
|
+
declare function getEffectRenderer(id: EffectRenderer$1): ((ctx: CanvasRenderingContext2D, params: EffectParameters, intensity: number, time: number, bodyMask?: ImageData) => void) | null;
|
|
467
|
+
/**
|
|
468
|
+
* Search effects by name or tag
|
|
469
|
+
*/
|
|
470
|
+
declare function searchEffects(query: string): EffectMetadata[];
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* Color Utility Functions
|
|
474
|
+
*/
|
|
475
|
+
/**
|
|
476
|
+
* Convert hex color to rgba string
|
|
477
|
+
*/
|
|
478
|
+
declare function hexToRgba(hex: string, alpha: number): string;
|
|
479
|
+
/**
|
|
480
|
+
* Convert rgba string to individual components
|
|
481
|
+
*/
|
|
482
|
+
declare function rgbaToComponents(rgba: string): {
|
|
483
|
+
r: number;
|
|
484
|
+
g: number;
|
|
485
|
+
b: number;
|
|
486
|
+
a: number;
|
|
487
|
+
};
|
|
488
|
+
/**
|
|
489
|
+
* Blend two colors together
|
|
490
|
+
*/
|
|
491
|
+
declare function blendColors(color1: string, color2: string, ratio: number): string;
|
|
492
|
+
|
|
493
|
+
/**
|
|
494
|
+
* Canvas Utility Functions
|
|
495
|
+
*/
|
|
496
|
+
/**
|
|
497
|
+
* Add noise to canvas
|
|
498
|
+
*/
|
|
499
|
+
declare function addNoise(ctx: CanvasRenderingContext2D, amount: number): void;
|
|
500
|
+
/**
|
|
501
|
+
* Clear canvas with optional color
|
|
502
|
+
*/
|
|
503
|
+
declare function clearCanvas(ctx: CanvasRenderingContext2D, color?: string): void;
|
|
504
|
+
/**
|
|
505
|
+
* Save and restore canvas context for isolated transforms
|
|
506
|
+
*/
|
|
507
|
+
declare function withContext<T>(ctx: CanvasRenderingContext2D, fn: (ctx: CanvasRenderingContext2D) => T): T;
|
|
508
|
+
|
|
509
|
+
/**
|
|
510
|
+
* Video Effects API Integration
|
|
511
|
+
*
|
|
512
|
+
* Provides metadata about effects for the API to consume
|
|
513
|
+
*/
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* API-compatible effect definition
|
|
517
|
+
*/
|
|
518
|
+
interface VideoEffectApiDefinition {
|
|
519
|
+
id: string;
|
|
520
|
+
name: string;
|
|
521
|
+
type: "effect" | "video-effect";
|
|
522
|
+
category: "essentials" | "glitch" | "retro" | "light" | "motion" | "color" | "body" | "cinematic" | "distortion";
|
|
523
|
+
description: string;
|
|
524
|
+
thumbnail: string;
|
|
525
|
+
renderer: EffectRenderer$1;
|
|
526
|
+
params: EffectParameters;
|
|
527
|
+
parameterSchema: EffectMetadata["parameterSchema"];
|
|
528
|
+
tags: string[];
|
|
529
|
+
isPremium?: boolean;
|
|
530
|
+
intensity: {
|
|
531
|
+
min: number;
|
|
532
|
+
max: number;
|
|
533
|
+
default: number;
|
|
534
|
+
step: number;
|
|
535
|
+
};
|
|
536
|
+
previewUrl?: string;
|
|
537
|
+
previewDuration?: number;
|
|
538
|
+
thumbnailUrl?: string;
|
|
539
|
+
}
|
|
540
|
+
/**
|
|
541
|
+
* Get effect preview URL
|
|
542
|
+
*/
|
|
543
|
+
declare function getEffectPreviewUrl(effectId: string, category: string): string;
|
|
544
|
+
/**
|
|
545
|
+
* Convert effect metadata to API format with preview URL
|
|
546
|
+
*/
|
|
547
|
+
declare function effectMetadataToApi(metadata: EffectMetadata): VideoEffectApiDefinition;
|
|
548
|
+
/**
|
|
549
|
+
* Get all effects in API format
|
|
550
|
+
*/
|
|
551
|
+
declare function getAllEffectsForApi(): VideoEffectApiDefinition[];
|
|
552
|
+
/**
|
|
553
|
+
* Get effects by category in API format
|
|
554
|
+
*/
|
|
555
|
+
declare function getEffectsByCategoryForApi(category: EffectMetadata["category"]): VideoEffectApiDefinition[];
|
|
556
|
+
/**
|
|
557
|
+
* Search effects in API format
|
|
558
|
+
*/
|
|
559
|
+
declare function searchEffectsForApi(query: string): VideoEffectApiDefinition[];
|
|
560
|
+
/**
|
|
561
|
+
* Get effect by ID in API format
|
|
562
|
+
*/
|
|
563
|
+
declare function getEffectByIdForApi(id: string): VideoEffectApiDefinition | null;
|
|
564
|
+
/**
|
|
565
|
+
* Get effect categories summary
|
|
566
|
+
*/
|
|
567
|
+
declare function getEffectCategoriesSummary(): Array<{
|
|
568
|
+
id: string;
|
|
569
|
+
name: string;
|
|
570
|
+
count: number;
|
|
571
|
+
description: string;
|
|
572
|
+
}>;
|
|
573
|
+
/**
|
|
574
|
+
* Generate manifest for all effects
|
|
575
|
+
*/
|
|
576
|
+
declare function generateEffectsManifest(): {
|
|
577
|
+
version: string;
|
|
578
|
+
totalCount: number;
|
|
579
|
+
categories: Array<{
|
|
580
|
+
id: string;
|
|
581
|
+
name: string;
|
|
582
|
+
count: number;
|
|
583
|
+
description: string;
|
|
584
|
+
}>;
|
|
585
|
+
effects: VideoEffectApiDefinition[];
|
|
586
|
+
};
|
|
587
|
+
|
|
588
|
+
/**
|
|
589
|
+
* @clypra/engine — PixiRenderer
|
|
590
|
+
*
|
|
591
|
+
* Manages a single shared PixiJS Application instance.
|
|
592
|
+
* Handles three effect subtypes:
|
|
593
|
+
* - filter → builds filter chain on videoSprite, updates uniforms per frame
|
|
594
|
+
* - motion → calls mount/unmount lifecycle, hooks into Ticker
|
|
595
|
+
* - composite → does both
|
|
596
|
+
*
|
|
597
|
+
* Used by:
|
|
598
|
+
* - Clypra Studio (VideoEffectWorkspace preview canvas)
|
|
599
|
+
* - Clypra Desktop (rasterizer.ts frame compositor)
|
|
600
|
+
*
|
|
601
|
+
* Both environments receive the same canvas output — PixiJS renders into it,
|
|
602
|
+
* then the Desktop rasterizer reads the pixels for FFmpeg.
|
|
603
|
+
*/
|
|
604
|
+
|
|
605
|
+
declare class PixiRenderer {
|
|
606
|
+
private app;
|
|
607
|
+
private videoSprite;
|
|
608
|
+
private overlayContainer;
|
|
609
|
+
private mounted;
|
|
610
|
+
private initialized;
|
|
611
|
+
/**
|
|
612
|
+
* Initialize the PixiJS Application.
|
|
613
|
+
* Call once, reuse across effect changes.
|
|
614
|
+
*
|
|
615
|
+
* @param canvas The target HTMLCanvasElement (Studio preview or rasterizer offscreen canvas)
|
|
616
|
+
* @param width Canvas width in pixels
|
|
617
|
+
* @param height Canvas height in pixels
|
|
618
|
+
*/
|
|
619
|
+
init(canvas: HTMLCanvasElement, width: number, height: number): Promise<void>;
|
|
620
|
+
/**
|
|
621
|
+
* Point the video sprite at a live HTMLVideoElement.
|
|
622
|
+
* PixiJS polls the video element each frame automatically.
|
|
623
|
+
*/
|
|
624
|
+
setVideoSource(video: HTMLVideoElement): void;
|
|
625
|
+
setImageSource(image: HTMLImageElement): void;
|
|
626
|
+
/**
|
|
627
|
+
* Mount a resolved set of PixiJS graph nodes.
|
|
628
|
+
* Builds filter chains and initialises motion effects.
|
|
629
|
+
* Previously mounted effects NOT in the new list are unmounted.
|
|
630
|
+
*/
|
|
631
|
+
applyNodes(nodes: GraphNode[], globalParams?: Map<string, ParamValues>): void;
|
|
632
|
+
/**
|
|
633
|
+
* Update multiple params on a mounted effect in one pass.
|
|
634
|
+
*/
|
|
635
|
+
updateParams(nodeId: string, params: ParamValues): void;
|
|
636
|
+
/**
|
|
637
|
+
* Force a render pass (required for static image previews after uniform changes).
|
|
638
|
+
*/
|
|
639
|
+
render(): void;
|
|
640
|
+
/**
|
|
641
|
+
* Update a single param on a mounted effect.
|
|
642
|
+
* Triggers uniform refresh and calls onParamChange lifecycle hook.
|
|
643
|
+
*/
|
|
644
|
+
updateParam(nodeId: string, key: string, value: number | string | boolean): void;
|
|
645
|
+
/**
|
|
646
|
+
* Capture the current rendered frame as an ImageData.
|
|
647
|
+
* Used by the Desktop rasterizer to extract pixels for FFmpeg.
|
|
648
|
+
*/
|
|
649
|
+
captureFrame(): ImageData | null;
|
|
650
|
+
/**
|
|
651
|
+
* Resize the renderer (e.g. when project resolution changes).
|
|
652
|
+
*/
|
|
653
|
+
resize(width: number, height: number): void;
|
|
654
|
+
/**
|
|
655
|
+
* Full teardown — unmounts all effects, destroys the PixiJS Application.
|
|
656
|
+
* Call when the editor session ends or the Studio workspace unmounts.
|
|
657
|
+
*/
|
|
658
|
+
destroy(): void;
|
|
659
|
+
private _unmount;
|
|
660
|
+
private _defaultParams;
|
|
661
|
+
getApp(): Application | null;
|
|
662
|
+
getVideoSprite(): Sprite | null;
|
|
663
|
+
get isReady(): boolean;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
/**
|
|
667
|
+
* @clypra/engine — example effects
|
|
668
|
+
*
|
|
669
|
+
* Three fully-worked examples covering every PixiJS subtype.
|
|
670
|
+
* Copy these as templates when authoring new effects.
|
|
671
|
+
*
|
|
672
|
+
* 1. NeonGlowEffect — 'filter' — GPU shader, no ticker needed
|
|
673
|
+
* 2. ParticleBurstEffect — 'motion' — ticker-driven animation, no shader
|
|
674
|
+
* 3. VHSCompositeEffect — 'composite' — shader + animated overlay together
|
|
675
|
+
*/
|
|
676
|
+
|
|
677
|
+
declare const NeonGlowEffect: PixiEffectDefinition;
|
|
678
|
+
declare const ParticleBurstEffect: PixiEffectDefinition;
|
|
679
|
+
declare const VHSCompositeEffect: PixiEffectDefinition;
|
|
680
|
+
|
|
681
|
+
declare const example_NeonGlowEffect: typeof NeonGlowEffect;
|
|
682
|
+
declare const example_ParticleBurstEffect: typeof ParticleBurstEffect;
|
|
683
|
+
declare const example_VHSCompositeEffect: typeof VHSCompositeEffect;
|
|
684
|
+
declare namespace example {
|
|
685
|
+
export { example_NeonGlowEffect as NeonGlowEffect, example_ParticleBurstEffect as ParticleBurstEffect, example_VHSCompositeEffect as VHSCompositeEffect };
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
/**
|
|
689
|
+
* Shake Effect
|
|
690
|
+
*/
|
|
691
|
+
|
|
692
|
+
declare function renderShake(ctx: CanvasRenderingContext2D, params: EffectParameters, intensity: number, time: number): void;
|
|
693
|
+
|
|
694
|
+
/**
|
|
695
|
+
* Zoom Effect
|
|
696
|
+
*/
|
|
697
|
+
|
|
698
|
+
declare function renderZoom(ctx: CanvasRenderingContext2D, params: EffectParameters, intensity: number, time: number): void;
|
|
699
|
+
|
|
700
|
+
/**
|
|
701
|
+
* Pan Effect
|
|
702
|
+
*/
|
|
703
|
+
|
|
704
|
+
declare function renderPan(ctx: CanvasRenderingContext2D, params: EffectParameters, intensity: number, time: number): void;
|
|
705
|
+
|
|
706
|
+
/**
|
|
707
|
+
* Rotate Effect
|
|
708
|
+
*/
|
|
709
|
+
|
|
710
|
+
declare function renderRotate(ctx: CanvasRenderingContext2D, params: EffectParameters, intensity: number, time: number): void;
|
|
711
|
+
|
|
712
|
+
/**
|
|
713
|
+
* Dolly Effect
|
|
714
|
+
* Essentially zoom with slight rotation
|
|
715
|
+
*/
|
|
716
|
+
|
|
717
|
+
declare function renderDolly(ctx: CanvasRenderingContext2D, params: EffectParameters, intensity: number, time: number): void;
|
|
718
|
+
|
|
719
|
+
/**
|
|
720
|
+
* Camera Effects Renderers
|
|
721
|
+
*/
|
|
722
|
+
|
|
723
|
+
declare const index$1_renderDolly: typeof renderDolly;
|
|
724
|
+
declare const index$1_renderPan: typeof renderPan;
|
|
725
|
+
declare const index$1_renderRotate: typeof renderRotate;
|
|
726
|
+
declare const index$1_renderShake: typeof renderShake;
|
|
727
|
+
declare const index$1_renderZoom: typeof renderZoom;
|
|
728
|
+
declare namespace index$1 {
|
|
729
|
+
export { index$1_renderDolly as renderDolly, index$1_renderPan as renderPan, index$1_renderRotate as renderRotate, index$1_renderShake as renderShake, index$1_renderZoom as renderZoom };
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
/**
|
|
733
|
+
* Light Leak Effect
|
|
734
|
+
*/
|
|
735
|
+
|
|
736
|
+
declare function renderLightLeak(ctx: CanvasRenderingContext2D, params: EffectParameters, intensity: number, time: number): void;
|
|
737
|
+
|
|
738
|
+
/**
|
|
739
|
+
* Light Leak 2 Effect
|
|
740
|
+
* Animated red/orange light that moves from bottom-left → bottom-right → top-right
|
|
741
|
+
*/
|
|
742
|
+
|
|
743
|
+
declare function renderLightLeak2(ctx: CanvasRenderingContext2D, params: EffectParameters, intensity: number, time: number): void;
|
|
744
|
+
|
|
745
|
+
/**
|
|
746
|
+
* Flash Effect
|
|
747
|
+
*/
|
|
748
|
+
|
|
749
|
+
declare function renderFlash(ctx: CanvasRenderingContext2D, params: EffectParameters, intensity: number, time: number): void;
|
|
750
|
+
|
|
751
|
+
/**
|
|
752
|
+
* Flicker Effect
|
|
753
|
+
*/
|
|
754
|
+
|
|
755
|
+
declare function renderFlicker(ctx: CanvasRenderingContext2D, params: EffectParameters, intensity: number, time: number): void;
|
|
756
|
+
|
|
757
|
+
/**
|
|
758
|
+
* Vignette Effect
|
|
759
|
+
*/
|
|
760
|
+
|
|
761
|
+
declare function renderVignette(ctx: CanvasRenderingContext2D, params: EffectParameters, intensity: number, time: number): void;
|
|
762
|
+
|
|
763
|
+
/**
|
|
764
|
+
* Glow Effect
|
|
765
|
+
*/
|
|
766
|
+
|
|
767
|
+
declare function renderGlow(ctx: CanvasRenderingContext2D, params: EffectParameters, intensity: number, time: number): void;
|
|
768
|
+
|
|
769
|
+
/**
|
|
770
|
+
* Fire Effect Renderer
|
|
771
|
+
* Creates animated fire effects with particles and heat distortion
|
|
772
|
+
*/
|
|
773
|
+
|
|
774
|
+
declare function renderFire(ctx: CanvasRenderingContext2D, params: EffectParameters, intensity: number, time: number): void;
|
|
775
|
+
|
|
776
|
+
/**
|
|
777
|
+
* Particles Effect Renderer
|
|
778
|
+
* Creates floating particles with various behaviors
|
|
779
|
+
*/
|
|
780
|
+
|
|
781
|
+
declare function renderParticles(ctx: CanvasRenderingContext2D, params: EffectParameters, intensity: number, time: number): void;
|
|
782
|
+
declare function renderDustParticles(ctx: CanvasRenderingContext2D, params: EffectParameters, intensity: number, time: number): void;
|
|
783
|
+
|
|
784
|
+
/**
|
|
785
|
+
* Light Effects Renderers
|
|
786
|
+
*/
|
|
787
|
+
|
|
788
|
+
declare const index_renderDustParticles: typeof renderDustParticles;
|
|
789
|
+
declare const index_renderFire: typeof renderFire;
|
|
790
|
+
declare const index_renderFlash: typeof renderFlash;
|
|
791
|
+
declare const index_renderFlicker: typeof renderFlicker;
|
|
792
|
+
declare const index_renderGlow: typeof renderGlow;
|
|
793
|
+
declare const index_renderLightLeak: typeof renderLightLeak;
|
|
794
|
+
declare const index_renderLightLeak2: typeof renderLightLeak2;
|
|
795
|
+
declare const index_renderParticles: typeof renderParticles;
|
|
796
|
+
declare const index_renderVignette: typeof renderVignette;
|
|
797
|
+
declare namespace index {
|
|
798
|
+
export { index_renderDustParticles as renderDustParticles, index_renderFire as renderFire, index_renderFlash as renderFlash, index_renderFlicker as renderFlicker, index_renderGlow as renderGlow, index_renderLightLeak as renderLightLeak, index_renderLightLeak2 as renderLightLeak2, index_renderParticles as renderParticles, index_renderVignette as renderVignette };
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
export { type AppliedEffect, type AppliedOverlay, type BlendMode, index$1 as CameraEffects, type Canvas2DEffectDefinition, type Canvas2DEngine, type Canvas2DEngineConstructor, EFFECTS_REGISTRY, type EffectCategory$1 as EffectCategory, type EffectDefinition, EffectEngine, EffectGraph, type EffectMetadata, type EffectParameters, type EffectPreset, EffectRenderer, type EffectRenderer$1 as EffectRendererType, example as ExamplePixiEffects, type FilterAsset, type GraphDefinition, index as LightEffects, type OverlayAsset, type ParamSchema, type ParamType, type ParamValues, type PixiEffectContext, type PixiEffectDefinition, type PixiEffectSubtype, type PixiFilterSpec, PixiRenderer, type VideoEffectApiDefinition, type VideoEffectCategory, type VideoEffectItem, type VideoEffectManifest, type VideoEffectState, addNoise, blendColors, clearCanvas, effectMetadataToApi, generateEffectsManifest, getAllEffectsForApi, getEffectByIdForApi, getEffectCategoriesSummary, getEffectMetadata, getEffectPreviewUrl, getEffectRenderer, getEffectsByCategory, getEffectsByCategoryForApi, hexToRgba, isCanvas2DEffect, isCompositeEffect, isFilterEffect, isMotionEffect, isPixiEffect, rgbaToComponents, searchEffects, searchEffectsForApi, withContext };
|