@twick/visualizer 0.14.2 → 0.14.3
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/README.md +104 -4
- package/package.json +8 -8
- package/package.json.bak +8 -8
- package/src/animations/blur.tsx +47 -11
- package/src/animations/breathe.tsx +44 -9
- package/src/animations/fade.tsx +126 -13
- package/src/animations/index.ts +12 -0
- package/src/animations/photo-rise.tsx +48 -11
- package/src/animations/photo-zoom.tsx +45 -9
- package/src/animations/rise.tsx +52 -13
- package/src/animations/succession.tsx +45 -10
- package/src/elements/audio.element.tsx +63 -1
- package/src/elements/caption.element.tsx +82 -0
- package/src/elements/circle.element.tsx +70 -2
- package/src/elements/icon.element.tsx +70 -2
- package/src/elements/image.element.tsx +81 -0
- package/src/elements/index.ts +14 -0
- package/src/elements/rect.element.tsx +72 -2
- package/src/elements/scene.element.tsx +87 -19
- package/src/elements/text.element.tsx +74 -0
- package/src/elements/video.element.tsx +220 -1
- package/src/frame-effects/circle.frame.tsx +77 -12
- package/src/frame-effects/index.ts +7 -0
- package/src/frame-effects/rect.frame.tsx +108 -13
- package/src/helpers/element.utils.ts +100 -8
- package/src/helpers/event.utils.ts +15 -0
- package/src/helpers/log.utils.ts +37 -11
- package/src/helpers/types.ts +119 -0
- package/src/helpers/utils.ts +17 -0
- package/src/index.ts +190 -0
- package/src/text-effects/elastic.tsx +39 -8
- package/src/text-effects/erase.tsx +42 -9
- package/src/text-effects/index.ts +9 -0
- package/src/text-effects/stream-word.tsx +43 -9
- package/src/text-effects/typewriter.tsx +43 -9
- package/src/visualizer-grouped.ts +83 -0
- package/src/visualizer.tsx +89 -5
- package/typedoc.json +8 -3
|
@@ -9,17 +9,29 @@ import { logger } from "./log.utils";
|
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Element utilities for the visualizer package.
|
|
12
|
-
* Provides functions for handling element positioning, sizing, and transformations
|
|
12
|
+
* Provides functions for handling element positioning, sizing, and transformations
|
|
13
|
+
* to ensure proper content display and visual effects.
|
|
13
14
|
*/
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
|
-
* Fits an element within specified bounds while maintaining aspect ratio
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* @param
|
|
20
|
-
* @param
|
|
21
|
-
* @param
|
|
22
|
-
* @
|
|
17
|
+
* Fits an element within specified bounds while maintaining aspect ratio.
|
|
18
|
+
* Handles different object-fit modes for proper content scaling and positioning.
|
|
19
|
+
*
|
|
20
|
+
* @param containerSize - The container size dimensions
|
|
21
|
+
* @param elementSize - The element size dimensions
|
|
22
|
+
* @param elementRef - The element reference to modify
|
|
23
|
+
* @param objectFit - The fit mode (contain, cover, fill, none)
|
|
24
|
+
* @returns Generator that controls the element fitting process
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```js
|
|
28
|
+
* yield* fitElement({
|
|
29
|
+
* containerSize: { x: 800, y: 600 },
|
|
30
|
+
* elementSize: { x: 1920, y: 1080 },
|
|
31
|
+
* elementRef: videoElement,
|
|
32
|
+
* objectFit: "cover"
|
|
33
|
+
* });
|
|
34
|
+
* ```
|
|
23
35
|
*/
|
|
24
36
|
export function* fitElement({
|
|
25
37
|
containerSize,
|
|
@@ -89,6 +101,28 @@ export function* fitElement({
|
|
|
89
101
|
}
|
|
90
102
|
}
|
|
91
103
|
|
|
104
|
+
/**
|
|
105
|
+
* Adds text effects to an element based on its configuration.
|
|
106
|
+
* Applies text animations like typewriter, stream word, or elastic effects.
|
|
107
|
+
*
|
|
108
|
+
* @param elementRef - Reference to the text element
|
|
109
|
+
* @param element - Element configuration containing text effect settings
|
|
110
|
+
* @returns Generator that controls the text effect animation
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```js
|
|
114
|
+
* yield* addTextEffect({
|
|
115
|
+
* elementRef: textElement,
|
|
116
|
+
* element: {
|
|
117
|
+
* textEffect: {
|
|
118
|
+
* name: "typewriter",
|
|
119
|
+
* duration: 3,
|
|
120
|
+
* interval: 0.1
|
|
121
|
+
* }
|
|
122
|
+
* }
|
|
123
|
+
* });
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
92
126
|
export function* addTextEffect({
|
|
93
127
|
elementRef,
|
|
94
128
|
element,
|
|
@@ -109,6 +143,33 @@ export function* addTextEffect({
|
|
|
109
143
|
}
|
|
110
144
|
}
|
|
111
145
|
|
|
146
|
+
/**
|
|
147
|
+
* Adds animations to an element based on its configuration.
|
|
148
|
+
* Applies entrance, exit, or transition animations to elements.
|
|
149
|
+
*
|
|
150
|
+
* @param elementRef - Reference to the element to animate
|
|
151
|
+
* @param containerRef - Optional reference to the container element
|
|
152
|
+
* @param element - Element configuration containing animation settings
|
|
153
|
+
* @param view - The main scene view for rendering
|
|
154
|
+
* @returns Generator that controls the animation timeline
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* ```js
|
|
158
|
+
* yield* addAnimation({
|
|
159
|
+
* elementRef: videoElement,
|
|
160
|
+
* containerRef: frameContainer,
|
|
161
|
+
* element: {
|
|
162
|
+
* animation: {
|
|
163
|
+
* name: "fade",
|
|
164
|
+
* animate: "enter",
|
|
165
|
+
* duration: 2,
|
|
166
|
+
* direction: "center"
|
|
167
|
+
* }
|
|
168
|
+
* },
|
|
169
|
+
* view: sceneView
|
|
170
|
+
* });
|
|
171
|
+
* ```
|
|
172
|
+
*/
|
|
112
173
|
export function* addAnimation({
|
|
113
174
|
elementRef,
|
|
114
175
|
containerRef,
|
|
@@ -136,6 +197,37 @@ export function* addAnimation({
|
|
|
136
197
|
}
|
|
137
198
|
|
|
138
199
|
|
|
200
|
+
/**
|
|
201
|
+
* Adds frame effects to an element based on its configuration.
|
|
202
|
+
* Applies visual masks and containers like circular or rectangular frames.
|
|
203
|
+
*
|
|
204
|
+
* @param containerRef - Reference to the frame container element
|
|
205
|
+
* @param elementRef - Reference to the content element inside the frame
|
|
206
|
+
* @param element - Element configuration containing frame effect settings
|
|
207
|
+
* @returns Generator that controls the frame effect timeline
|
|
208
|
+
*
|
|
209
|
+
* @example
|
|
210
|
+
* ```js
|
|
211
|
+
* yield* addFrameEffect({
|
|
212
|
+
* containerRef: frameContainer,
|
|
213
|
+
* elementRef: contentElement,
|
|
214
|
+
* element: {
|
|
215
|
+
* frameEffects: [{
|
|
216
|
+
* name: "circle",
|
|
217
|
+
* s: 0,
|
|
218
|
+
* e: 10,
|
|
219
|
+
* props: {
|
|
220
|
+
* frameSize: [400, 400],
|
|
221
|
+
* frameShape: "circle",
|
|
222
|
+
* framePosition: { x: 960, y: 540 },
|
|
223
|
+
* radius: 200,
|
|
224
|
+
* objectFit: "cover"
|
|
225
|
+
* }
|
|
226
|
+
* }]
|
|
227
|
+
* }
|
|
228
|
+
* });
|
|
229
|
+
* ```
|
|
230
|
+
*/
|
|
139
231
|
export function* addFrameEffect({
|
|
140
232
|
containerRef,
|
|
141
233
|
elementRef,
|
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dispatches a custom event to the window object.
|
|
3
|
+
* Creates and dispatches a CustomEvent with the specified name and detail
|
|
4
|
+
* if running in a browser environment.
|
|
5
|
+
*
|
|
6
|
+
* @param eventName - The name of the custom event to dispatch
|
|
7
|
+
* @param detail - The event detail object to include with the event
|
|
8
|
+
* @returns True if the event was dispatched successfully, false otherwise
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```js
|
|
12
|
+
* dispatchWindowEvent("playerUpdate", { status: "ready", playerId: "123" });
|
|
13
|
+
* // Dispatches a custom event with player update information
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
1
16
|
export const dispatchWindowEvent = (eventName: string, detail: any) => {
|
|
2
17
|
if (typeof window !== "undefined") {
|
|
3
18
|
const event = new CustomEvent(eventName, detail as any);
|
package/src/helpers/log.utils.ts
CHANGED
|
@@ -1,28 +1,54 @@
|
|
|
1
1
|
import { format } from "date-fns";
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Gets the current time formatted according to the specified format.
|
|
5
|
+
* Uses date-fns to format the current timestamp.
|
|
6
|
+
*
|
|
7
|
+
* @param dateFormat - The date format string to use
|
|
8
|
+
* @returns Formatted time string
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```js
|
|
12
|
+
* const time = getCurrentTime("mm:ss:SSS");
|
|
13
|
+
* // time = "05:30:123"
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
3
16
|
const getCurrentTime = (dateFormat = "mm:ss:SSS") => {
|
|
4
17
|
const now = new Date();
|
|
5
18
|
return format(now, dateFormat);
|
|
6
19
|
};
|
|
7
20
|
|
|
8
21
|
/**
|
|
9
|
-
*
|
|
10
|
-
* Provides consistent logging functionality across the application
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* @
|
|
22
|
+
* Logs a message to the console with a visualizer prefix.
|
|
23
|
+
* Provides consistent logging functionality across the application
|
|
24
|
+
* with standardized formatting and prefixing.
|
|
25
|
+
*
|
|
26
|
+
* @param message - The message to log
|
|
27
|
+
* @param data - Optional data to log
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```js
|
|
31
|
+
* logger("Scene loaded successfully", { sceneId: "scene1" });
|
|
32
|
+
* // Output: [Visualizer] Scene loaded successfully { sceneId: "scene1" }
|
|
33
|
+
* ```
|
|
17
34
|
*/
|
|
18
35
|
export function logger(message: string, data?: any) {
|
|
19
36
|
console.log(`[Visualizer] ${message}`, data ? data : "");
|
|
20
37
|
}
|
|
21
38
|
|
|
22
39
|
/**
|
|
23
|
-
* Logs an error to the console with a visualizer prefix
|
|
24
|
-
*
|
|
25
|
-
*
|
|
40
|
+
* Logs an error to the console with a visualizer prefix.
|
|
41
|
+
* Provides consistent error logging functionality across the application
|
|
42
|
+
* with standardized formatting and prefixing.
|
|
43
|
+
*
|
|
44
|
+
* @param message - The error message to log
|
|
45
|
+
* @param error - Optional error object
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```js
|
|
49
|
+
* errorLogger("Failed to load scene", new Error("Network error"));
|
|
50
|
+
* // Output: [Visualizer Error] Failed to load scene Error: Network error
|
|
51
|
+
* ```
|
|
26
52
|
*/
|
|
27
53
|
export function errorLogger(message: string, error?: Error) {
|
|
28
54
|
console.error(`[Visualizer Error] ${message}`, error ? error : "");
|
package/src/helpers/types.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { View2D } from "@twick/2d";
|
|
2
2
|
import { Reference, ThreadGenerator, Vector2 } from "@twick/core";
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Main input configuration for video visualization.
|
|
6
|
+
* Contains player settings, background color, dimensions, and track definitions
|
|
7
|
+
* for creating complete video visualizations.
|
|
8
|
+
*/
|
|
4
9
|
export type VideoInput = {
|
|
5
10
|
playerId: string,
|
|
6
11
|
backgroundColor: string;
|
|
@@ -11,27 +16,55 @@ export type VideoInput = {
|
|
|
11
16
|
tracks: VisualizerTrack[];
|
|
12
17
|
};
|
|
13
18
|
|
|
19
|
+
/**
|
|
20
|
+
* Supported media types for visualizer elements.
|
|
21
|
+
* Defines the types of media content that can be displayed.
|
|
22
|
+
*/
|
|
14
23
|
export type MediaType = "video" | "image";
|
|
15
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Object fit options for content scaling within containers.
|
|
27
|
+
* Controls how content is sized and positioned within its container.
|
|
28
|
+
*/
|
|
16
29
|
export type ObjectFit = "contain" | "cover" | "fill" | "none";
|
|
17
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Two-dimensional size vector with x and y coordinates.
|
|
33
|
+
* Used for representing width and height dimensions.
|
|
34
|
+
*/
|
|
18
35
|
export type SizeVector = {
|
|
19
36
|
x: number;
|
|
20
37
|
y: number;
|
|
21
38
|
};
|
|
22
39
|
|
|
40
|
+
/**
|
|
41
|
+
* Size object with width and height properties.
|
|
42
|
+
* Standard size representation for elements and containers.
|
|
43
|
+
*/
|
|
23
44
|
export type Size = {
|
|
24
45
|
width: number;
|
|
25
46
|
height: number;
|
|
26
47
|
};
|
|
27
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Size array with width and height values.
|
|
51
|
+
* Alternative size representation as a tuple.
|
|
52
|
+
*/
|
|
28
53
|
export type SizeArray = [number, number];
|
|
29
54
|
|
|
55
|
+
/**
|
|
56
|
+
* Position object with x and y coordinates.
|
|
57
|
+
* Represents 2D positioning for elements in the scene.
|
|
58
|
+
*/
|
|
30
59
|
export type Position = {
|
|
31
60
|
x: number;
|
|
32
61
|
y: number;
|
|
33
62
|
};
|
|
34
63
|
|
|
64
|
+
/**
|
|
65
|
+
* Frame effect configuration for visual masking.
|
|
66
|
+
* Defines timing and properties for frame effects like circles and rectangles.
|
|
67
|
+
*/
|
|
35
68
|
export type FrameEffect = {
|
|
36
69
|
name: string;
|
|
37
70
|
s: number;
|
|
@@ -39,6 +72,10 @@ export type FrameEffect = {
|
|
|
39
72
|
props: FrameEffectProps;
|
|
40
73
|
};
|
|
41
74
|
|
|
75
|
+
/**
|
|
76
|
+
* Properties for frame effect transformations.
|
|
77
|
+
* Controls frame size, shape, position, and transition behavior.
|
|
78
|
+
*/
|
|
42
79
|
export type FrameEffectProps = {
|
|
43
80
|
frameSize: SizeArray;
|
|
44
81
|
frameShape: "circle" | "rect";
|
|
@@ -50,6 +87,10 @@ export type FrameEffectProps = {
|
|
|
50
87
|
elementPosition: Position;
|
|
51
88
|
};
|
|
52
89
|
|
|
90
|
+
/**
|
|
91
|
+
* Styling configuration for caption elements.
|
|
92
|
+
* Defines visual appearance of captions including layout and text styling.
|
|
93
|
+
*/
|
|
53
94
|
export type CaptionStyle = {
|
|
54
95
|
rect: {
|
|
55
96
|
alignItems?: string;
|
|
@@ -75,6 +116,10 @@ export type CaptionStyle = {
|
|
|
75
116
|
};
|
|
76
117
|
};
|
|
77
118
|
|
|
119
|
+
/**
|
|
120
|
+
* Caption element configuration.
|
|
121
|
+
* Defines text content, timing, styling, and display properties for captions.
|
|
122
|
+
*/
|
|
78
123
|
export type Caption = {
|
|
79
124
|
t: string;
|
|
80
125
|
s: number;
|
|
@@ -83,6 +128,10 @@ export type Caption = {
|
|
|
83
128
|
props?: CaptionProps;
|
|
84
129
|
};
|
|
85
130
|
|
|
131
|
+
/**
|
|
132
|
+
* Caption styling properties.
|
|
133
|
+
* Controls colors, fonts, background, and positioning for caption text.
|
|
134
|
+
*/
|
|
86
135
|
export type CaptionProps = {
|
|
87
136
|
colors: CaptionColors;
|
|
88
137
|
font: CaptionFont;
|
|
@@ -96,12 +145,20 @@ export type CaptionProps = {
|
|
|
96
145
|
y?: number;
|
|
97
146
|
};
|
|
98
147
|
|
|
148
|
+
/**
|
|
149
|
+
* Color configuration for caption text and backgrounds.
|
|
150
|
+
* Defines text color, background color, and highlight colors.
|
|
151
|
+
*/
|
|
99
152
|
export type CaptionColors = {
|
|
100
153
|
text?: string;
|
|
101
154
|
background?: string;
|
|
102
155
|
highlight?: string;
|
|
103
156
|
};
|
|
104
157
|
|
|
158
|
+
/**
|
|
159
|
+
* Font configuration for caption text.
|
|
160
|
+
* Controls font family, size, weight, and style.
|
|
161
|
+
*/
|
|
105
162
|
export type CaptionFont = {
|
|
106
163
|
family?: string;
|
|
107
164
|
size?: number;
|
|
@@ -109,6 +166,11 @@ export type CaptionFont = {
|
|
|
109
166
|
style?: string;
|
|
110
167
|
};
|
|
111
168
|
|
|
169
|
+
/**
|
|
170
|
+
* Visualizer element configuration.
|
|
171
|
+
* Defines the structure and properties for all visual elements in the scene
|
|
172
|
+
* including videos, images, text, and captions with their animations and effects.
|
|
173
|
+
*/
|
|
112
174
|
export type VisualizerElement = {
|
|
113
175
|
id: string;
|
|
114
176
|
trackId?: string;
|
|
@@ -127,6 +189,11 @@ export type VisualizerElement = {
|
|
|
127
189
|
hWords?: any;
|
|
128
190
|
};
|
|
129
191
|
|
|
192
|
+
/**
|
|
193
|
+
* Visualizer track configuration.
|
|
194
|
+
* Contains a collection of elements that share common properties and timing.
|
|
195
|
+
* Tracks organize elements into logical groups for better scene management.
|
|
196
|
+
*/
|
|
130
197
|
export type VisualizerTrack = {
|
|
131
198
|
id: string;
|
|
132
199
|
type: string;
|
|
@@ -151,6 +218,10 @@ export type VisualizerTrack = {
|
|
|
151
218
|
};
|
|
152
219
|
};
|
|
153
220
|
|
|
221
|
+
/**
|
|
222
|
+
* Parameters for creating elements in the visualizer scene.
|
|
223
|
+
* Contains all necessary references and configuration for element creation.
|
|
224
|
+
*/
|
|
154
225
|
export type ElementParams = {
|
|
155
226
|
view: View2D;
|
|
156
227
|
containerRef: Reference<any>;
|
|
@@ -159,11 +230,21 @@ export type ElementParams = {
|
|
|
159
230
|
waitOnStart?: boolean;
|
|
160
231
|
};
|
|
161
232
|
|
|
233
|
+
/**
|
|
234
|
+
* Interface for creating visual elements in the scene.
|
|
235
|
+
* Defines the contract for all element types including video, image, text, and captions.
|
|
236
|
+
*/
|
|
162
237
|
export interface Element<Params = ElementParams> {
|
|
238
|
+
/** The unique name identifier for this element type */
|
|
163
239
|
name: string;
|
|
240
|
+
/** Creates and manages the element in the scene */
|
|
164
241
|
create(params: Params): ThreadGenerator;
|
|
165
242
|
}
|
|
166
243
|
|
|
244
|
+
/**
|
|
245
|
+
* Parameters for text effect animations.
|
|
246
|
+
* Controls timing and behavior of text animation effects.
|
|
247
|
+
*/
|
|
167
248
|
export type TextEffectParams = {
|
|
168
249
|
elementRef: Reference<any>;
|
|
169
250
|
interval?: number;
|
|
@@ -173,6 +254,10 @@ export type TextEffectParams = {
|
|
|
173
254
|
direction?: "left" | "right" | "center";
|
|
174
255
|
};
|
|
175
256
|
|
|
257
|
+
/**
|
|
258
|
+
* Configuration properties for text effects.
|
|
259
|
+
* Defines how text effects should behave and appear.
|
|
260
|
+
*/
|
|
176
261
|
export type TextEffectProps = {
|
|
177
262
|
name: string;
|
|
178
263
|
interval?: number;
|
|
@@ -182,11 +267,21 @@ export type TextEffectProps = {
|
|
|
182
267
|
direction?: "left" | "right" | "center";
|
|
183
268
|
};
|
|
184
269
|
|
|
270
|
+
/**
|
|
271
|
+
* Interface for text effect animations.
|
|
272
|
+
* Defines the contract for text animation effects like typewriter, stream word, etc.
|
|
273
|
+
*/
|
|
185
274
|
export interface TextEffect<Params = TextEffectParams> {
|
|
275
|
+
/** The unique name identifier for this text effect */
|
|
186
276
|
name: string;
|
|
277
|
+
/** Executes the text effect animation */
|
|
187
278
|
run(params: Params): Generator;
|
|
188
279
|
}
|
|
189
280
|
|
|
281
|
+
/**
|
|
282
|
+
* Parameters for element animations.
|
|
283
|
+
* Controls timing, direction, and behavior of element animations.
|
|
284
|
+
*/
|
|
190
285
|
export type AnimationParams = {
|
|
191
286
|
elementRef: Reference<any>;
|
|
192
287
|
containerRef?: Reference<any>;
|
|
@@ -199,6 +294,10 @@ export type AnimationParams = {
|
|
|
199
294
|
direction?: "left" | "right" | "center" | "up" | "down";
|
|
200
295
|
};
|
|
201
296
|
|
|
297
|
+
/**
|
|
298
|
+
* Configuration properties for animations.
|
|
299
|
+
* Defines how animations should behave and appear.
|
|
300
|
+
*/
|
|
202
301
|
export type AnimationProps = {
|
|
203
302
|
name: string;
|
|
204
303
|
interval?: number;
|
|
@@ -209,11 +308,21 @@ export type AnimationProps = {
|
|
|
209
308
|
direction?: "left" | "right" | "center" | "up" | "down";
|
|
210
309
|
};
|
|
211
310
|
|
|
311
|
+
/**
|
|
312
|
+
* Interface for element animations.
|
|
313
|
+
* Defines the contract for element animation effects like fade, rise, blur, etc.
|
|
314
|
+
*/
|
|
212
315
|
export interface Animation<Params = AnimationParams> {
|
|
316
|
+
/** The unique name identifier for this animation */
|
|
213
317
|
name: string;
|
|
318
|
+
/** Executes the animation */
|
|
214
319
|
run(params: Params): ThreadGenerator;
|
|
215
320
|
}
|
|
216
321
|
|
|
322
|
+
/**
|
|
323
|
+
* Parameters for frame effects.
|
|
324
|
+
* Controls frame transformations and visual masking effects.
|
|
325
|
+
*/
|
|
217
326
|
export type FrameEffectParams = {
|
|
218
327
|
elementRef: Reference<any>;
|
|
219
328
|
containerRef?: Reference<any>;
|
|
@@ -221,11 +330,21 @@ export type FrameEffectParams = {
|
|
|
221
330
|
frameEffect: FrameEffect;
|
|
222
331
|
};
|
|
223
332
|
|
|
333
|
+
/**
|
|
334
|
+
* Interface for frame effect plugins.
|
|
335
|
+
* Defines the contract for frame effects like circular and rectangular masks.
|
|
336
|
+
*/
|
|
224
337
|
export interface FrameEffectPlugin<Params = FrameEffectParams> {
|
|
338
|
+
/** The unique name identifier for this frame effect */
|
|
225
339
|
name: string;
|
|
340
|
+
/** Executes the frame effect */
|
|
226
341
|
run(params: Params): ThreadGenerator;
|
|
227
342
|
}
|
|
228
343
|
|
|
344
|
+
/**
|
|
345
|
+
* State information for frame and element transformations.
|
|
346
|
+
* Contains size, position, and transformation data for frame effects.
|
|
347
|
+
*/
|
|
229
348
|
export type FrameState = {
|
|
230
349
|
frame: {
|
|
231
350
|
size: Vector2;
|
package/src/helpers/utils.ts
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a hex color string to RGB values.
|
|
3
|
+
* Handles both 3-digit and 6-digit hex color formats
|
|
4
|
+
* and returns an object with red, green, and blue values.
|
|
5
|
+
*
|
|
6
|
+
* @param color - The hex color string to convert
|
|
7
|
+
* @returns Object containing r, g, b values
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```js
|
|
11
|
+
* const rgb = hexToRGB("#ff0000");
|
|
12
|
+
* // rgb = { r: 255, g: 0, b: 0 }
|
|
13
|
+
*
|
|
14
|
+
* const rgb = hexToRGB("#f00");
|
|
15
|
+
* // rgb = { r: 255, g: 0, b: 0 }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
1
18
|
export const hexToRGB = (color: string) => {
|
|
2
19
|
// Remove leading '#' if present
|
|
3
20
|
let hex = color.replace(/^#/, '');
|