@twick/visualizer 0.0.1 → 0.14.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/.turbo/turbo-build.log +19 -0
- package/.turbo/turbo-docs.log +7 -0
- package/LICENSE +197 -0
- package/README.md +1 -1
- package/dist/mp4.wasm +0 -0
- package/dist/project.css +1 -0
- package/dist/project.js +145 -0
- package/docs/.nojekyll +1 -0
- package/docs/README.md +13 -0
- package/docs/interfaces/Animation.md +47 -0
- package/docs/interfaces/Element.md +47 -0
- package/docs/interfaces/FrameEffectPlugin.md +47 -0
- package/docs/interfaces/TextEffect.md +47 -0
- package/docs/modules.md +535 -0
- package/package.json +34 -31
- package/src/animations/blur.tsx +60 -0
- package/src/animations/breathe.tsx +60 -0
- package/src/animations/fade.tsx +60 -0
- package/src/animations/photo-rise.tsx +66 -0
- package/src/animations/photo-zoom.tsx +73 -0
- package/src/animations/rise.tsx +118 -0
- package/src/animations/succession.tsx +77 -0
- package/src/components/frame-effects.tsx +2 -4
- package/src/components/track.tsx +232 -0
- package/src/controllers/animation.controller.ts +39 -0
- package/src/controllers/element.controller.ts +43 -0
- package/src/controllers/frame-effect.controller.tsx +30 -0
- package/src/controllers/text-effect.controller.ts +33 -0
- package/src/elements/audio.element.tsx +17 -0
- package/src/elements/caption.element.tsx +87 -0
- package/src/elements/circle.element.tsx +20 -0
- package/src/elements/icon.element.tsx +20 -0
- package/src/elements/image.element.tsx +55 -0
- package/src/elements/rect.element.tsx +22 -0
- package/src/elements/scene.element.tsx +29 -0
- package/src/elements/text.element.tsx +28 -0
- package/src/elements/video.element.tsx +56 -0
- package/src/frame-effects/circle.frame.tsx +103 -0
- package/src/frame-effects/rect.frame.tsx +103 -0
- package/src/helpers/caption.utils.ts +4 -14
- package/src/helpers/constants.ts +1 -1
- package/src/helpers/element.utils.ts +222 -68
- package/src/helpers/filters.ts +1 -1
- package/src/helpers/log.utils.ts +0 -3
- package/src/helpers/timing.utils.ts +2 -21
- package/src/helpers/types.ts +103 -8
- package/src/helpers/utils.ts +20 -0
- package/src/index.ts +4 -2
- package/src/live.tsx +1 -1
- package/src/project.ts +1 -1
- package/src/sample.ts +16 -218
- package/src/text-effects/elastic.tsx +39 -0
- package/src/text-effects/erase.tsx +58 -0
- package/src/text-effects/stream-word.tsx +60 -0
- package/src/text-effects/typewriter.tsx +59 -0
- package/src/visualizer.tsx +27 -27
- package/tsconfig.json +3 -2
- package/vite.config.ts +1 -1
- package/src/components/animation.tsx +0 -7
- package/src/components/element.tsx +0 -344
- package/src/components/timeline.tsx +0 -225
package/docs/modules.md
ADDED
|
@@ -0,0 +1,535 @@
|
|
|
1
|
+
# @twick/visualizer
|
|
2
|
+
|
|
3
|
+
## Table of contents
|
|
4
|
+
|
|
5
|
+
### Interfaces
|
|
6
|
+
|
|
7
|
+
- [Animation](interfaces/Animation.md)
|
|
8
|
+
- [Element](interfaces/Element.md)
|
|
9
|
+
- [FrameEffectPlugin](interfaces/FrameEffectPlugin.md)
|
|
10
|
+
- [TextEffect](interfaces/TextEffect.md)
|
|
11
|
+
|
|
12
|
+
### Type Aliases
|
|
13
|
+
|
|
14
|
+
- [AnimationParams](modules.md#animationparams)
|
|
15
|
+
- [AnimationProps](modules.md#animationprops)
|
|
16
|
+
- [Caption](modules.md#caption)
|
|
17
|
+
- [CaptionColors](modules.md#captioncolors)
|
|
18
|
+
- [CaptionFont](modules.md#captionfont)
|
|
19
|
+
- [CaptionProps](modules.md#captionprops)
|
|
20
|
+
- [CaptionStyle](modules.md#captionstyle)
|
|
21
|
+
- [ElementParams](modules.md#elementparams)
|
|
22
|
+
- [FrameEffect](modules.md#frameeffect)
|
|
23
|
+
- [FrameEffectParams](modules.md#frameeffectparams)
|
|
24
|
+
- [FrameEffectProps](modules.md#frameeffectprops)
|
|
25
|
+
- [FrameState](modules.md#framestate)
|
|
26
|
+
- [MediaType](modules.md#mediatype)
|
|
27
|
+
- [ObjectFit](modules.md#objectfit)
|
|
28
|
+
- [Position](modules.md#position)
|
|
29
|
+
- [Size](modules.md#size)
|
|
30
|
+
- [SizeArray](modules.md#sizearray)
|
|
31
|
+
- [SizeVector](modules.md#sizevector)
|
|
32
|
+
- [TextEffectParams](modules.md#texteffectparams)
|
|
33
|
+
- [TextEffectProps](modules.md#texteffectprops)
|
|
34
|
+
- [VideoInput](modules.md#videoinput)
|
|
35
|
+
- [VisualizerElement](modules.md#visualizerelement)
|
|
36
|
+
- [VisualizerTrack](modules.md#visualizertrack)
|
|
37
|
+
|
|
38
|
+
### Variables
|
|
39
|
+
|
|
40
|
+
- [scene](modules.md#scene)
|
|
41
|
+
|
|
42
|
+
## Type Aliases
|
|
43
|
+
|
|
44
|
+
### AnimationParams
|
|
45
|
+
|
|
46
|
+
Ƭ **AnimationParams**: `Object`
|
|
47
|
+
|
|
48
|
+
#### Type declaration
|
|
49
|
+
|
|
50
|
+
| Name | Type |
|
|
51
|
+
| :------ | :------ |
|
|
52
|
+
| `animate?` | ``"enter"`` \| ``"exit"`` \| ``"both"`` |
|
|
53
|
+
| `containerRef?` | `Reference`\<`any`\> |
|
|
54
|
+
| `direction?` | ``"left"`` \| ``"right"`` \| ``"center"`` \| ``"up"`` \| ``"down"`` |
|
|
55
|
+
| `duration?` | `number` |
|
|
56
|
+
| `elementRef` | `Reference`\<`any`\> |
|
|
57
|
+
| `intensity?` | `number` |
|
|
58
|
+
| `interval?` | `number` |
|
|
59
|
+
| `mode?` | ``"in"`` \| ``"out"`` |
|
|
60
|
+
| `view` | `View2D` |
|
|
61
|
+
|
|
62
|
+
#### Defined in
|
|
63
|
+
|
|
64
|
+
[helpers/types.ts:189](https://github.com/ncounterspecialist/twick/blob/7c22d63b8d885bd0a8497127883a5009346a6a6b/packages/visualizer/src/helpers/types.ts#L189)
|
|
65
|
+
|
|
66
|
+
___
|
|
67
|
+
|
|
68
|
+
### AnimationProps
|
|
69
|
+
|
|
70
|
+
Ƭ **AnimationProps**: `Object`
|
|
71
|
+
|
|
72
|
+
#### Type declaration
|
|
73
|
+
|
|
74
|
+
| Name | Type |
|
|
75
|
+
| :------ | :------ |
|
|
76
|
+
| `animate?` | ``"enter"`` \| ``"exit"`` \| ``"both"`` |
|
|
77
|
+
| `direction?` | ``"left"`` \| ``"right"`` \| ``"center"`` \| ``"up"`` \| ``"down"`` |
|
|
78
|
+
| `duration?` | `number` |
|
|
79
|
+
| `intensity?` | `number` |
|
|
80
|
+
| `interval?` | `number` |
|
|
81
|
+
| `mode?` | ``"in"`` \| ``"out"`` |
|
|
82
|
+
| `name` | `string` |
|
|
83
|
+
|
|
84
|
+
#### Defined in
|
|
85
|
+
|
|
86
|
+
[helpers/types.ts:201](https://github.com/ncounterspecialist/twick/blob/7c22d63b8d885bd0a8497127883a5009346a6a6b/packages/visualizer/src/helpers/types.ts#L201)
|
|
87
|
+
|
|
88
|
+
___
|
|
89
|
+
|
|
90
|
+
### Caption
|
|
91
|
+
|
|
92
|
+
Ƭ **Caption**: `Object`
|
|
93
|
+
|
|
94
|
+
#### Type declaration
|
|
95
|
+
|
|
96
|
+
| Name | Type |
|
|
97
|
+
| :------ | :------ |
|
|
98
|
+
| `capStyle?` | `string` |
|
|
99
|
+
| `e` | `number` |
|
|
100
|
+
| `props?` | [`CaptionProps`](modules.md#captionprops) |
|
|
101
|
+
| `s` | `number` |
|
|
102
|
+
| `t` | `string` |
|
|
103
|
+
|
|
104
|
+
#### Defined in
|
|
105
|
+
|
|
106
|
+
[helpers/types.ts:77](https://github.com/ncounterspecialist/twick/blob/7c22d63b8d885bd0a8497127883a5009346a6a6b/packages/visualizer/src/helpers/types.ts#L77)
|
|
107
|
+
|
|
108
|
+
___
|
|
109
|
+
|
|
110
|
+
### CaptionColors
|
|
111
|
+
|
|
112
|
+
Ƭ **CaptionColors**: `Object`
|
|
113
|
+
|
|
114
|
+
#### Type declaration
|
|
115
|
+
|
|
116
|
+
| Name | Type |
|
|
117
|
+
| :------ | :------ |
|
|
118
|
+
| `background?` | `string` |
|
|
119
|
+
| `highlight?` | `string` |
|
|
120
|
+
| `text?` | `string` |
|
|
121
|
+
|
|
122
|
+
#### Defined in
|
|
123
|
+
|
|
124
|
+
[helpers/types.ts:98](https://github.com/ncounterspecialist/twick/blob/7c22d63b8d885bd0a8497127883a5009346a6a6b/packages/visualizer/src/helpers/types.ts#L98)
|
|
125
|
+
|
|
126
|
+
___
|
|
127
|
+
|
|
128
|
+
### CaptionFont
|
|
129
|
+
|
|
130
|
+
Ƭ **CaptionFont**: `Object`
|
|
131
|
+
|
|
132
|
+
#### Type declaration
|
|
133
|
+
|
|
134
|
+
| Name | Type |
|
|
135
|
+
| :------ | :------ |
|
|
136
|
+
| `family?` | `string` |
|
|
137
|
+
| `size?` | `number` |
|
|
138
|
+
| `style?` | `string` |
|
|
139
|
+
| `weight?` | `number` |
|
|
140
|
+
|
|
141
|
+
#### Defined in
|
|
142
|
+
|
|
143
|
+
[helpers/types.ts:104](https://github.com/ncounterspecialist/twick/blob/7c22d63b8d885bd0a8497127883a5009346a6a6b/packages/visualizer/src/helpers/types.ts#L104)
|
|
144
|
+
|
|
145
|
+
___
|
|
146
|
+
|
|
147
|
+
### CaptionProps
|
|
148
|
+
|
|
149
|
+
Ƭ **CaptionProps**: `Object`
|
|
150
|
+
|
|
151
|
+
#### Type declaration
|
|
152
|
+
|
|
153
|
+
| Name | Type |
|
|
154
|
+
| :------ | :------ |
|
|
155
|
+
| `bgMargin?` | [`number`, `number`] |
|
|
156
|
+
| `bgOffsetHeight?` | `number` |
|
|
157
|
+
| `bgOffsetWidth?` | `number` |
|
|
158
|
+
| `bgOpacity?` | `number` |
|
|
159
|
+
| `bgPadding?` | [`number`, `number`] |
|
|
160
|
+
| `bgRadius?` | `number` |
|
|
161
|
+
| `colors` | [`CaptionColors`](modules.md#captioncolors) |
|
|
162
|
+
| `font` | [`CaptionFont`](modules.md#captionfont) |
|
|
163
|
+
| `x?` | `number` |
|
|
164
|
+
| `y?` | `number` |
|
|
165
|
+
|
|
166
|
+
#### Defined in
|
|
167
|
+
|
|
168
|
+
[helpers/types.ts:85](https://github.com/ncounterspecialist/twick/blob/7c22d63b8d885bd0a8497127883a5009346a6a6b/packages/visualizer/src/helpers/types.ts#L85)
|
|
169
|
+
|
|
170
|
+
___
|
|
171
|
+
|
|
172
|
+
### CaptionStyle
|
|
173
|
+
|
|
174
|
+
Ƭ **CaptionStyle**: `Object`
|
|
175
|
+
|
|
176
|
+
#### Type declaration
|
|
177
|
+
|
|
178
|
+
| Name | Type |
|
|
179
|
+
| :------ | :------ |
|
|
180
|
+
| `rect` | \{ `alignItems?`: `string` ; `gap?`: `number` ; `justifyContent?`: `string` ; `padding?`: [`number`, `number`] ; `radius?`: `number` } |
|
|
181
|
+
| `rect.alignItems?` | `string` |
|
|
182
|
+
| `rect.gap?` | `number` |
|
|
183
|
+
| `rect.justifyContent?` | `string` |
|
|
184
|
+
| `rect.padding?` | [`number`, `number`] |
|
|
185
|
+
| `rect.radius?` | `number` |
|
|
186
|
+
| `word` | \{ `bgColor?`: `string` ; `bgOffsetHeight?`: `number` ; `bgOffsetWidth?`: `number` ; `fill`: `string` ; `fontFamily`: `string` ; `fontSize`: `number` ; `fontWeight`: `number` ; `lineWidth`: `number` ; `shadowBlur?`: `number` ; `shadowColor?`: `string` ; `shadowOffset?`: `number`[] ; `stroke`: `string` ; `strokeFirst?`: `boolean` } |
|
|
187
|
+
| `word.bgColor?` | `string` |
|
|
188
|
+
| `word.bgOffsetHeight?` | `number` |
|
|
189
|
+
| `word.bgOffsetWidth?` | `number` |
|
|
190
|
+
| `word.fill` | `string` |
|
|
191
|
+
| `word.fontFamily` | `string` |
|
|
192
|
+
| `word.fontSize` | `number` |
|
|
193
|
+
| `word.fontWeight` | `number` |
|
|
194
|
+
| `word.lineWidth` | `number` |
|
|
195
|
+
| `word.shadowBlur?` | `number` |
|
|
196
|
+
| `word.shadowColor?` | `string` |
|
|
197
|
+
| `word.shadowOffset?` | `number`[] |
|
|
198
|
+
| `word.stroke` | `string` |
|
|
199
|
+
| `word.strokeFirst?` | `boolean` |
|
|
200
|
+
|
|
201
|
+
#### Defined in
|
|
202
|
+
|
|
203
|
+
[helpers/types.ts:52](https://github.com/ncounterspecialist/twick/blob/7c22d63b8d885bd0a8497127883a5009346a6a6b/packages/visualizer/src/helpers/types.ts#L52)
|
|
204
|
+
|
|
205
|
+
___
|
|
206
|
+
|
|
207
|
+
### ElementParams
|
|
208
|
+
|
|
209
|
+
Ƭ **ElementParams**: `Object`
|
|
210
|
+
|
|
211
|
+
#### Type declaration
|
|
212
|
+
|
|
213
|
+
| Name | Type |
|
|
214
|
+
| :------ | :------ |
|
|
215
|
+
| `caption?` | [`Caption`](modules.md#caption) |
|
|
216
|
+
| `containerRef` | `Reference`\<`any`\> |
|
|
217
|
+
| `element?` | [`VisualizerElement`](modules.md#visualizerelement) |
|
|
218
|
+
| `view` | `View2D` |
|
|
219
|
+
| `waitOnStart?` | `boolean` |
|
|
220
|
+
|
|
221
|
+
#### Defined in
|
|
222
|
+
|
|
223
|
+
[helpers/types.ts:153](https://github.com/ncounterspecialist/twick/blob/7c22d63b8d885bd0a8497127883a5009346a6a6b/packages/visualizer/src/helpers/types.ts#L153)
|
|
224
|
+
|
|
225
|
+
___
|
|
226
|
+
|
|
227
|
+
### FrameEffect
|
|
228
|
+
|
|
229
|
+
Ƭ **FrameEffect**: `Object`
|
|
230
|
+
|
|
231
|
+
#### Type declaration
|
|
232
|
+
|
|
233
|
+
| Name | Type |
|
|
234
|
+
| :------ | :------ |
|
|
235
|
+
| `e` | `number` |
|
|
236
|
+
| `name` | `string` |
|
|
237
|
+
| `props` | [`FrameEffectProps`](modules.md#frameeffectprops) |
|
|
238
|
+
| `s` | `number` |
|
|
239
|
+
|
|
240
|
+
#### Defined in
|
|
241
|
+
|
|
242
|
+
[helpers/types.ts:34](https://github.com/ncounterspecialist/twick/blob/7c22d63b8d885bd0a8497127883a5009346a6a6b/packages/visualizer/src/helpers/types.ts#L34)
|
|
243
|
+
|
|
244
|
+
___
|
|
245
|
+
|
|
246
|
+
### FrameEffectParams
|
|
247
|
+
|
|
248
|
+
Ƭ **FrameEffectParams**: `Object`
|
|
249
|
+
|
|
250
|
+
#### Type declaration
|
|
251
|
+
|
|
252
|
+
| Name | Type |
|
|
253
|
+
| :------ | :------ |
|
|
254
|
+
| `containerRef?` | `Reference`\<`any`\> |
|
|
255
|
+
| `elementRef` | `Reference`\<`any`\> |
|
|
256
|
+
| `frameEffect` | [`FrameEffect`](modules.md#frameeffect) |
|
|
257
|
+
| `initFrameState` | [`FrameState`](modules.md#framestate) |
|
|
258
|
+
|
|
259
|
+
#### Defined in
|
|
260
|
+
|
|
261
|
+
[helpers/types.ts:216](https://github.com/ncounterspecialist/twick/blob/7c22d63b8d885bd0a8497127883a5009346a6a6b/packages/visualizer/src/helpers/types.ts#L216)
|
|
262
|
+
|
|
263
|
+
___
|
|
264
|
+
|
|
265
|
+
### FrameEffectProps
|
|
266
|
+
|
|
267
|
+
Ƭ **FrameEffectProps**: `Object`
|
|
268
|
+
|
|
269
|
+
#### Type declaration
|
|
270
|
+
|
|
271
|
+
| Name | Type |
|
|
272
|
+
| :------ | :------ |
|
|
273
|
+
| `elementPosition` | [`Position`](modules.md#position) |
|
|
274
|
+
| `framePosition` | [`Position`](modules.md#position) |
|
|
275
|
+
| `frameShape` | ``"circle"`` \| ``"rect"`` |
|
|
276
|
+
| `frameSize` | [`SizeArray`](modules.md#sizearray) |
|
|
277
|
+
| `objectFit` | [`ObjectFit`](modules.md#objectfit) |
|
|
278
|
+
| `radius` | `number` |
|
|
279
|
+
| `transitionDuration` | `number` |
|
|
280
|
+
| `transitionEasing?` | `string` |
|
|
281
|
+
|
|
282
|
+
#### Defined in
|
|
283
|
+
|
|
284
|
+
[helpers/types.ts:41](https://github.com/ncounterspecialist/twick/blob/7c22d63b8d885bd0a8497127883a5009346a6a6b/packages/visualizer/src/helpers/types.ts#L41)
|
|
285
|
+
|
|
286
|
+
___
|
|
287
|
+
|
|
288
|
+
### FrameState
|
|
289
|
+
|
|
290
|
+
Ƭ **FrameState**: `Object`
|
|
291
|
+
|
|
292
|
+
#### Type declaration
|
|
293
|
+
|
|
294
|
+
| Name | Type |
|
|
295
|
+
| :------ | :------ |
|
|
296
|
+
| `element` | \{ `pos`: `Vector2` ; `scale`: `Vector2` ; `size`: `Vector2` } |
|
|
297
|
+
| `element.pos` | `Vector2` |
|
|
298
|
+
| `element.scale` | `Vector2` |
|
|
299
|
+
| `element.size` | `Vector2` |
|
|
300
|
+
| `frame` | \{ `pos`: `Vector2` ; `radius`: `number` ; `rotation`: `number` ; `scale`: `Vector2` ; `size`: `Vector2` } |
|
|
301
|
+
| `frame.pos` | `Vector2` |
|
|
302
|
+
| `frame.radius` | `number` |
|
|
303
|
+
| `frame.rotation` | `number` |
|
|
304
|
+
| `frame.scale` | `Vector2` |
|
|
305
|
+
| `frame.size` | `Vector2` |
|
|
306
|
+
|
|
307
|
+
#### Defined in
|
|
308
|
+
|
|
309
|
+
[helpers/types.ts:228](https://github.com/ncounterspecialist/twick/blob/7c22d63b8d885bd0a8497127883a5009346a6a6b/packages/visualizer/src/helpers/types.ts#L228)
|
|
310
|
+
|
|
311
|
+
___
|
|
312
|
+
|
|
313
|
+
### MediaType
|
|
314
|
+
|
|
315
|
+
Ƭ **MediaType**: ``"video"`` \| ``"image"``
|
|
316
|
+
|
|
317
|
+
#### Defined in
|
|
318
|
+
|
|
319
|
+
[helpers/types.ts:13](https://github.com/ncounterspecialist/twick/blob/7c22d63b8d885bd0a8497127883a5009346a6a6b/packages/visualizer/src/helpers/types.ts#L13)
|
|
320
|
+
|
|
321
|
+
___
|
|
322
|
+
|
|
323
|
+
### ObjectFit
|
|
324
|
+
|
|
325
|
+
Ƭ **ObjectFit**: ``"contain"`` \| ``"cover"`` \| ``"fill"`` \| ``"none"``
|
|
326
|
+
|
|
327
|
+
#### Defined in
|
|
328
|
+
|
|
329
|
+
[helpers/types.ts:15](https://github.com/ncounterspecialist/twick/blob/7c22d63b8d885bd0a8497127883a5009346a6a6b/packages/visualizer/src/helpers/types.ts#L15)
|
|
330
|
+
|
|
331
|
+
___
|
|
332
|
+
|
|
333
|
+
### Position
|
|
334
|
+
|
|
335
|
+
Ƭ **Position**: `Object`
|
|
336
|
+
|
|
337
|
+
#### Type declaration
|
|
338
|
+
|
|
339
|
+
| Name | Type |
|
|
340
|
+
| :------ | :------ |
|
|
341
|
+
| `x` | `number` |
|
|
342
|
+
| `y` | `number` |
|
|
343
|
+
|
|
344
|
+
#### Defined in
|
|
345
|
+
|
|
346
|
+
[helpers/types.ts:29](https://github.com/ncounterspecialist/twick/blob/7c22d63b8d885bd0a8497127883a5009346a6a6b/packages/visualizer/src/helpers/types.ts#L29)
|
|
347
|
+
|
|
348
|
+
___
|
|
349
|
+
|
|
350
|
+
### Size
|
|
351
|
+
|
|
352
|
+
Ƭ **Size**: `Object`
|
|
353
|
+
|
|
354
|
+
#### Type declaration
|
|
355
|
+
|
|
356
|
+
| Name | Type |
|
|
357
|
+
| :------ | :------ |
|
|
358
|
+
| `height` | `number` |
|
|
359
|
+
| `width` | `number` |
|
|
360
|
+
|
|
361
|
+
#### Defined in
|
|
362
|
+
|
|
363
|
+
[helpers/types.ts:22](https://github.com/ncounterspecialist/twick/blob/7c22d63b8d885bd0a8497127883a5009346a6a6b/packages/visualizer/src/helpers/types.ts#L22)
|
|
364
|
+
|
|
365
|
+
___
|
|
366
|
+
|
|
367
|
+
### SizeArray
|
|
368
|
+
|
|
369
|
+
Ƭ **SizeArray**: [`number`, `number`]
|
|
370
|
+
|
|
371
|
+
#### Defined in
|
|
372
|
+
|
|
373
|
+
[helpers/types.ts:27](https://github.com/ncounterspecialist/twick/blob/7c22d63b8d885bd0a8497127883a5009346a6a6b/packages/visualizer/src/helpers/types.ts#L27)
|
|
374
|
+
|
|
375
|
+
___
|
|
376
|
+
|
|
377
|
+
### SizeVector
|
|
378
|
+
|
|
379
|
+
Ƭ **SizeVector**: `Object`
|
|
380
|
+
|
|
381
|
+
#### Type declaration
|
|
382
|
+
|
|
383
|
+
| Name | Type |
|
|
384
|
+
| :------ | :------ |
|
|
385
|
+
| `x` | `number` |
|
|
386
|
+
| `y` | `number` |
|
|
387
|
+
|
|
388
|
+
#### Defined in
|
|
389
|
+
|
|
390
|
+
[helpers/types.ts:17](https://github.com/ncounterspecialist/twick/blob/7c22d63b8d885bd0a8497127883a5009346a6a6b/packages/visualizer/src/helpers/types.ts#L17)
|
|
391
|
+
|
|
392
|
+
___
|
|
393
|
+
|
|
394
|
+
### TextEffectParams
|
|
395
|
+
|
|
396
|
+
Ƭ **TextEffectParams**: `Object`
|
|
397
|
+
|
|
398
|
+
#### Type declaration
|
|
399
|
+
|
|
400
|
+
| Name | Type |
|
|
401
|
+
| :------ | :------ |
|
|
402
|
+
| `bufferTime?` | `number` |
|
|
403
|
+
| `delay?` | `number` |
|
|
404
|
+
| `direction?` | ``"left"`` \| ``"right"`` \| ``"center"`` |
|
|
405
|
+
| `duration?` | `number` |
|
|
406
|
+
| `elementRef` | `Reference`\<`any`\> |
|
|
407
|
+
| `interval?` | `number` |
|
|
408
|
+
|
|
409
|
+
#### Defined in
|
|
410
|
+
|
|
411
|
+
[helpers/types.ts:166](https://github.com/ncounterspecialist/twick/blob/7c22d63b8d885bd0a8497127883a5009346a6a6b/packages/visualizer/src/helpers/types.ts#L166)
|
|
412
|
+
|
|
413
|
+
___
|
|
414
|
+
|
|
415
|
+
### TextEffectProps
|
|
416
|
+
|
|
417
|
+
Ƭ **TextEffectProps**: `Object`
|
|
418
|
+
|
|
419
|
+
#### Type declaration
|
|
420
|
+
|
|
421
|
+
| Name | Type |
|
|
422
|
+
| :------ | :------ |
|
|
423
|
+
| `bufferTime?` | `number` |
|
|
424
|
+
| `delay?` | `number` |
|
|
425
|
+
| `direction?` | ``"left"`` \| ``"right"`` \| ``"center"`` |
|
|
426
|
+
| `duration?` | `number` |
|
|
427
|
+
| `interval?` | `number` |
|
|
428
|
+
| `name` | `string` |
|
|
429
|
+
|
|
430
|
+
#### Defined in
|
|
431
|
+
|
|
432
|
+
[helpers/types.ts:175](https://github.com/ncounterspecialist/twick/blob/7c22d63b8d885bd0a8497127883a5009346a6a6b/packages/visualizer/src/helpers/types.ts#L175)
|
|
433
|
+
|
|
434
|
+
___
|
|
435
|
+
|
|
436
|
+
### VideoInput
|
|
437
|
+
|
|
438
|
+
Ƭ **VideoInput**: `Object`
|
|
439
|
+
|
|
440
|
+
#### Type declaration
|
|
441
|
+
|
|
442
|
+
| Name | Type |
|
|
443
|
+
| :------ | :------ |
|
|
444
|
+
| `backgroundColor` | `string` |
|
|
445
|
+
| `properties` | \{ `height`: `number` ; `width`: `number` } |
|
|
446
|
+
| `properties.height` | `number` |
|
|
447
|
+
| `properties.width` | `number` |
|
|
448
|
+
| `tracks` | [`VisualizerTrack`](modules.md#visualizertrack)[] |
|
|
449
|
+
|
|
450
|
+
#### Defined in
|
|
451
|
+
|
|
452
|
+
[helpers/types.ts:4](https://github.com/ncounterspecialist/twick/blob/7c22d63b8d885bd0a8497127883a5009346a6a6b/packages/visualizer/src/helpers/types.ts#L4)
|
|
453
|
+
|
|
454
|
+
___
|
|
455
|
+
|
|
456
|
+
### VisualizerElement
|
|
457
|
+
|
|
458
|
+
Ƭ **VisualizerElement**: `Object`
|
|
459
|
+
|
|
460
|
+
#### Type declaration
|
|
461
|
+
|
|
462
|
+
| Name | Type |
|
|
463
|
+
| :------ | :------ |
|
|
464
|
+
| `animation?` | [`AnimationProps`](modules.md#animationprops) |
|
|
465
|
+
| `backgroundColor?` | `string` |
|
|
466
|
+
| `e` | `number` |
|
|
467
|
+
| `frame?` | `any` |
|
|
468
|
+
| `frameEffects?` | [`FrameEffect`](modules.md#frameeffect)[] |
|
|
469
|
+
| `hWords?` | `any` |
|
|
470
|
+
| `id` | `string` |
|
|
471
|
+
| `objectFit?` | ``"contain"`` \| ``"cover"`` \| ``"fill"`` |
|
|
472
|
+
| `props?` | `any` |
|
|
473
|
+
| `s` | `number` |
|
|
474
|
+
| `scale?` | `number` |
|
|
475
|
+
| `t?` | `string` |
|
|
476
|
+
| `textEffect` | [`TextEffectProps`](modules.md#texteffectprops) |
|
|
477
|
+
| `trackId?` | `string` |
|
|
478
|
+
| `type?` | `string` |
|
|
479
|
+
|
|
480
|
+
#### Defined in
|
|
481
|
+
|
|
482
|
+
[helpers/types.ts:111](https://github.com/ncounterspecialist/twick/blob/7c22d63b8d885bd0a8497127883a5009346a6a6b/packages/visualizer/src/helpers/types.ts#L111)
|
|
483
|
+
|
|
484
|
+
___
|
|
485
|
+
|
|
486
|
+
### VisualizerTrack
|
|
487
|
+
|
|
488
|
+
Ƭ **VisualizerTrack**: `Object`
|
|
489
|
+
|
|
490
|
+
#### Type declaration
|
|
491
|
+
|
|
492
|
+
| Name | Type |
|
|
493
|
+
| :------ | :------ |
|
|
494
|
+
| `elements` | [`VisualizerElement`](modules.md#visualizerelement)[] |
|
|
495
|
+
| `id` | `string` |
|
|
496
|
+
| `props?` | \{ `bgOpacity?`: `number` ; `capStyle?`: `string` ; `captionProps?`: [`CaptionProps`](modules.md#captionprops) ; `colors?`: \{ `background?`: `string` ; `highlight?`: `string` ; `text?`: `string` } ; `font?`: \{ `family?`: `string` ; `size?`: `number` ; `style?`: `string` ; `weight?`: `number` } ; `x?`: `number` ; `y?`: `number` } |
|
|
497
|
+
| `props.bgOpacity?` | `number` |
|
|
498
|
+
| `props.capStyle?` | `string` |
|
|
499
|
+
| `props.captionProps?` | [`CaptionProps`](modules.md#captionprops) |
|
|
500
|
+
| `props.colors?` | \{ `background?`: `string` ; `highlight?`: `string` ; `text?`: `string` } |
|
|
501
|
+
| `props.colors.background?` | `string` |
|
|
502
|
+
| `props.colors.highlight?` | `string` |
|
|
503
|
+
| `props.colors.text?` | `string` |
|
|
504
|
+
| `props.font?` | \{ `family?`: `string` ; `size?`: `number` ; `style?`: `string` ; `weight?`: `number` } |
|
|
505
|
+
| `props.font.family?` | `string` |
|
|
506
|
+
| `props.font.size?` | `number` |
|
|
507
|
+
| `props.font.style?` | `string` |
|
|
508
|
+
| `props.font.weight?` | `number` |
|
|
509
|
+
| `props.x?` | `number` |
|
|
510
|
+
| `props.y?` | `number` |
|
|
511
|
+
| `type` | `string` |
|
|
512
|
+
|
|
513
|
+
#### Defined in
|
|
514
|
+
|
|
515
|
+
[helpers/types.ts:129](https://github.com/ncounterspecialist/twick/blob/7c22d63b8d885bd0a8497127883a5009346a6a6b/packages/visualizer/src/helpers/types.ts#L129)
|
|
516
|
+
|
|
517
|
+
## Variables
|
|
518
|
+
|
|
519
|
+
### scene
|
|
520
|
+
|
|
521
|
+
• `Const` **scene**: `SceneDescription`\<`ThreadGeneratorFactory`\<`View2D`\>\>
|
|
522
|
+
|
|
523
|
+
Creates and configures the main scene for video visualization
|
|
524
|
+
|
|
525
|
+
**`Param`**
|
|
526
|
+
|
|
527
|
+
Name of the scene
|
|
528
|
+
|
|
529
|
+
**`Param`**
|
|
530
|
+
|
|
531
|
+
Generator function that handles scene setup and animation
|
|
532
|
+
|
|
533
|
+
#### Defined in
|
|
534
|
+
|
|
535
|
+
[visualizer.tsx:27](https://github.com/ncounterspecialist/twick/blob/7c22d63b8d885bd0a8497127883a5009346a6a6b/packages/visualizer/src/visualizer.tsx#L27)
|
package/package.json
CHANGED
|
@@ -1,31 +1,34 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@twick/visualizer",
|
|
3
|
-
"version": "0.0
|
|
4
|
-
"license": "Apache-2.0",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"@
|
|
13
|
-
"@
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"@twick/
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@twick/visualizer",
|
|
3
|
+
"version": "0.14.0",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"@preact/signals": "^1.2.1",
|
|
10
|
+
"@twick/2d": "^0.14.0",
|
|
11
|
+
"@twick/core": "^0.14.0",
|
|
12
|
+
"@twick/renderer": "^0.14.0",
|
|
13
|
+
"@twick/vite-plugin": "^0.14.0",
|
|
14
|
+
"date-fns": "^4.1.0",
|
|
15
|
+
"preact": "^10.19.2",
|
|
16
|
+
"crelt": "^1.0.6",
|
|
17
|
+
"@twick/media-utils": "0.14.0"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@twick/cli": "0.14.0",
|
|
21
|
+
"@twick/ui": "0.14.0",
|
|
22
|
+
"typescript": "5.4.2",
|
|
23
|
+
"typedoc": "^0.25.8",
|
|
24
|
+
"typedoc-plugin-markdown": "^3.17.1",
|
|
25
|
+
"vite-plugin-dts": "^3.7.3",
|
|
26
|
+
"vite": "^5.1.4"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"start": "twick editor --projectFile ./src/live.tsx",
|
|
30
|
+
"build": "tsc && vite build",
|
|
31
|
+
"docs": "typedoc --out docs src/index.ts",
|
|
32
|
+
"clean": "rimraf .turbo node_modules dist"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { waitFor } from "@twick/core";
|
|
2
|
+
import { AnimationParams } from "../helpers/types";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* BlurAnimation applies a blur effect to an element or its container
|
|
6
|
+
* during enter, exit, or both animations.
|
|
7
|
+
*
|
|
8
|
+
* Available animation modes:
|
|
9
|
+
* - "enter": Starts blurred and gradually becomes clear.
|
|
10
|
+
* - "exit": Starts clear and gradually becomes blurred.
|
|
11
|
+
* - "both": Blurs in, clears, then blurs out.
|
|
12
|
+
*
|
|
13
|
+
* @param elementRef - Reference to the main element.
|
|
14
|
+
* @param containerRef - Optional reference to a container element.
|
|
15
|
+
* @param interval - Duration (in frames or ms) of each blur transition.
|
|
16
|
+
* @param duration - Total duration of the animation.
|
|
17
|
+
* @param intensity - Maximum blur strength (default: 25).
|
|
18
|
+
* @param animate - Animation phase ("enter" | "exit" | "both").
|
|
19
|
+
*/
|
|
20
|
+
export const BlurAnimation = {
|
|
21
|
+
name: "blur",
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Generator function controlling the blur animation.
|
|
25
|
+
*/
|
|
26
|
+
*run({
|
|
27
|
+
elementRef,
|
|
28
|
+
containerRef,
|
|
29
|
+
interval,
|
|
30
|
+
duration,
|
|
31
|
+
intensity = 25,
|
|
32
|
+
animate,
|
|
33
|
+
}: AnimationParams) {
|
|
34
|
+
// Choose containerRef if provided; otherwise, fallback to elementRef
|
|
35
|
+
const ref = containerRef ?? elementRef;
|
|
36
|
+
|
|
37
|
+
let animationInterval = Math.min(interval, duration);
|
|
38
|
+
if (animate === "enter") {
|
|
39
|
+
// Start fully blurred
|
|
40
|
+
ref().filters.blur(intensity);
|
|
41
|
+
// Animate to no blur over 'interval'
|
|
42
|
+
yield* ref().filters.blur(0, animationInterval);
|
|
43
|
+
} else if (animate === "exit") {
|
|
44
|
+
// Wait for the time before exit animation starts
|
|
45
|
+
yield* waitFor(duration - animationInterval);
|
|
46
|
+
// Animate from no blur to full blur over 'interval'
|
|
47
|
+
yield* ref().filters.blur(intensity, animationInterval);
|
|
48
|
+
} else if (animate === "both") {
|
|
49
|
+
animationInterval = Math.min(interval, duration/2);
|
|
50
|
+
// Start fully blurred
|
|
51
|
+
ref().filters.blur(intensity);
|
|
52
|
+
// Animate to no blur
|
|
53
|
+
yield* ref().filters.blur(0, animationInterval);
|
|
54
|
+
// Wait until exit animation
|
|
55
|
+
yield* waitFor(duration - animationInterval);
|
|
56
|
+
// Animate to full blur again
|
|
57
|
+
yield* ref().filters.blur(intensity, animationInterval);
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
};
|