@twick/visualizer 0.0.1 → 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 +34 -31
- package/package.json.bak +34 -0
- 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 +188 -190
- package/src/components/track.tsx +237 -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 +53 -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 +55 -0
- package/src/frame-effects/circle.frame.tsx +103 -0
- package/src/frame-effects/rect.frame.tsx +103 -0
- package/src/global.css +11 -11
- package/src/helpers/caption.utils.ts +30 -40
- package/src/helpers/constants.ts +162 -158
- package/src/helpers/element.utils.ts +239 -85
- package/src/helpers/event.utils.ts +6 -0
- package/src/helpers/filters.ts +127 -127
- package/src/helpers/log.utils.ts +29 -32
- package/src/helpers/timing.utils.ts +110 -129
- package/src/helpers/types.ts +242 -146
- package/src/helpers/utils.ts +20 -0
- package/src/index.ts +6 -4
- package/src/live.tsx +16 -16
- package/src/project.ts +6 -6
- package/src/sample.ts +247 -449
- 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 +98 -78
- package/tsconfig.json +11 -10
- package/typedoc.json +14 -14
- package/vite.config.ts +15 -15
- package/src/components/animation.tsx +0 -7
- package/src/components/element.tsx +0 -344
- package/src/components/timeline.tsx +0 -225
|
@@ -1,129 +1,110 @@
|
|
|
1
|
-
import {
|
|
2
|
-
linear,
|
|
3
|
-
easeInSine,
|
|
4
|
-
easeOutSine,
|
|
5
|
-
easeInOutSine,
|
|
6
|
-
easeInQuad,
|
|
7
|
-
easeOutQuad,
|
|
8
|
-
easeInOutQuad,
|
|
9
|
-
easeInCubic,
|
|
10
|
-
easeOutCubic,
|
|
11
|
-
easeInOutCubic,
|
|
12
|
-
easeInQuart,
|
|
13
|
-
easeOutQuart,
|
|
14
|
-
easeInOutQuart,
|
|
15
|
-
easeInQuint,
|
|
16
|
-
easeOutQuint,
|
|
17
|
-
easeInOutQuint,
|
|
18
|
-
easeInExpo,
|
|
19
|
-
easeOutExpo,
|
|
20
|
-
easeInOutExpo,
|
|
21
|
-
easeInCirc,
|
|
22
|
-
easeOutCirc,
|
|
23
|
-
easeInOutCirc,
|
|
24
|
-
easeInBack,
|
|
25
|
-
easeOutBack,
|
|
26
|
-
easeInOutBack,
|
|
27
|
-
easeInElastic,
|
|
28
|
-
easeOutElastic,
|
|
29
|
-
easeInOutElastic,
|
|
30
|
-
easeInBounce,
|
|
31
|
-
easeOutBounce,
|
|
32
|
-
easeInOutBounce,
|
|
33
|
-
} from "@
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Timing utilities for the visualizer package.
|
|
37
|
-
* Provides functions for handling timing and animation calculations.
|
|
38
|
-
*/
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Gets the timing function based on the provided name
|
|
42
|
-
* @param {string} name - Name of the timing function
|
|
43
|
-
* @returns {Function} The timing function
|
|
44
|
-
*/
|
|
45
|
-
export function getTimingFunction(name: string) {
|
|
46
|
-
switch (name) {
|
|
47
|
-
case "easeInSine":
|
|
48
|
-
return easeInSine;
|
|
49
|
-
case "easeOutSine":
|
|
50
|
-
return easeOutSine;
|
|
51
|
-
case "easeInOutSine":
|
|
52
|
-
return easeInOutSine;
|
|
53
|
-
case "easeInQuad":
|
|
54
|
-
return easeInQuad;
|
|
55
|
-
case "easeOutQuad":
|
|
56
|
-
return easeOutQuad;
|
|
57
|
-
case "easeInOutQuad":
|
|
58
|
-
return easeInOutQuad;
|
|
59
|
-
case "easeInCubic":
|
|
60
|
-
return easeInCubic;
|
|
61
|
-
case "easeOutCubic":
|
|
62
|
-
return easeOutCubic;
|
|
63
|
-
case "easeInOutCubic":
|
|
64
|
-
return easeInOutCubic;
|
|
65
|
-
case "easeInQuart":
|
|
66
|
-
return easeInQuart;
|
|
67
|
-
case "easeOutQuart":
|
|
68
|
-
return easeOutQuart;
|
|
69
|
-
case "easeInOutQuart":
|
|
70
|
-
return easeInOutQuart;
|
|
71
|
-
case "easeInQuint":
|
|
72
|
-
return easeInQuint;
|
|
73
|
-
case "easeOutQuint":
|
|
74
|
-
return easeOutQuint;
|
|
75
|
-
case "easeInOutQuint":
|
|
76
|
-
return easeInOutQuint;
|
|
77
|
-
case "easeInExpo":
|
|
78
|
-
return easeInExpo;
|
|
79
|
-
case "easeOutExpo":
|
|
80
|
-
return easeOutExpo;
|
|
81
|
-
case "easeInOutExpo":
|
|
82
|
-
return easeInOutExpo;
|
|
83
|
-
case "easeInCirc":
|
|
84
|
-
return easeInCirc;
|
|
85
|
-
case "easeOutCirc":
|
|
86
|
-
return easeOutCirc;
|
|
87
|
-
case "easeInOutCirc":
|
|
88
|
-
return easeInOutCirc;
|
|
89
|
-
case "easeInBack":
|
|
90
|
-
return easeInBack;
|
|
91
|
-
case "easeOutBack":
|
|
92
|
-
return easeOutBack;
|
|
93
|
-
case "easeInOutBack":
|
|
94
|
-
return easeInOutBack;
|
|
95
|
-
case "easeInElastic":
|
|
96
|
-
return easeInElastic;
|
|
97
|
-
case "easeOutElastic":
|
|
98
|
-
return easeOutElastic;
|
|
99
|
-
case "easeInOutElastic":
|
|
100
|
-
return easeInOutElastic;
|
|
101
|
-
case "easeInBounce":
|
|
102
|
-
return easeInBounce;
|
|
103
|
-
case "easeOutBounce":
|
|
104
|
-
return easeOutBounce;
|
|
105
|
-
case "easeInOutBounce":
|
|
106
|
-
return easeInOutBounce;
|
|
107
|
-
default:
|
|
108
|
-
return linear;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Calculates the duration between two timestamps
|
|
114
|
-
* @param {number} startTime - Start timestamp
|
|
115
|
-
* @param {number} endTime - End timestamp
|
|
116
|
-
* @returns {number} Duration in milliseconds
|
|
117
|
-
*/
|
|
118
|
-
export function calculateDuration(startTime: number, endTime: number) {
|
|
119
|
-
// ... existing code ...
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Formats a timestamp into a readable time string
|
|
124
|
-
* @param {number} timestamp - Timestamp to format
|
|
125
|
-
* @returns {string} Formatted time string
|
|
126
|
-
*/
|
|
127
|
-
export function formatTime(timestamp: number) {
|
|
128
|
-
// ... existing code ...
|
|
129
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
linear,
|
|
3
|
+
easeInSine,
|
|
4
|
+
easeOutSine,
|
|
5
|
+
easeInOutSine,
|
|
6
|
+
easeInQuad,
|
|
7
|
+
easeOutQuad,
|
|
8
|
+
easeInOutQuad,
|
|
9
|
+
easeInCubic,
|
|
10
|
+
easeOutCubic,
|
|
11
|
+
easeInOutCubic,
|
|
12
|
+
easeInQuart,
|
|
13
|
+
easeOutQuart,
|
|
14
|
+
easeInOutQuart,
|
|
15
|
+
easeInQuint,
|
|
16
|
+
easeOutQuint,
|
|
17
|
+
easeInOutQuint,
|
|
18
|
+
easeInExpo,
|
|
19
|
+
easeOutExpo,
|
|
20
|
+
easeInOutExpo,
|
|
21
|
+
easeInCirc,
|
|
22
|
+
easeOutCirc,
|
|
23
|
+
easeInOutCirc,
|
|
24
|
+
easeInBack,
|
|
25
|
+
easeOutBack,
|
|
26
|
+
easeInOutBack,
|
|
27
|
+
easeInElastic,
|
|
28
|
+
easeOutElastic,
|
|
29
|
+
easeInOutElastic,
|
|
30
|
+
easeInBounce,
|
|
31
|
+
easeOutBounce,
|
|
32
|
+
easeInOutBounce,
|
|
33
|
+
} from "@twick/core";
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Timing utilities for the visualizer package.
|
|
37
|
+
* Provides functions for handling timing and animation calculations.
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Gets the timing function based on the provided name
|
|
42
|
+
* @param {string} name - Name of the timing function
|
|
43
|
+
* @returns {Function} The timing function
|
|
44
|
+
*/
|
|
45
|
+
export function getTimingFunction(name: string) {
|
|
46
|
+
switch (name) {
|
|
47
|
+
case "easeInSine":
|
|
48
|
+
return easeInSine;
|
|
49
|
+
case "easeOutSine":
|
|
50
|
+
return easeOutSine;
|
|
51
|
+
case "easeInOutSine":
|
|
52
|
+
return easeInOutSine;
|
|
53
|
+
case "easeInQuad":
|
|
54
|
+
return easeInQuad;
|
|
55
|
+
case "easeOutQuad":
|
|
56
|
+
return easeOutQuad;
|
|
57
|
+
case "easeInOutQuad":
|
|
58
|
+
return easeInOutQuad;
|
|
59
|
+
case "easeInCubic":
|
|
60
|
+
return easeInCubic;
|
|
61
|
+
case "easeOutCubic":
|
|
62
|
+
return easeOutCubic;
|
|
63
|
+
case "easeInOutCubic":
|
|
64
|
+
return easeInOutCubic;
|
|
65
|
+
case "easeInQuart":
|
|
66
|
+
return easeInQuart;
|
|
67
|
+
case "easeOutQuart":
|
|
68
|
+
return easeOutQuart;
|
|
69
|
+
case "easeInOutQuart":
|
|
70
|
+
return easeInOutQuart;
|
|
71
|
+
case "easeInQuint":
|
|
72
|
+
return easeInQuint;
|
|
73
|
+
case "easeOutQuint":
|
|
74
|
+
return easeOutQuint;
|
|
75
|
+
case "easeInOutQuint":
|
|
76
|
+
return easeInOutQuint;
|
|
77
|
+
case "easeInExpo":
|
|
78
|
+
return easeInExpo;
|
|
79
|
+
case "easeOutExpo":
|
|
80
|
+
return easeOutExpo;
|
|
81
|
+
case "easeInOutExpo":
|
|
82
|
+
return easeInOutExpo;
|
|
83
|
+
case "easeInCirc":
|
|
84
|
+
return easeInCirc;
|
|
85
|
+
case "easeOutCirc":
|
|
86
|
+
return easeOutCirc;
|
|
87
|
+
case "easeInOutCirc":
|
|
88
|
+
return easeInOutCirc;
|
|
89
|
+
case "easeInBack":
|
|
90
|
+
return easeInBack;
|
|
91
|
+
case "easeOutBack":
|
|
92
|
+
return easeOutBack;
|
|
93
|
+
case "easeInOutBack":
|
|
94
|
+
return easeInOutBack;
|
|
95
|
+
case "easeInElastic":
|
|
96
|
+
return easeInElastic;
|
|
97
|
+
case "easeOutElastic":
|
|
98
|
+
return easeOutElastic;
|
|
99
|
+
case "easeInOutElastic":
|
|
100
|
+
return easeInOutElastic;
|
|
101
|
+
case "easeInBounce":
|
|
102
|
+
return easeInBounce;
|
|
103
|
+
case "easeOutBounce":
|
|
104
|
+
return easeOutBounce;
|
|
105
|
+
case "easeInOutBounce":
|
|
106
|
+
return easeInOutBounce;
|
|
107
|
+
default:
|
|
108
|
+
return linear;
|
|
109
|
+
}
|
|
110
|
+
}
|
package/src/helpers/types.ts
CHANGED
|
@@ -1,146 +1,242 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export type
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
1
|
+
import { View2D } from "@twick/2d";
|
|
2
|
+
import { Reference, ThreadGenerator, Vector2 } from "@twick/core";
|
|
3
|
+
|
|
4
|
+
export type VideoInput = {
|
|
5
|
+
playerId: string,
|
|
6
|
+
backgroundColor: string;
|
|
7
|
+
properties: {
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
};
|
|
11
|
+
tracks: VisualizerTrack[];
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export type MediaType = "video" | "image";
|
|
15
|
+
|
|
16
|
+
export type ObjectFit = "contain" | "cover" | "fill" | "none";
|
|
17
|
+
|
|
18
|
+
export type SizeVector = {
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type Size = {
|
|
24
|
+
width: number;
|
|
25
|
+
height: number;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export type SizeArray = [number, number];
|
|
29
|
+
|
|
30
|
+
export type Position = {
|
|
31
|
+
x: number;
|
|
32
|
+
y: number;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export type FrameEffect = {
|
|
36
|
+
name: string;
|
|
37
|
+
s: number;
|
|
38
|
+
e: number;
|
|
39
|
+
props: FrameEffectProps;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export type FrameEffectProps = {
|
|
43
|
+
frameSize: SizeArray;
|
|
44
|
+
frameShape: "circle" | "rect";
|
|
45
|
+
framePosition: Position;
|
|
46
|
+
radius: number;
|
|
47
|
+
objectFit: ObjectFit;
|
|
48
|
+
transitionDuration: number;
|
|
49
|
+
transitionEasing?: string;
|
|
50
|
+
elementPosition: Position;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export type CaptionStyle = {
|
|
54
|
+
rect: {
|
|
55
|
+
alignItems?: string;
|
|
56
|
+
gap?: number;
|
|
57
|
+
justifyContent?: string;
|
|
58
|
+
padding?: [number, number];
|
|
59
|
+
radius?: number;
|
|
60
|
+
};
|
|
61
|
+
word: {
|
|
62
|
+
lineWidth: number;
|
|
63
|
+
stroke: string;
|
|
64
|
+
fontWeight: number;
|
|
65
|
+
shadowOffset?: number[];
|
|
66
|
+
shadowColor?: string;
|
|
67
|
+
shadowBlur?: number;
|
|
68
|
+
fill: string;
|
|
69
|
+
fontFamily: string;
|
|
70
|
+
bgColor?: string;
|
|
71
|
+
bgOffsetWidth?: number;
|
|
72
|
+
bgOffsetHeight?: number;
|
|
73
|
+
fontSize: number;
|
|
74
|
+
strokeFirst?: boolean;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export type Caption = {
|
|
79
|
+
t: string;
|
|
80
|
+
s: number;
|
|
81
|
+
e: number;
|
|
82
|
+
capStyle?: string;
|
|
83
|
+
props?: CaptionProps;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export type CaptionProps = {
|
|
87
|
+
colors: CaptionColors;
|
|
88
|
+
font: CaptionFont;
|
|
89
|
+
bgOpacity?: number;
|
|
90
|
+
bgOffsetWidth?: number;
|
|
91
|
+
bgOffsetHeight?: number;
|
|
92
|
+
bgMargin?: [number, number];
|
|
93
|
+
bgRadius?: number;
|
|
94
|
+
bgPadding?: [number, number];
|
|
95
|
+
x?: number;
|
|
96
|
+
y?: number;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export type CaptionColors = {
|
|
100
|
+
text?: string;
|
|
101
|
+
background?: string;
|
|
102
|
+
highlight?: string;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export type CaptionFont = {
|
|
106
|
+
family?: string;
|
|
107
|
+
size?: number;
|
|
108
|
+
weight?: number;
|
|
109
|
+
style?: string;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
export type VisualizerElement = {
|
|
113
|
+
id: string;
|
|
114
|
+
trackId?: string;
|
|
115
|
+
frame?: any;
|
|
116
|
+
props?: any;
|
|
117
|
+
objectFit?: "contain" | "cover" | "fill";
|
|
118
|
+
type?: string;
|
|
119
|
+
s: number;
|
|
120
|
+
e: number;
|
|
121
|
+
backgroundColor?: string;
|
|
122
|
+
animation?: AnimationProps;
|
|
123
|
+
textEffect: TextEffectProps;
|
|
124
|
+
frameEffects?: FrameEffect[];
|
|
125
|
+
scale?: number;
|
|
126
|
+
t?: string;
|
|
127
|
+
hWords?: any;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
export type VisualizerTrack = {
|
|
131
|
+
id: string;
|
|
132
|
+
type: string;
|
|
133
|
+
elements: VisualizerElement[];
|
|
134
|
+
props?: {
|
|
135
|
+
capStyle?: string;
|
|
136
|
+
bgOpacity?: number;
|
|
137
|
+
x?: number;
|
|
138
|
+
y?: number;
|
|
139
|
+
colors?: {
|
|
140
|
+
text?: string;
|
|
141
|
+
background?: string;
|
|
142
|
+
highlight?: string;
|
|
143
|
+
};
|
|
144
|
+
font?: {
|
|
145
|
+
family?: string;
|
|
146
|
+
size?: number;
|
|
147
|
+
weight?: number;
|
|
148
|
+
style?: string;
|
|
149
|
+
};
|
|
150
|
+
captionProps?: CaptionProps;
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
export type ElementParams = {
|
|
155
|
+
view: View2D;
|
|
156
|
+
containerRef: Reference<any>;
|
|
157
|
+
element?: VisualizerElement;
|
|
158
|
+
caption?: Caption;
|
|
159
|
+
waitOnStart?: boolean;
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
export interface Element<Params = ElementParams> {
|
|
163
|
+
name: string;
|
|
164
|
+
create(params: Params): ThreadGenerator;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export type TextEffectParams = {
|
|
168
|
+
elementRef: Reference<any>;
|
|
169
|
+
interval?: number;
|
|
170
|
+
duration?: number;
|
|
171
|
+
bufferTime?: number;
|
|
172
|
+
delay?: number;
|
|
173
|
+
direction?: "left" | "right" | "center";
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
export type TextEffectProps = {
|
|
177
|
+
name: string;
|
|
178
|
+
interval?: number;
|
|
179
|
+
duration?: number;
|
|
180
|
+
bufferTime?: number;
|
|
181
|
+
delay?: number;
|
|
182
|
+
direction?: "left" | "right" | "center";
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
export interface TextEffect<Params = TextEffectParams> {
|
|
186
|
+
name: string;
|
|
187
|
+
run(params: Params): Generator;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export type AnimationParams = {
|
|
191
|
+
elementRef: Reference<any>;
|
|
192
|
+
containerRef?: Reference<any>;
|
|
193
|
+
view: View2D;
|
|
194
|
+
interval?: number;
|
|
195
|
+
duration?: number;
|
|
196
|
+
intensity?: number;
|
|
197
|
+
mode?: "in" | "out";
|
|
198
|
+
animate?: "enter" | "exit" | "both";
|
|
199
|
+
direction?: "left" | "right" | "center" | "up" | "down";
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
export type AnimationProps = {
|
|
203
|
+
name: string;
|
|
204
|
+
interval?: number;
|
|
205
|
+
duration?: number;
|
|
206
|
+
intensity?: number;
|
|
207
|
+
mode?: "in" | "out";
|
|
208
|
+
animate?: "enter" | "exit" | "both";
|
|
209
|
+
direction?: "left" | "right" | "center" | "up" | "down";
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
export interface Animation<Params = AnimationParams> {
|
|
213
|
+
name: string;
|
|
214
|
+
run(params: Params): ThreadGenerator;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export type FrameEffectParams = {
|
|
218
|
+
elementRef: Reference<any>;
|
|
219
|
+
containerRef?: Reference<any>;
|
|
220
|
+
initFrameState: FrameState;
|
|
221
|
+
frameEffect: FrameEffect;
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
export interface FrameEffectPlugin<Params = FrameEffectParams> {
|
|
225
|
+
name: string;
|
|
226
|
+
run(params: Params): ThreadGenerator;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export type FrameState = {
|
|
230
|
+
frame: {
|
|
231
|
+
size: Vector2;
|
|
232
|
+
pos: Vector2;
|
|
233
|
+
radius: number;
|
|
234
|
+
scale: Vector2;
|
|
235
|
+
rotation: number;
|
|
236
|
+
};
|
|
237
|
+
element: {
|
|
238
|
+
size: Vector2;
|
|
239
|
+
pos: Vector2;
|
|
240
|
+
scale: Vector2;
|
|
241
|
+
};
|
|
242
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const hexToRGB = (color: string) => {
|
|
2
|
+
// Remove leading '#' if present
|
|
3
|
+
let hex = color.replace(/^#/, '');
|
|
4
|
+
|
|
5
|
+
// Handle shorthand hex (e.g., #abc)
|
|
6
|
+
if (hex.length === 3) {
|
|
7
|
+
hex = hex.split('').map(c => c + c).join('');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
if (hex.length !== 6) {
|
|
11
|
+
throw new Error('Invalid hex color');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const num = parseInt(hex, 16);
|
|
15
|
+
const r = (num >> 16) & 255;
|
|
16
|
+
const g = (num >> 8) & 255;
|
|
17
|
+
const b = num & 255;
|
|
18
|
+
|
|
19
|
+
return { r, g, b };
|
|
20
|
+
}
|
package/src/index.ts
CHANGED