@twick/visualizer 0.14.0 → 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.
Files changed (68) hide show
  1. package/.eslintrc.json +20 -20
  2. package/README.md +113 -13
  3. package/package.json +14 -14
  4. package/package.json.bak +34 -0
  5. package/src/animations/blur.tsx +96 -60
  6. package/src/animations/breathe.tsx +95 -60
  7. package/src/animations/fade.tsx +173 -60
  8. package/src/animations/index.ts +12 -0
  9. package/src/animations/photo-rise.tsx +103 -66
  10. package/src/animations/photo-zoom.tsx +109 -73
  11. package/src/animations/rise.tsx +157 -118
  12. package/src/animations/succession.tsx +112 -77
  13. package/src/components/frame-effects.tsx +188 -188
  14. package/src/components/track.tsx +237 -232
  15. package/src/controllers/animation.controller.ts +38 -38
  16. package/src/controllers/element.controller.ts +42 -42
  17. package/src/controllers/frame-effect.controller.tsx +29 -29
  18. package/src/controllers/text-effect.controller.ts +32 -32
  19. package/src/elements/audio.element.tsx +79 -17
  20. package/src/elements/caption.element.tsx +169 -87
  21. package/src/elements/circle.element.tsx +88 -20
  22. package/src/elements/icon.element.tsx +88 -20
  23. package/src/elements/image.element.tsx +134 -55
  24. package/src/elements/index.ts +14 -0
  25. package/src/elements/rect.element.tsx +92 -22
  26. package/src/elements/scene.element.tsx +97 -29
  27. package/src/elements/text.element.tsx +101 -27
  28. package/src/elements/video.element.tsx +274 -56
  29. package/src/frame-effects/circle.frame.tsx +168 -103
  30. package/src/frame-effects/index.ts +7 -0
  31. package/src/frame-effects/rect.frame.tsx +198 -103
  32. package/src/global.css +11 -11
  33. package/src/helpers/caption.utils.ts +29 -29
  34. package/src/helpers/constants.ts +162 -158
  35. package/src/helpers/element.utils.ts +331 -239
  36. package/src/helpers/event.utils.ts +21 -0
  37. package/src/helpers/filters.ts +127 -127
  38. package/src/helpers/log.utils.ts +55 -29
  39. package/src/helpers/timing.utils.ts +109 -109
  40. package/src/helpers/types.ts +361 -241
  41. package/src/helpers/utils.ts +36 -19
  42. package/src/index.ts +196 -6
  43. package/src/live.tsx +16 -16
  44. package/src/project.ts +6 -6
  45. package/src/sample.ts +247 -247
  46. package/src/text-effects/elastic.tsx +70 -39
  47. package/src/text-effects/erase.tsx +91 -58
  48. package/src/text-effects/index.ts +9 -0
  49. package/src/text-effects/stream-word.tsx +94 -60
  50. package/src/text-effects/typewriter.tsx +93 -59
  51. package/src/visualizer-grouped.ts +83 -0
  52. package/src/visualizer.tsx +182 -78
  53. package/tsconfig.json +11 -11
  54. package/typedoc.json +19 -14
  55. package/vite.config.ts +15 -15
  56. package/.turbo/turbo-build.log +0 -19
  57. package/.turbo/turbo-docs.log +0 -7
  58. package/LICENSE +0 -197
  59. package/dist/mp4.wasm +0 -0
  60. package/dist/project.css +0 -1
  61. package/dist/project.js +0 -145
  62. package/docs/.nojekyll +0 -1
  63. package/docs/README.md +0 -13
  64. package/docs/interfaces/Animation.md +0 -47
  65. package/docs/interfaces/Element.md +0 -47
  66. package/docs/interfaces/FrameEffectPlugin.md +0 -47
  67. package/docs/interfaces/TextEffect.md +0 -47
  68. package/docs/modules.md +0 -535
@@ -1,58 +1,91 @@
1
- import { waitFor } from "@twick/core";
2
- import { TextEffectParams } from "../helpers/types";
3
-
4
- /**
5
- * EraseEffect animates text disappearing letter by letter,
6
- * simulating an "erasing" or backspace effect.
7
- *
8
- * Behavior:
9
- * - Optionally waits for a delay before starting.
10
- * - Preserves the original element size.
11
- * - Animates removing one character at a time from the end.
12
- *
13
- * @param elementRef - Reference to the text element to animate.
14
- * @param duration - Total duration of the erasing animation.
15
- * @param delay - Optional delay before starting.
16
- * @param bufferTime - Time reserved at the end of animation (default: 0.1).
17
- */
18
- export const EraseEffect = {
19
- name: "erase",
20
-
21
- /**
22
- * Generator function controlling the erase text effect.
23
- */
24
- *run({
25
- elementRef,
26
- duration,
27
- delay,
28
- bufferTime = 0.1,
29
- }: TextEffectParams) {
30
- // Get the full original text
31
- const fullText = elementRef().text();
32
-
33
- // Store the original size to avoid resizing during animation
34
- const size = elementRef().size();
35
-
36
- // Initialize element: clear text, set fixed size, align left
37
- elementRef().setText("");
38
- elementRef().size(size);
39
- elementRef().textAlign("left");
40
-
41
- // Wait for the optional initial delay
42
- if (delay) {
43
- yield* waitFor(delay);
44
- }
45
-
46
- // Compute the time interval between each character removal
47
- let timeInterval = (duration - bufferTime) / fullText.length;
48
-
49
- // Optionally wait a bit before starting erasing
50
- yield* waitFor(timeInterval);
51
-
52
- // Loop backwards through the text and erase one character at a time
53
- for (let i = fullText.length; i >= 0; i--) {
54
- yield* waitFor(timeInterval);
55
- elementRef().setText(fullText.substring(0, i));
56
- }
57
- },
58
- };
1
+ import { waitFor } from "@twick/core";
2
+ import { TextEffectParams } from "../helpers/types";
3
+
4
+ /**
5
+ * @group EraseEffect
6
+ * EraseEffect animates text disappearing letter by letter, simulating an "erasing"
7
+ * or backspace effect. Creates engaging text removal animations that mimic
8
+ * real-world erasing or typing corrections.
9
+ *
10
+ * Behavior:
11
+ * - Optionally waits for a delay before starting
12
+ * - Preserves the original element size
13
+ * - Animates removing one character at a time from the end
14
+ *
15
+ * @param elementRef - Reference to the text element to animate
16
+ * @param duration - Total duration of the erasing animation in seconds
17
+ * @param delay - Optional delay before starting in seconds
18
+ * @param bufferTime - Time reserved at the end of animation in seconds (default: 0.1)
19
+ *
20
+ * @example
21
+ * ```js
22
+ * // Basic erase effect
23
+ * textEffect: {
24
+ * name: "erase",
25
+ * duration: 3,
26
+ * delay: 1
27
+ * }
28
+ *
29
+ * // Quick erase with buffer time
30
+ * textEffect: {
31
+ * name: "erase",
32
+ * duration: 2,
33
+ * bufferTime: 0.5
34
+ * }
35
+ * ```
36
+ */
37
+ export const EraseEffect = {
38
+ name: "erase",
39
+
40
+ /**
41
+ * Generator function controlling the erase text effect.
42
+ * Handles character-by-character text removal animations.
43
+ *
44
+ * @param params - Text effect parameters including element reference and timing
45
+ * @returns Generator that controls the erase animation timeline
46
+ *
47
+ * @example
48
+ * ```js
49
+ * yield* EraseEffect.run({
50
+ * elementRef: textElement,
51
+ * duration: 3,
52
+ * delay: 1,
53
+ * bufferTime: 0.1
54
+ * });
55
+ * ```
56
+ */
57
+ *run({
58
+ elementRef,
59
+ duration,
60
+ delay,
61
+ bufferTime = 0.1,
62
+ }: TextEffectParams) {
63
+ // Get the full original text
64
+ const fullText = elementRef().text();
65
+
66
+ // Store the original size to avoid resizing during animation
67
+ const size = elementRef().size();
68
+
69
+ // Initialize element: clear text, set fixed size, align left
70
+ elementRef().setText("");
71
+ elementRef().size(size);
72
+ elementRef().textAlign("left");
73
+
74
+ // Wait for the optional initial delay
75
+ if (delay) {
76
+ yield* waitFor(delay);
77
+ }
78
+
79
+ // Compute the time interval between each character removal
80
+ let timeInterval = (duration - bufferTime) / fullText.length;
81
+
82
+ // Optionally wait a bit before starting erasing
83
+ yield* waitFor(timeInterval);
84
+
85
+ // Loop backwards through the text and erase one character at a time
86
+ for (let i = fullText.length; i >= 0; i--) {
87
+ yield* waitFor(timeInterval);
88
+ elementRef().setText(fullText.substring(0, i));
89
+ }
90
+ },
91
+ };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @group Text Effects
3
+ * @description Text animation and styling effects
4
+ */
5
+
6
+ export { TypewriterEffect } from './typewriter';
7
+ export { StreamWordEffect } from './stream-word';
8
+ export { ElasticEffect } from './elastic';
9
+ export { EraseEffect } from './erase';
@@ -1,60 +1,94 @@
1
- import { waitFor } from "@twick/core";
2
- import { TextEffectParams } from "../helpers/types";
3
-
4
- /**
5
- * StreamWordEffect animates text appearing word by word,
6
- * creating a smooth "typing" or "streaming" effect.
7
- *
8
- * Behavior:
9
- * - Optionally waits for a delay before starting.
10
- * - Clears the text initially and preserves the original size.
11
- * - Reveals one word at a time with a consistent interval.
12
- *
13
- * @param elementRef - Reference to the text element to animate.
14
- * @param duration - Total duration of the animation.
15
- * @param delay - Optional delay before starting.
16
- * @param bufferTime - Time reserved at the end of animation (default: 0.1).
17
- */
18
- export const StreamWordEffect = {
19
- name: "stream-word",
20
-
21
- /**
22
- * Generator function controlling the word streaming effect.
23
- */
24
- *run({
25
- elementRef,
26
- duration,
27
- delay,
28
- bufferTime = 0.1,
29
- }: TextEffectParams) {
30
- // Retrieve the full text content
31
- const fullText = elementRef().text();
32
-
33
- // Store the element's size to avoid resizing during animation
34
- const size = elementRef().size();
35
-
36
- // Split the text into words
37
- const words = fullText.split(" ");
38
-
39
- // Clear the text and set fixed size
40
- elementRef().setText("");
41
- elementRef().size(size);
42
-
43
- // Wait for optional delay before starting
44
- if (delay) {
45
- yield* waitFor(delay);
46
- }
47
-
48
- // Align text to the left
49
- elementRef().textAlign("left");
50
-
51
- // Calculate the interval between words
52
- let timeInterval =(duration - bufferTime) / words.length;
53
-
54
- // Reveal each word one at a time
55
- for (let i = 0; i < words.length; i++) {
56
- yield* waitFor(timeInterval);
57
- elementRef().setText(words.slice(0, i + 1).join(" "));
58
- }
59
- },
60
- };
1
+ import { waitFor } from "@twick/core";
2
+ import { TextEffectParams } from "../helpers/types";
3
+
4
+ /**
5
+ * @group StreamWordEffect
6
+ * StreamWordEffect animates text appearing word by word, creating a smooth
7
+ * "typing" or "streaming" effect. Animates text word by word for natural
8
+ * reading flow and storytelling content.
9
+ *
10
+ * Behavior:
11
+ * - Optionally waits for a delay before starting
12
+ * - Clears the text initially and preserves the original size
13
+ * - Reveals one word at a time with a consistent interval
14
+ *
15
+ * @param elementRef - Reference to the text element to animate
16
+ * @param duration - Total duration of the animation in seconds
17
+ * @param delay - Optional delay before starting in seconds
18
+ * @param bufferTime - Time reserved at the end of animation in seconds
19
+ *
20
+ * @example
21
+ * ```js
22
+ * // Basic stream word effect
23
+ * textEffect: {
24
+ * name: "stream-word",
25
+ * duration: 2,
26
+ * interval: 0.3
27
+ * }
28
+ *
29
+ * // With delay for dramatic effect
30
+ * textEffect: {
31
+ * name: "stream-word",
32
+ * duration: 4,
33
+ * delay: 1,
34
+ * bufferTime: 0.5
35
+ * }
36
+ * ```
37
+ */
38
+ export const StreamWordEffect = {
39
+ name: "stream-word",
40
+
41
+ /**
42
+ * Generator function controlling the word streaming effect.
43
+ * Handles text clearing, word-by-word revelation, and timing for natural reading flow.
44
+ *
45
+ * @param params - Text effect parameters including element reference and timing
46
+ * @returns Generator that controls the stream word animation timeline
47
+ *
48
+ * @example
49
+ * ```js
50
+ * yield* StreamWordEffect.run({
51
+ * elementRef: textElement,
52
+ * duration: 2,
53
+ * delay: 0.5,
54
+ * bufferTime: 0.1
55
+ * });
56
+ * ```
57
+ */
58
+ *run({
59
+ elementRef,
60
+ duration,
61
+ delay,
62
+ bufferTime = 0.1,
63
+ }: TextEffectParams) {
64
+ // Retrieve the full text content
65
+ const fullText = elementRef().text();
66
+
67
+ // Store the element's size to avoid resizing during animation
68
+ const size = elementRef().size();
69
+
70
+ // Split the text into words
71
+ const words = fullText.split(" ");
72
+
73
+ // Clear the text and set fixed size
74
+ elementRef().setText("");
75
+ elementRef().size(size);
76
+
77
+ // Wait for optional delay before starting
78
+ if (delay) {
79
+ yield* waitFor(delay);
80
+ }
81
+
82
+ // Align text to the left
83
+ elementRef().textAlign("left");
84
+
85
+ // Calculate the interval between words
86
+ let timeInterval =(duration - bufferTime) / words.length;
87
+
88
+ // Reveal each word one at a time
89
+ for (let i = 0; i < words.length; i++) {
90
+ yield* waitFor(timeInterval);
91
+ elementRef().setText(words.slice(0, i + 1).join(" "));
92
+ }
93
+ },
94
+ };
@@ -1,59 +1,93 @@
1
- import { waitFor } from "@twick/core";
2
- import { TextEffectParams } from "../helpers/types";
3
-
4
- /**
5
- * TypewriterEffect animates text appearing one character at a time,
6
- * mimicking the behavior of a classic typewriter.
7
- *
8
- * Behavior:
9
- * - Optionally waits for a delay before starting.
10
- * - Clears the text initially and preserves the element's original size.
11
- * - Reveals one character at a time at a consistent interval.
12
- *
13
- * @param elementRef - Reference to the text element to animate.
14
- * @param duration - Total duration of the animation.
15
- * @param delay - Optional delay before starting.
16
- * @param bufferTime - Time reserved at the end of animation (default: 0.1).
17
- */
18
- export const TypewriterEffect = {
19
- name: "typewriter",
20
-
21
- /**
22
- * Generator function controlling the character-by-character typing animation.
23
- */
24
- *run({
25
- elementRef,
26
- duration,
27
- delay,
28
- bufferTime = 0.1,
29
- }: TextEffectParams) {
30
- // Retrieve the full text content
31
- const fullText = elementRef().text();
32
-
33
- // Store the element's size to prevent resizing during animation
34
- const size = elementRef().size();
35
-
36
- // Clear the text and set fixed size
37
- elementRef().setText("");
38
- elementRef().size(size);
39
-
40
- // Align text to the left for consistent typing effect
41
- elementRef().textAlign("left");
42
-
43
- // Wait for an optional initial delay
44
- if (delay) {
45
- yield* waitFor(delay);
46
- }
47
-
48
- let timeInterval =(duration - bufferTime) / fullText.length;
49
-
50
- // Wait briefly before starting typing
51
- yield* waitFor(timeInterval);
52
-
53
- // Reveal each character one by one
54
- for (let i = 0; i < fullText.length; i++) {
55
- yield* waitFor(timeInterval);
56
- elementRef().setText(fullText.substring(0, i + 1));
57
- }
58
- },
59
- };
1
+ import { waitFor } from "@twick/core";
2
+ import { TextEffectParams } from "../helpers/types";
3
+
4
+ /**
5
+ * @group TypewriterEffect
6
+ * TypewriterEffect animates text appearing one character at a time, mimicking the
7
+ * behavior of a classic typewriter. Creates a nostalgic, engaging text animation
8
+ * that draws attention to important content.
9
+ *
10
+ * Behavior:
11
+ * - Optionally waits for a delay before starting
12
+ * - Clears the text initially and preserves the element's original size
13
+ * - Reveals one character at a time at a consistent interval
14
+ *
15
+ * @param elementRef - Reference to the text element to animate
16
+ * @param duration - Total duration of the animation in seconds
17
+ * @param delay - Optional delay before starting in seconds
18
+ * @param bufferTime - Time reserved at the end of animation in seconds
19
+ *
20
+ * @example
21
+ * ```js
22
+ * // Basic typewriter effect
23
+ * textEffect: {
24
+ * name: "typewriter",
25
+ * duration: 3,
26
+ * interval: 0.1
27
+ * }
28
+ *
29
+ * // With delay and buffer time
30
+ * textEffect: {
31
+ * name: "typewriter",
32
+ * duration: 5,
33
+ * delay: 1,
34
+ * bufferTime: 0.5
35
+ * }
36
+ * ```
37
+ */
38
+ export const TypewriterEffect = {
39
+ name: "typewriter",
40
+
41
+ /**
42
+ * Generator function controlling the character-by-character typing animation.
43
+ * Handles text clearing, character revelation, and timing for the typewriter effect.
44
+ *
45
+ * @param params - Text effect parameters including element reference and timing
46
+ * @returns Generator that controls the typewriter animation timeline
47
+ *
48
+ * @example
49
+ * ```js
50
+ * yield* TypewriterEffect.run({
51
+ * elementRef: textElement,
52
+ * duration: 3,
53
+ * delay: 0.5,
54
+ * bufferTime: 0.1
55
+ * });
56
+ * ```
57
+ */
58
+ *run({
59
+ elementRef,
60
+ duration,
61
+ delay,
62
+ bufferTime = 0.1,
63
+ }: TextEffectParams) {
64
+ // Retrieve the full text content
65
+ const fullText = elementRef().text();
66
+
67
+ // Store the element's size to prevent resizing during animation
68
+ const size = elementRef().size();
69
+
70
+ // Clear the text and set fixed size
71
+ elementRef().setText("");
72
+ elementRef().size(size);
73
+
74
+ // Align text to the left for consistent typing effect
75
+ elementRef().textAlign("left");
76
+
77
+ // Wait for an optional initial delay
78
+ if (delay) {
79
+ yield* waitFor(delay);
80
+ }
81
+
82
+ let timeInterval =(duration - bufferTime) / fullText.length;
83
+
84
+ // Wait briefly before starting typing
85
+ yield* waitFor(timeInterval);
86
+
87
+ // Reveal each character one by one
88
+ for (let i = 0; i < fullText.length; i++) {
89
+ yield* waitFor(timeInterval);
90
+ elementRef().setText(fullText.substring(0, i + 1));
91
+ }
92
+ },
93
+ };
@@ -0,0 +1,83 @@
1
+ /**
2
+ * @twick/visualizer - Professional Video Visualization Library
3
+ *
4
+ * A comprehensive TypeScript library for creating dynamic video visualizations with
5
+ * animations, effects, and interactive elements. Built on top of @twick/2d and @twick/core
6
+ * for high-performance 2D graphics and animation.
7
+ *
8
+ * @packageDocumentation
9
+ */
10
+
11
+ // Types
12
+ export * from './helpers/types';
13
+
14
+ // Core functionality
15
+ export * from './visualizer';
16
+
17
+ /**
18
+ * @group Core
19
+ * @description Main scene generator and core functionality
20
+ */
21
+ export { scene } from './visualizer';
22
+
23
+ /**
24
+ * @group Animations
25
+ * @description Motion effects and transitions for elements
26
+ */
27
+
28
+ // Basic animations
29
+ export { FadeAnimation } from './animations/fade';
30
+ export { RiseAnimation } from './animations/rise';
31
+
32
+ // Advanced animations
33
+ export { BlurAnimation } from './animations/blur';
34
+ export { BreatheAnimation } from './animations/breathe';
35
+ export { SuccessionAnimation } from './animations/succession';
36
+
37
+ // Photo-specific animations
38
+ export { PhotoRiseAnimation } from './animations/photo-rise';
39
+ export { PhotoZoomAnimation } from './animations/photo-zoom';
40
+
41
+ /**
42
+ * @group Elements
43
+ * @description Visual components for creating scenes and content
44
+ */
45
+
46
+ // Media elements
47
+ export { VideoElement } from './elements/video.element';
48
+ export { ImageElement } from './elements/image.element';
49
+ export { AudioElement } from './elements/audio.element';
50
+
51
+ // Text and caption elements
52
+ export { TextElement } from './elements/text.element';
53
+ export { CaptionElement } from './elements/caption.element';
54
+
55
+ // Shape and UI elements
56
+ export { RectElement } from './elements/rect.element';
57
+ export { CircleElement } from './elements/circle.element';
58
+ export { IconElement } from './elements/icon.element';
59
+
60
+ // Special elements
61
+ export { SceneElement } from './elements/scene.element';
62
+
63
+ /**
64
+ * @group Text Effects
65
+ * @description Text animation and styling effects
66
+ */
67
+
68
+ // Basic text effects
69
+ export { TypewriterEffect } from './text-effects/typewriter';
70
+ export { StreamWordEffect } from './text-effects/stream-word';
71
+
72
+ // Advanced text effects
73
+ export { ElasticEffect } from './text-effects/elastic';
74
+ export { EraseEffect } from './text-effects/erase';
75
+
76
+ /**
77
+ * @group Frame Effects
78
+ * @description Visual frame and masking effects
79
+ */
80
+
81
+ // Frame effects
82
+ export { CircleFrameEffect } from './frame-effects/circle.frame';
83
+ export { RectFrameEffect } from './frame-effects/rect.frame';