@twick/visualizer 0.14.0 → 0.14.2
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/.eslintrc.json +20 -20
- package/README.md +12 -12
- package/package.json +13 -13
- package/package.json.bak +34 -0
- package/src/animations/blur.tsx +60 -60
- package/src/animations/breathe.tsx +60 -60
- package/src/animations/fade.tsx +60 -60
- package/src/animations/photo-rise.tsx +66 -66
- package/src/animations/photo-zoom.tsx +73 -73
- package/src/animations/rise.tsx +118 -118
- package/src/animations/succession.tsx +77 -77
- package/src/components/frame-effects.tsx +188 -188
- package/src/components/track.tsx +237 -232
- package/src/controllers/animation.controller.ts +38 -38
- package/src/controllers/element.controller.ts +42 -42
- package/src/controllers/frame-effect.controller.tsx +29 -29
- package/src/controllers/text-effect.controller.ts +32 -32
- package/src/elements/audio.element.tsx +17 -17
- package/src/elements/caption.element.tsx +87 -87
- package/src/elements/circle.element.tsx +20 -20
- package/src/elements/icon.element.tsx +20 -20
- package/src/elements/image.element.tsx +53 -55
- package/src/elements/rect.element.tsx +22 -22
- package/src/elements/scene.element.tsx +29 -29
- package/src/elements/text.element.tsx +27 -27
- package/src/elements/video.element.tsx +55 -56
- package/src/frame-effects/circle.frame.tsx +103 -103
- package/src/frame-effects/rect.frame.tsx +103 -103
- package/src/global.css +11 -11
- package/src/helpers/caption.utils.ts +29 -29
- package/src/helpers/constants.ts +162 -158
- package/src/helpers/element.utils.ts +239 -239
- package/src/helpers/event.utils.ts +6 -0
- package/src/helpers/filters.ts +127 -127
- package/src/helpers/log.utils.ts +29 -29
- package/src/helpers/timing.utils.ts +109 -109
- package/src/helpers/types.ts +242 -241
- package/src/helpers/utils.ts +19 -19
- package/src/index.ts +6 -6
- package/src/live.tsx +16 -16
- package/src/project.ts +6 -6
- package/src/sample.ts +247 -247
- package/src/text-effects/elastic.tsx +39 -39
- package/src/text-effects/erase.tsx +58 -58
- package/src/text-effects/stream-word.tsx +60 -60
- package/src/text-effects/typewriter.tsx +59 -59
- package/src/visualizer.tsx +98 -78
- package/tsconfig.json +11 -11
- package/typedoc.json +14 -14
- package/vite.config.ts +15 -15
- package/.turbo/turbo-build.log +0 -19
- package/.turbo/turbo-docs.log +0 -7
- package/LICENSE +0 -197
- package/dist/mp4.wasm +0 -0
- package/dist/project.css +0 -1
- package/dist/project.js +0 -145
- package/docs/.nojekyll +0 -1
- package/docs/README.md +0 -13
- package/docs/interfaces/Animation.md +0 -47
- package/docs/interfaces/Element.md +0 -47
- package/docs/interfaces/FrameEffectPlugin.md +0 -47
- package/docs/interfaces/TextEffect.md +0 -47
- package/docs/modules.md +0 -535
|
@@ -1,188 +1,188 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Frame effects component that handles the application of various visual effects
|
|
3
|
-
* to frames and elements in the scene.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { all, Reference, waitFor } from "@twick/core";
|
|
7
|
-
import { getTimingFunction } from "../helpers/timing.utils";
|
|
8
|
-
import { fitElement } from "../helpers/element.utils";
|
|
9
|
-
import { DEFAULT_POSITION, DEFAULT_TIMING_FUNCTION, FRAME_SHAPE } from "../helpers/constants";
|
|
10
|
-
import { FrameEffect } from "../helpers/types";
|
|
11
|
-
import { View2D } from "@twick/2d";
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Applies frame effects to a view or element
|
|
15
|
-
* @param {Object} params - Parameters for applying frame effects
|
|
16
|
-
* @param {View2D} params.view - The 2D view to apply effects to
|
|
17
|
-
* @param {FrameEffect[]} params.effects - Array of effects to apply
|
|
18
|
-
* @returns {void}
|
|
19
|
-
*/
|
|
20
|
-
export function applyFrameEffects({ view, effects }: { view: View2D; effects: FrameEffect[] }) {
|
|
21
|
-
// ... existing code ...
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function* addFrameEffect({
|
|
25
|
-
containerRef,
|
|
26
|
-
elementRef,
|
|
27
|
-
frameElement,
|
|
28
|
-
}: {
|
|
29
|
-
containerRef: Reference<any>;
|
|
30
|
-
elementRef: Reference<any>;
|
|
31
|
-
frameElement: any;
|
|
32
|
-
}) {
|
|
33
|
-
let frameEffects = [];
|
|
34
|
-
const initProps = {
|
|
35
|
-
frame: {
|
|
36
|
-
size: containerRef().size(),
|
|
37
|
-
pos: containerRef().position(),
|
|
38
|
-
radius: containerRef().radius(),
|
|
39
|
-
scale: containerRef().scale(),
|
|
40
|
-
rotation: containerRef().rotation(),
|
|
41
|
-
},
|
|
42
|
-
element: {
|
|
43
|
-
size: containerRef().size(),
|
|
44
|
-
pos: elementRef().position(),
|
|
45
|
-
scale: elementRef().scale(),
|
|
46
|
-
},
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
for (let i = 0; i < frameElement?.frameEffects?.length; i++) {
|
|
50
|
-
const frameEffect = frameElement.frameEffects[i];
|
|
51
|
-
const restore =
|
|
52
|
-
i === frameElement.frameEffects.length - 1 ||
|
|
53
|
-
frameElement.frameEffects[i + 1].s !== frameEffect.e;
|
|
54
|
-
frameEffects.push(
|
|
55
|
-
getFrameEffect({
|
|
56
|
-
containerRef,
|
|
57
|
-
elementRef,
|
|
58
|
-
frameEffect,
|
|
59
|
-
element: frameElement,
|
|
60
|
-
restore,
|
|
61
|
-
initProps,
|
|
62
|
-
})
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
yield* all(...frameEffects);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function* getFrameEffect({
|
|
69
|
-
containerRef,
|
|
70
|
-
elementRef,
|
|
71
|
-
frameEffect,
|
|
72
|
-
element,
|
|
73
|
-
initProps,
|
|
74
|
-
restore = true,
|
|
75
|
-
}: {
|
|
76
|
-
containerRef: Reference<any>;
|
|
77
|
-
elementRef: Reference<any>;
|
|
78
|
-
frameEffect: FrameEffect;
|
|
79
|
-
element: any;
|
|
80
|
-
initProps: any;
|
|
81
|
-
restore?: boolean;
|
|
82
|
-
}) {
|
|
83
|
-
yield* waitFor(frameEffect.s);
|
|
84
|
-
const props = frameEffect.props;
|
|
85
|
-
const sequence = [];
|
|
86
|
-
|
|
87
|
-
if (restore) {
|
|
88
|
-
sequence.push(
|
|
89
|
-
restoreState({
|
|
90
|
-
containerRef,
|
|
91
|
-
elementRef,
|
|
92
|
-
frameEffect,
|
|
93
|
-
element,
|
|
94
|
-
initProps,
|
|
95
|
-
})
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
sequence.push(
|
|
100
|
-
containerRef().size(
|
|
101
|
-
props.frameSize,
|
|
102
|
-
props.transitionDuration,
|
|
103
|
-
getTimingFunction(props.transitionEasing ?? DEFAULT_TIMING_FUNCTION)
|
|
104
|
-
)
|
|
105
|
-
);
|
|
106
|
-
|
|
107
|
-
sequence.push(
|
|
108
|
-
containerRef().position(
|
|
109
|
-
props.framePosition ?? { x: 0, y: 0 },
|
|
110
|
-
props.transitionDuration,
|
|
111
|
-
getTimingFunction(props.transitionEasing ?? DEFAULT_TIMING_FUNCTION)
|
|
112
|
-
)
|
|
113
|
-
);
|
|
114
|
-
|
|
115
|
-
sequence.push(
|
|
116
|
-
elementRef().position(
|
|
117
|
-
props.elementPosition ?? DEFAULT_POSITION,
|
|
118
|
-
props.transitionDuration,
|
|
119
|
-
getTimingFunction(props.transitionEasing ?? DEFAULT_TIMING_FUNCTION)
|
|
120
|
-
)
|
|
121
|
-
);
|
|
122
|
-
|
|
123
|
-
switch (props.frameShape) {
|
|
124
|
-
case FRAME_SHAPE.CIRCLE:
|
|
125
|
-
sequence.push(
|
|
126
|
-
containerRef().radius(
|
|
127
|
-
props.frameSize[0] / 2,
|
|
128
|
-
props.transitionDuration,
|
|
129
|
-
getTimingFunction(props.transitionEasing ?? DEFAULT_TIMING_FUNCTION)
|
|
130
|
-
)
|
|
131
|
-
);
|
|
132
|
-
break;
|
|
133
|
-
default:
|
|
134
|
-
sequence.push(
|
|
135
|
-
containerRef().radius(
|
|
136
|
-
props.radius ?? 0,
|
|
137
|
-
props.transitionDuration,
|
|
138
|
-
getTimingFunction(props.transitionEasing ?? DEFAULT_TIMING_FUNCTION)
|
|
139
|
-
)
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
if (props.objectFit) {
|
|
144
|
-
sequence.push(
|
|
145
|
-
fitElement({
|
|
146
|
-
elementRef,
|
|
147
|
-
containerSize: { x: props.frameSize[0], y: props.frameSize[1] },
|
|
148
|
-
elementSize: initProps.element.size,
|
|
149
|
-
objectFit: props.objectFit,
|
|
150
|
-
})
|
|
151
|
-
);
|
|
152
|
-
}
|
|
153
|
-
yield* all(...sequence);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
function* restoreState({
|
|
157
|
-
containerRef,
|
|
158
|
-
elementRef,
|
|
159
|
-
frameEffect,
|
|
160
|
-
element,
|
|
161
|
-
initProps,
|
|
162
|
-
}: {
|
|
163
|
-
containerRef: Reference<any>;
|
|
164
|
-
elementRef: Reference<any>;
|
|
165
|
-
frameEffect: any;
|
|
166
|
-
element: any;
|
|
167
|
-
initProps: any;
|
|
168
|
-
}) {
|
|
169
|
-
yield* waitFor(frameEffect.e - frameEffect.s);
|
|
170
|
-
let sequence = [];
|
|
171
|
-
sequence.push(containerRef().size(initProps.frame.size));
|
|
172
|
-
sequence.push(containerRef().position(initProps.frame.pos));
|
|
173
|
-
sequence.push(containerRef().scale(initProps.frame.scale));
|
|
174
|
-
sequence.push(containerRef().rotation(initProps.frame.rotation));
|
|
175
|
-
sequence.push(containerRef().radius(initProps.frame.radius));
|
|
176
|
-
sequence.push(elementRef().size(initProps.element.size));
|
|
177
|
-
sequence.push(elementRef().position(initProps.element.pos));
|
|
178
|
-
sequence.push(elementRef().scale(initProps.element.scale));
|
|
179
|
-
sequence.push(
|
|
180
|
-
fitElement({
|
|
181
|
-
elementRef,
|
|
182
|
-
containerSize: initProps.frame.size,
|
|
183
|
-
elementSize: initProps.element.size,
|
|
184
|
-
objectFit: element.objectFit ?? "none",
|
|
185
|
-
})
|
|
186
|
-
);
|
|
187
|
-
yield* all(...sequence);
|
|
188
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Frame effects component that handles the application of various visual effects
|
|
3
|
+
* to frames and elements in the scene.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { all, Reference, waitFor } from "@twick/core";
|
|
7
|
+
import { getTimingFunction } from "../helpers/timing.utils";
|
|
8
|
+
import { fitElement } from "../helpers/element.utils";
|
|
9
|
+
import { DEFAULT_POSITION, DEFAULT_TIMING_FUNCTION, FRAME_SHAPE } from "../helpers/constants";
|
|
10
|
+
import { FrameEffect } from "../helpers/types";
|
|
11
|
+
import { View2D } from "@twick/2d";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Applies frame effects to a view or element
|
|
15
|
+
* @param {Object} params - Parameters for applying frame effects
|
|
16
|
+
* @param {View2D} params.view - The 2D view to apply effects to
|
|
17
|
+
* @param {FrameEffect[]} params.effects - Array of effects to apply
|
|
18
|
+
* @returns {void}
|
|
19
|
+
*/
|
|
20
|
+
export function applyFrameEffects({ view, effects }: { view: View2D; effects: FrameEffect[] }) {
|
|
21
|
+
// ... existing code ...
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function* addFrameEffect({
|
|
25
|
+
containerRef,
|
|
26
|
+
elementRef,
|
|
27
|
+
frameElement,
|
|
28
|
+
}: {
|
|
29
|
+
containerRef: Reference<any>;
|
|
30
|
+
elementRef: Reference<any>;
|
|
31
|
+
frameElement: any;
|
|
32
|
+
}) {
|
|
33
|
+
let frameEffects = [];
|
|
34
|
+
const initProps = {
|
|
35
|
+
frame: {
|
|
36
|
+
size: containerRef().size(),
|
|
37
|
+
pos: containerRef().position(),
|
|
38
|
+
radius: containerRef().radius(),
|
|
39
|
+
scale: containerRef().scale(),
|
|
40
|
+
rotation: containerRef().rotation(),
|
|
41
|
+
},
|
|
42
|
+
element: {
|
|
43
|
+
size: containerRef().size(),
|
|
44
|
+
pos: elementRef().position(),
|
|
45
|
+
scale: elementRef().scale(),
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
for (let i = 0; i < frameElement?.frameEffects?.length; i++) {
|
|
50
|
+
const frameEffect = frameElement.frameEffects[i];
|
|
51
|
+
const restore =
|
|
52
|
+
i === frameElement.frameEffects.length - 1 ||
|
|
53
|
+
frameElement.frameEffects[i + 1].s !== frameEffect.e;
|
|
54
|
+
frameEffects.push(
|
|
55
|
+
getFrameEffect({
|
|
56
|
+
containerRef,
|
|
57
|
+
elementRef,
|
|
58
|
+
frameEffect,
|
|
59
|
+
element: frameElement,
|
|
60
|
+
restore,
|
|
61
|
+
initProps,
|
|
62
|
+
})
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
yield* all(...frameEffects);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function* getFrameEffect({
|
|
69
|
+
containerRef,
|
|
70
|
+
elementRef,
|
|
71
|
+
frameEffect,
|
|
72
|
+
element,
|
|
73
|
+
initProps,
|
|
74
|
+
restore = true,
|
|
75
|
+
}: {
|
|
76
|
+
containerRef: Reference<any>;
|
|
77
|
+
elementRef: Reference<any>;
|
|
78
|
+
frameEffect: FrameEffect;
|
|
79
|
+
element: any;
|
|
80
|
+
initProps: any;
|
|
81
|
+
restore?: boolean;
|
|
82
|
+
}) {
|
|
83
|
+
yield* waitFor(frameEffect.s);
|
|
84
|
+
const props = frameEffect.props;
|
|
85
|
+
const sequence = [];
|
|
86
|
+
|
|
87
|
+
if (restore) {
|
|
88
|
+
sequence.push(
|
|
89
|
+
restoreState({
|
|
90
|
+
containerRef,
|
|
91
|
+
elementRef,
|
|
92
|
+
frameEffect,
|
|
93
|
+
element,
|
|
94
|
+
initProps,
|
|
95
|
+
})
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
sequence.push(
|
|
100
|
+
containerRef().size(
|
|
101
|
+
props.frameSize,
|
|
102
|
+
props.transitionDuration,
|
|
103
|
+
getTimingFunction(props.transitionEasing ?? DEFAULT_TIMING_FUNCTION)
|
|
104
|
+
)
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
sequence.push(
|
|
108
|
+
containerRef().position(
|
|
109
|
+
props.framePosition ?? { x: 0, y: 0 },
|
|
110
|
+
props.transitionDuration,
|
|
111
|
+
getTimingFunction(props.transitionEasing ?? DEFAULT_TIMING_FUNCTION)
|
|
112
|
+
)
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
sequence.push(
|
|
116
|
+
elementRef().position(
|
|
117
|
+
props.elementPosition ?? DEFAULT_POSITION,
|
|
118
|
+
props.transitionDuration,
|
|
119
|
+
getTimingFunction(props.transitionEasing ?? DEFAULT_TIMING_FUNCTION)
|
|
120
|
+
)
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
switch (props.frameShape) {
|
|
124
|
+
case FRAME_SHAPE.CIRCLE:
|
|
125
|
+
sequence.push(
|
|
126
|
+
containerRef().radius(
|
|
127
|
+
props.frameSize[0] / 2,
|
|
128
|
+
props.transitionDuration,
|
|
129
|
+
getTimingFunction(props.transitionEasing ?? DEFAULT_TIMING_FUNCTION)
|
|
130
|
+
)
|
|
131
|
+
);
|
|
132
|
+
break;
|
|
133
|
+
default:
|
|
134
|
+
sequence.push(
|
|
135
|
+
containerRef().radius(
|
|
136
|
+
props.radius ?? 0,
|
|
137
|
+
props.transitionDuration,
|
|
138
|
+
getTimingFunction(props.transitionEasing ?? DEFAULT_TIMING_FUNCTION)
|
|
139
|
+
)
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (props.objectFit) {
|
|
144
|
+
sequence.push(
|
|
145
|
+
fitElement({
|
|
146
|
+
elementRef,
|
|
147
|
+
containerSize: { x: props.frameSize[0], y: props.frameSize[1] },
|
|
148
|
+
elementSize: initProps.element.size,
|
|
149
|
+
objectFit: props.objectFit,
|
|
150
|
+
})
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
yield* all(...sequence);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function* restoreState({
|
|
157
|
+
containerRef,
|
|
158
|
+
elementRef,
|
|
159
|
+
frameEffect,
|
|
160
|
+
element,
|
|
161
|
+
initProps,
|
|
162
|
+
}: {
|
|
163
|
+
containerRef: Reference<any>;
|
|
164
|
+
elementRef: Reference<any>;
|
|
165
|
+
frameEffect: any;
|
|
166
|
+
element: any;
|
|
167
|
+
initProps: any;
|
|
168
|
+
}) {
|
|
169
|
+
yield* waitFor(frameEffect.e - frameEffect.s);
|
|
170
|
+
let sequence = [];
|
|
171
|
+
sequence.push(containerRef().size(initProps.frame.size));
|
|
172
|
+
sequence.push(containerRef().position(initProps.frame.pos));
|
|
173
|
+
sequence.push(containerRef().scale(initProps.frame.scale));
|
|
174
|
+
sequence.push(containerRef().rotation(initProps.frame.rotation));
|
|
175
|
+
sequence.push(containerRef().radius(initProps.frame.radius));
|
|
176
|
+
sequence.push(elementRef().size(initProps.element.size));
|
|
177
|
+
sequence.push(elementRef().position(initProps.element.pos));
|
|
178
|
+
sequence.push(elementRef().scale(initProps.element.scale));
|
|
179
|
+
sequence.push(
|
|
180
|
+
fitElement({
|
|
181
|
+
elementRef,
|
|
182
|
+
containerSize: initProps.frame.size,
|
|
183
|
+
elementSize: initProps.element.size,
|
|
184
|
+
objectFit: element.objectFit ?? "none",
|
|
185
|
+
})
|
|
186
|
+
);
|
|
187
|
+
yield* all(...sequence);
|
|
188
|
+
}
|