@tsparticles/fireworks 4.0.0-beta.9 → 4.0.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/README.md +98 -45
- package/browser/browser.js +5 -0
- package/browser/bundle.js +4 -0
- package/browser/fireworks.js +32 -216
- package/browser/fireworks.lazy.js +64 -0
- package/browser/index.lazy.js +1 -0
- package/browser/types.js +1 -0
- package/browser/utils.js +195 -0
- package/cjs/browser.js +5 -0
- package/cjs/bundle.js +4 -0
- package/cjs/fireworks.js +32 -216
- package/cjs/fireworks.lazy.js +64 -0
- package/cjs/index.lazy.js +1 -0
- package/cjs/types.js +1 -0
- package/cjs/utils.js +195 -0
- package/esm/browser.js +5 -0
- package/esm/bundle.js +4 -0
- package/esm/fireworks.js +32 -216
- package/esm/fireworks.lazy.js +64 -0
- package/esm/index.lazy.js +1 -0
- package/esm/types.js +1 -0
- package/esm/utils.js +195 -0
- package/package.json +19 -12
- package/report.html +4949 -94
- package/tsparticles.fireworks.bundle.js +9132 -977
- package/tsparticles.fireworks.bundle.min.js +1 -2
- package/tsparticles.fireworks.js +395 -467
- package/tsparticles.fireworks.min.js +1 -2
- package/types/browser.d.ts +1 -0
- package/types/fireworks.d.ts +3 -6
- package/types/fireworks.lazy.d.ts +17 -0
- package/types/index.lazy.d.ts +4 -0
- package/types/types.d.ts +6 -0
- package/types/utils.d.ts +6 -0
- package/1241.min.js +0 -1
- package/1581.min.js +0 -1
- package/2049.min.js +0 -1
- package/2066.min.js +0 -1
- package/2127.min.js +0 -1
- package/218.min.js +0 -1
- package/2191.min.js +0 -1
- package/2270.min.js +0 -1
- package/2556.min.js +0 -1
- package/2602.min.js +0 -1
- package/2760.min.js +0 -1
- package/2865.min.js +0 -33
- package/3047.min.js +0 -1
- package/3073.min.js +0 -1
- package/3384.min.js +0 -1
- package/3443.min.js +0 -1
- package/3583.min.js +0 -1
- package/374.min.js +0 -1
- package/382.min.js +0 -1
- package/4068.min.js +0 -1
- package/4186.min.js +0 -1
- package/4217.min.js +0 -1
- package/4427.min.js +0 -1
- package/4519.min.js +0 -1
- package/4626.min.js +0 -1
- package/5048.min.js +0 -1
- package/5218.min.js +0 -1
- package/5294.min.js +0 -1
- package/5344.min.js +0 -1
- package/5445.min.js +0 -1
- package/5492.min.js +0 -1
- package/5629.min.js +0 -1
- package/5675.min.js +0 -1
- package/6055.min.js +0 -1
- package/6067.min.js +0 -1
- package/6099.min.js +0 -1
- package/6171.min.js +0 -1
- package/648.min.js +0 -1
- package/6602.min.js +0 -1
- package/6943.min.js +0 -1
- package/6996.min.js +0 -1
- package/7162.min.js +0 -1
- package/7698.min.js +0 -1
- package/7711.min.js +0 -1
- package/7757.min.js +0 -1
- package/7792.min.js +0 -1
- package/8272.min.js +0 -1
- package/8386.min.js +0 -1
- package/8529.min.js +0 -1
- package/8607.min.js +0 -1
- package/8656.min.js +0 -1
- package/8731.min.js +0 -1
- package/9407.min.js +0 -1
- package/9674.min.js +0 -1
- package/basic_dist_browser_index_js.js +0 -30
- package/dist_browser_FireworksInstance_js.js +0 -30
- package/engine_dist_browser_Core_Container_js.js +0 -100
- package/plugins_blend_dist_browser_BlendPluginInstance_js.js +0 -30
- package/plugins_blend_dist_browser_BlendPlugin_js.js +0 -40
- package/plugins_blend_dist_browser_index_js.js +0 -30
- package/plugins_colors_hex_dist_browser_HexColorManager_js.js +0 -30
- package/plugins_colors_hex_dist_browser_index_js.js +0 -30
- package/plugins_colors_hsl_dist_browser_HslColorManager_js.js +0 -30
- package/plugins_colors_hsl_dist_browser_index_js.js +0 -30
- package/plugins_colors_rgb_dist_browser_RgbColorManager_js.js +0 -30
- package/plugins_colors_rgb_dist_browser_index_js.js +0 -30
- package/plugins_emittersShapes_square_dist_browser_EmittersSquareShapeGenerator_js.js +0 -100
- package/plugins_emittersShapes_square_dist_browser_index_js.js +0 -30
- package/plugins_emitters_dist_browser_EmitterInstance_js.js +0 -30
- package/plugins_emitters_dist_browser_EmittersInstancesManager_js.js +0 -100
- package/plugins_emitters_dist_browser_EmittersInteractor_js.js +0 -210
- package/plugins_emitters_dist_browser_EmittersPluginInstance_js.js +0 -30
- package/plugins_emitters_dist_browser_EmittersPlugin_js.js +0 -100
- package/plugins_emitters_dist_browser_ShapeManager_js.js +0 -30
- package/plugins_emitters_dist_browser_addEmittersShapesManager_js.js +0 -30
- package/plugins_emitters_dist_browser_getEmittersInstancesManager_js.js +0 -30
- package/plugins_emitters_dist_browser_index_js.js +0 -80
- package/plugins_emitters_dist_browser_plugin_js.js +0 -50
- package/plugins_interactivity_dist_browser_InteractivityPluginInstance_js.js +0 -50
- package/plugins_interactivity_dist_browser_InteractivityPlugin_js.js +0 -70
- package/plugins_interactivity_dist_browser_index_js.js +0 -120
- package/plugins_move_dist_browser_MovePluginInstance_js.js +0 -40
- package/plugins_move_dist_browser_MovePlugin_js.js +0 -30
- package/plugins_move_dist_browser_index_js.js +0 -30
- package/plugins_sounds_dist_browser_SoundsPluginInstance_js.js +0 -40
- package/plugins_sounds_dist_browser_SoundsPlugin_js.js +0 -130
- package/plugins_sounds_dist_browser_index_js.js +0 -30
- package/shapes_circle_dist_browser_CircleDrawer_js.js +0 -40
- package/shapes_circle_dist_browser_index_js.js +0 -30
- package/shapes_line_dist_browser_LineDrawer_js.js +0 -40
- package/shapes_line_dist_browser_index_js.js +0 -30
- package/updaters_destroy_dist_browser_DestroyUpdater_js.js +0 -100
- package/updaters_destroy_dist_browser_index_js.js +0 -30
- package/updaters_fillColor_dist_browser_FillColorUpdater_js.js +0 -30
- package/updaters_fillColor_dist_browser_index_js.js +0 -30
- package/updaters_life_dist_browser_LifeUpdater_js.js +0 -70
- package/updaters_life_dist_browser_index_js.js +0 -30
- package/updaters_opacity_dist_browser_OpacityUpdater_js.js +0 -30
- package/updaters_opacity_dist_browser_index_js.js +0 -30
- package/updaters_outModes_dist_browser_OutOfCanvasUpdater_js.js +0 -80
- package/updaters_outModes_dist_browser_index_js.js +0 -30
- package/updaters_rotate_dist_browser_RotateUpdater_js.js +0 -50
- package/updaters_rotate_dist_browser_index_js.js +0 -30
- package/updaters_size_dist_browser_SizeUpdater_js.js +0 -30
- package/updaters_size_dist_browser_index_js.js +0 -30
- package/updaters_strokeColor_dist_browser_StrokeColorUpdater_js.js +0 -30
- package/updaters_strokeColor_dist_browser_index_js.js +0 -30
package/README.md
CHANGED
|
@@ -4,8 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
[](https://www.jsdelivr.com/package/npm/@tsparticles/fireworks) [](https://www.npmjs.com/package/@tsparticles/fireworks) [](https://www.npmjs.com/package/@tsparticles/fireworks) [](https://github.com/sponsors/matteobruni)
|
|
6
6
|
|
|
7
|
-
[tsParticles](https://github.com/tsparticles/tsparticles) fireworks bundle
|
|
8
|
-
beautiful fireworks effects with ease.
|
|
7
|
+
[tsParticles](https://github.com/tsparticles/tsparticles) fireworks bundle to create fireworks effects with a focused API.
|
|
9
8
|
|
|
10
9
|
**Included Packages**
|
|
11
10
|
|
|
@@ -13,10 +12,12 @@ beautiful fireworks effects with ease.
|
|
|
13
12
|
- [@tsparticles/engine](https://github.com/tsparticles/tsparticles/tree/main/engine)
|
|
14
13
|
- [@tsparticles/plugin-blend](https://github.com/tsparticles/tsparticles/tree/main/plugins/blend)
|
|
15
14
|
- [@tsparticles/plugin-emitters](https://github.com/tsparticles/tsparticles/tree/main/plugins/emitters)
|
|
16
|
-
- [@tsparticles/plugin-emitters-shape-square](https://github.com/tsparticles/tsparticles/tree/main/plugins/
|
|
15
|
+
- [@tsparticles/plugin-emitters-shape-square](https://github.com/tsparticles/tsparticles/tree/main/plugins/emittersShapes/square)
|
|
17
16
|
- [@tsparticles/plugin-sounds](https://github.com/tsparticles/tsparticles/tree/main/plugins/sounds)
|
|
17
|
+
- [@tsparticles/shape-line](https://github.com/tsparticles/tsparticles/tree/main/shapes/line)
|
|
18
18
|
- [@tsparticles/updater-destroy](https://github.com/tsparticles/tsparticles/tree/main/updaters/destroy)
|
|
19
19
|
- [@tsparticles/updater-life](https://github.com/tsparticles/tsparticles/tree/main/updaters/life)
|
|
20
|
+
- [@tsparticles/updater-paint](https://github.com/tsparticles/tsparticles/tree/main/updaters/paint)
|
|
20
21
|
- [@tsparticles/updater-rotate](https://github.com/tsparticles/tsparticles/tree/main/updaters/rotate)
|
|
21
22
|
|
|
22
23
|
## Dependency Graph
|
|
@@ -43,40 +44,98 @@ end
|
|
|
43
44
|
subgraph u [Updaters]
|
|
44
45
|
ud[tsparticles/updater-destroy]
|
|
45
46
|
ul[tsparticles/updater-life]
|
|
47
|
+
up[tsparticles/updater-paint]
|
|
46
48
|
ur[tsparticles/updater-rotate]
|
|
47
49
|
end
|
|
48
50
|
|
|
51
|
+
subgraph s [Shapes]
|
|
52
|
+
sl[tsparticles/shape-line]
|
|
53
|
+
end
|
|
54
|
+
|
|
49
55
|
bf --> bb
|
|
50
56
|
bf --> ce
|
|
51
|
-
bf --> e
|
|
52
57
|
bf --> p
|
|
58
|
+
bf --> s
|
|
53
59
|
bf --> u
|
|
54
60
|
```
|
|
55
61
|
|
|
56
|
-
##
|
|
62
|
+
## Exposed API
|
|
63
|
+
|
|
64
|
+
The package API is centered on `fireworks`.
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
import { fireworks } from "@tsparticles/fireworks";
|
|
57
68
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
69
|
+
// Main API
|
|
70
|
+
const instance = await fireworks();
|
|
71
|
+
const byId = await fireworks("canvas-id", options);
|
|
72
|
+
const byOptions = await fireworks(options);
|
|
73
|
+
|
|
74
|
+
// Extra helpers
|
|
75
|
+
await fireworks.init();
|
|
76
|
+
const custom = await fireworks.create(canvas, options);
|
|
77
|
+
|
|
78
|
+
console.log(fireworks.version);
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
`@tsparticles/fireworks` does not expose `tsParticles` from its main entrypoint.
|
|
82
|
+
If you need direct engine APIs, import them from `@tsparticles/engine`.
|
|
83
|
+
|
|
84
|
+
## Installation
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
pnpm add @tsparticles/fireworks
|
|
88
|
+
```
|
|
61
89
|
|
|
62
90
|
## How to use it
|
|
63
91
|
|
|
92
|
+
### ESM / TypeScript
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
import { fireworks } from "@tsparticles/fireworks";
|
|
96
|
+
|
|
97
|
+
const instance = await fireworks({
|
|
98
|
+
colors: ["#ffffff", "#ff0000"],
|
|
99
|
+
sounds: false,
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
instance?.pause();
|
|
103
|
+
instance?.play();
|
|
104
|
+
instance?.stop();
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
With explicit canvas id:
|
|
108
|
+
|
|
109
|
+
```ts
|
|
110
|
+
import { fireworks } from "@tsparticles/fireworks";
|
|
111
|
+
|
|
112
|
+
await fireworks("tsparticles", {
|
|
113
|
+
rate: 3,
|
|
114
|
+
speed: { min: 10, max: 25 },
|
|
115
|
+
});
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Custom canvas via `fireworks.create`
|
|
119
|
+
|
|
120
|
+
```ts
|
|
121
|
+
import { fireworks } from "@tsparticles/fireworks";
|
|
122
|
+
|
|
123
|
+
const canvas = document.getElementById("my-canvas") as HTMLCanvasElement;
|
|
124
|
+
await fireworks.create(canvas, { sounds: true });
|
|
125
|
+
```
|
|
126
|
+
|
|
64
127
|
### CDN / Vanilla JS / jQuery
|
|
65
128
|
|
|
66
|
-
The CDN/Vanilla version
|
|
129
|
+
The CDN/Vanilla JS version has two files:
|
|
67
130
|
|
|
68
131
|
- One is a bundle file with all the scripts included in a single file
|
|
69
|
-
- One
|
|
70
|
-
be
|
|
71
|
-
included manually
|
|
72
|
-
|
|
73
|
-
#### Bundle
|
|
132
|
+
- One includes only the `fireworks` API, where dependencies must be loaded manually
|
|
74
133
|
|
|
75
|
-
|
|
134
|
+
After loading the bundle, `fireworks` is available on `globalThis`.
|
|
76
135
|
|
|
77
|
-
|
|
136
|
+
#### Bundle
|
|
78
137
|
|
|
79
|
-
|
|
138
|
+
Use the bundle when you want a single script with all required dependencies.
|
|
80
139
|
|
|
81
140
|
#### Not Bundle
|
|
82
141
|
|
|
@@ -85,47 +144,33 @@ specified in the **Included Packages** section.
|
|
|
85
144
|
|
|
86
145
|
### Usage
|
|
87
146
|
|
|
88
|
-
Once the scripts are loaded you can set up `tsParticles` like the following examples:
|
|
89
|
-
|
|
90
|
-
** Easiest Way **
|
|
91
|
-
|
|
92
147
|
```javascript
|
|
93
148
|
fireworks();
|
|
94
149
|
```
|
|
95
150
|
|
|
96
|
-
** Async Way, best practice **
|
|
97
|
-
|
|
98
151
|
```javascript
|
|
99
152
|
(async () => {
|
|
100
|
-
await fireworks();
|
|
153
|
+
const instance = await fireworks();
|
|
154
|
+
|
|
155
|
+
instance?.pause();
|
|
156
|
+
instance?.play();
|
|
157
|
+
instance?.stop();
|
|
101
158
|
})();
|
|
102
159
|
```
|
|
103
160
|
|
|
104
|
-
** Custom Canvas **
|
|
105
|
-
|
|
106
161
|
```javascript
|
|
107
162
|
fireworks.create(document.getElementById("custom-id"));
|
|
108
163
|
```
|
|
109
164
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
```javascript
|
|
113
|
-
fireworks({
|
|
114
|
-
colors: ["#ffffff", "#ff0000"],
|
|
115
|
-
});
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
** Custom Canvas with Options **
|
|
165
|
+
#### Options
|
|
119
166
|
|
|
120
|
-
|
|
121
|
-
fireworks.create(document.getElementById("custom-id"), {
|
|
122
|
-
colors: ["#ffffff", "#ff0000"],
|
|
123
|
-
});
|
|
124
|
-
```
|
|
167
|
+
`fireworks` supports these call signatures:
|
|
125
168
|
|
|
126
|
-
|
|
169
|
+
- `fireworks()`
|
|
170
|
+
- `fireworks(options)`
|
|
171
|
+
- `fireworks(id, options)`
|
|
127
172
|
|
|
128
|
-
|
|
173
|
+
Main options:
|
|
129
174
|
|
|
130
175
|
- `background` String: The background color of the canvas, it can be any valid CSS color, can be transparent as well.
|
|
131
176
|
- `brightness` Number or { min: number; max: number; }: The brightness offset applied to the particles color, from -100
|
|
@@ -141,11 +186,19 @@ The `fireworks` has only a single `options` object parameter, with the following
|
|
|
141
186
|
- `speed` Number or { min: number; max: number; }: The speed of the fireworks particles.
|
|
142
187
|
- `splitCount` Number or { min: number; max: number; }: The number of particles to split the emitter in.
|
|
143
188
|
|
|
189
|
+
### Returned instance methods
|
|
190
|
+
|
|
191
|
+
The resolved `FireworksInstance` exposes:
|
|
192
|
+
|
|
193
|
+
- `pause()`
|
|
194
|
+
- `play()`
|
|
195
|
+
- `stop()`
|
|
196
|
+
|
|
144
197
|
## Common pitfalls
|
|
145
198
|
|
|
146
|
-
- Calling `
|
|
147
|
-
-
|
|
148
|
-
-
|
|
199
|
+
- Calling `fireworks` before scripts are loaded in CDN usage
|
|
200
|
+
- Assuming `tsParticles` is exported by `@tsparticles/fireworks` main entrypoint
|
|
201
|
+
- Reusing the same `id` unintentionally (the package caches instances by id)
|
|
149
202
|
|
|
150
203
|
## Related docs
|
|
151
204
|
|
package/browser/bundle.js
CHANGED
package/browser/fireworks.js
CHANGED
|
@@ -1,230 +1,45 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
clearInterval(interval);
|
|
19
|
-
resolve();
|
|
20
|
-
}, timeout);
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
initializing = true;
|
|
24
|
-
engine.checkVersion("4.0.0-beta.9");
|
|
1
|
+
import { isString, tsParticles } from "@tsparticles/engine";
|
|
2
|
+
import { getFireworksInstance } from "./utils.js";
|
|
3
|
+
import { loadBasic } from "@tsparticles/basic";
|
|
4
|
+
import { loadBlendPlugin } from "@tsparticles/plugin-blend";
|
|
5
|
+
import { loadDestroyUpdater } from "@tsparticles/updater-destroy";
|
|
6
|
+
import { loadEmittersPluginSimple } from "@tsparticles/plugin-emitters/plugin";
|
|
7
|
+
import { loadEmittersShapeSquare } from "@tsparticles/plugin-emitters-shape-square";
|
|
8
|
+
import { loadLifeUpdater } from "@tsparticles/updater-life";
|
|
9
|
+
import { loadLineShape } from "@tsparticles/shape-line";
|
|
10
|
+
import { loadPaintUpdater } from "@tsparticles/updater-paint";
|
|
11
|
+
import { loadRotateUpdater } from "@tsparticles/updater-rotate";
|
|
12
|
+
import { loadSoundsPlugin } from "@tsparticles/plugin-sounds";
|
|
13
|
+
let initPromise = null;
|
|
14
|
+
async function doInitPlugins(engine) {
|
|
15
|
+
engine.checkVersion("4.0.0");
|
|
25
16
|
await engine.pluginManager.register(async (e) => {
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
import("@tsparticles/plugin-emitters/plugin"),
|
|
31
|
-
import("@tsparticles/plugin-emitters-shape-square"),
|
|
32
|
-
import("@tsparticles/plugin-sounds"),
|
|
33
|
-
import("@tsparticles/updater-rotate"),
|
|
34
|
-
import("@tsparticles/updater-destroy"),
|
|
35
|
-
import("@tsparticles/updater-life"),
|
|
36
|
-
import("@tsparticles/updater-stroke-color"),
|
|
37
|
-
]);
|
|
17
|
+
const loadEmittersForFireworks = async (e) => {
|
|
18
|
+
await loadEmittersPluginSimple(e);
|
|
19
|
+
await loadEmittersShapeSquare(e);
|
|
20
|
+
};
|
|
38
21
|
await Promise.all([
|
|
39
22
|
loadBasic(e),
|
|
40
23
|
loadLineShape(e),
|
|
41
24
|
loadBlendPlugin(e),
|
|
42
|
-
(
|
|
43
|
-
await loadEmittersPluginSimple(e);
|
|
44
|
-
await loadEmittersShapeSquare(e);
|
|
45
|
-
})(),
|
|
25
|
+
loadEmittersForFireworks(e),
|
|
46
26
|
loadSoundsPlugin(e),
|
|
47
27
|
loadRotateUpdater(e),
|
|
48
28
|
loadDestroyUpdater(e),
|
|
49
29
|
loadLifeUpdater(e),
|
|
50
|
-
|
|
30
|
+
loadPaintUpdater(e),
|
|
51
31
|
]);
|
|
52
32
|
});
|
|
53
|
-
initializing = false;
|
|
54
|
-
initialized = true;
|
|
55
33
|
}
|
|
56
|
-
function
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
detectRetina: true,
|
|
60
|
-
background: {
|
|
61
|
-
color: options.background,
|
|
62
|
-
},
|
|
63
|
-
blend: {
|
|
64
|
-
enable: true,
|
|
65
|
-
mode: "lighter",
|
|
66
|
-
},
|
|
67
|
-
fullScreen: {
|
|
68
|
-
enable: !canvas,
|
|
69
|
-
},
|
|
70
|
-
fpsLimit: 60,
|
|
71
|
-
emitters: {
|
|
72
|
-
direction: MoveDirection.top,
|
|
73
|
-
life: {
|
|
74
|
-
count: 0,
|
|
75
|
-
duration: 0.1,
|
|
76
|
-
delay: 0.1,
|
|
77
|
-
},
|
|
78
|
-
rate: {
|
|
79
|
-
delay: isNumber(options.rate)
|
|
80
|
-
? identity / options.rate
|
|
81
|
-
: { min: identity / getRangeMin(options.rate), max: identity / getRangeMax(options.rate) },
|
|
82
|
-
quantity: 1,
|
|
83
|
-
},
|
|
84
|
-
size: {
|
|
85
|
-
width: 100,
|
|
86
|
-
height: 0,
|
|
87
|
-
},
|
|
88
|
-
position: {
|
|
89
|
-
y: 100,
|
|
90
|
-
x: 50,
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
particles: {
|
|
94
|
-
number: {
|
|
95
|
-
value: 0,
|
|
96
|
-
},
|
|
97
|
-
stroke: {
|
|
98
|
-
color: {
|
|
99
|
-
value: options.colors,
|
|
100
|
-
},
|
|
101
|
-
width: 2,
|
|
102
|
-
},
|
|
103
|
-
destroy: {
|
|
104
|
-
mode: "split",
|
|
105
|
-
bounds: {
|
|
106
|
-
top: setRangeValue(options.minHeight),
|
|
107
|
-
},
|
|
108
|
-
split: {
|
|
109
|
-
count: 1,
|
|
110
|
-
factor: {
|
|
111
|
-
value: 0.333333,
|
|
112
|
-
},
|
|
113
|
-
rate: {
|
|
114
|
-
value: options.splitCount,
|
|
115
|
-
},
|
|
116
|
-
strokeColorOffset: {
|
|
117
|
-
s: options.saturation,
|
|
118
|
-
l: options.brightness,
|
|
119
|
-
},
|
|
120
|
-
particles: {
|
|
121
|
-
group: "split",
|
|
122
|
-
number: {
|
|
123
|
-
value: 0,
|
|
124
|
-
},
|
|
125
|
-
opacity: {
|
|
126
|
-
value: {
|
|
127
|
-
min: 0.1,
|
|
128
|
-
max: 1,
|
|
129
|
-
},
|
|
130
|
-
animation: {
|
|
131
|
-
enable: true,
|
|
132
|
-
speed: { min: 2, max: 4 },
|
|
133
|
-
sync: true,
|
|
134
|
-
startValue: StartValueType.max,
|
|
135
|
-
destroy: DestroyType.min,
|
|
136
|
-
count: 1,
|
|
137
|
-
},
|
|
138
|
-
},
|
|
139
|
-
size: {
|
|
140
|
-
value: { min: 5, max: 10 },
|
|
141
|
-
},
|
|
142
|
-
life: {
|
|
143
|
-
count: 1,
|
|
144
|
-
duration: {
|
|
145
|
-
value: {
|
|
146
|
-
min: 0.5,
|
|
147
|
-
max: 1,
|
|
148
|
-
},
|
|
149
|
-
},
|
|
150
|
-
},
|
|
151
|
-
move: {
|
|
152
|
-
decay: 0.05,
|
|
153
|
-
enable: true,
|
|
154
|
-
gravity: {
|
|
155
|
-
enable: false,
|
|
156
|
-
},
|
|
157
|
-
speed: {
|
|
158
|
-
min: 10,
|
|
159
|
-
max: 25,
|
|
160
|
-
},
|
|
161
|
-
direction: "outside",
|
|
162
|
-
outModes: OutMode.destroy,
|
|
163
|
-
},
|
|
164
|
-
},
|
|
165
|
-
},
|
|
166
|
-
},
|
|
167
|
-
life: {
|
|
168
|
-
count: 1,
|
|
169
|
-
},
|
|
170
|
-
shape: {
|
|
171
|
-
type: "line",
|
|
172
|
-
options: {
|
|
173
|
-
line: {
|
|
174
|
-
cap: "round",
|
|
175
|
-
},
|
|
176
|
-
},
|
|
177
|
-
},
|
|
178
|
-
size: {
|
|
179
|
-
value: { min: 10, max: 20 },
|
|
180
|
-
},
|
|
181
|
-
rotate: {
|
|
182
|
-
path: true,
|
|
183
|
-
},
|
|
184
|
-
move: {
|
|
185
|
-
enable: true,
|
|
186
|
-
gravity: {
|
|
187
|
-
acceleration: setRangeValue(options.gravity),
|
|
188
|
-
enable: true,
|
|
189
|
-
inverse: true,
|
|
190
|
-
maxSpeed: 150,
|
|
191
|
-
},
|
|
192
|
-
speed: setRangeValue(options.speed),
|
|
193
|
-
outModes: {
|
|
194
|
-
default: OutMode.destroy,
|
|
195
|
-
top: OutMode.none,
|
|
196
|
-
},
|
|
197
|
-
},
|
|
198
|
-
},
|
|
199
|
-
sounds: {
|
|
200
|
-
enable: options.sounds,
|
|
201
|
-
events: [
|
|
202
|
-
{
|
|
203
|
-
event: EventType.particleRemoved,
|
|
204
|
-
filter: explodeSoundCheck,
|
|
205
|
-
audio: [
|
|
206
|
-
"https://particles.js.org/audio/explosion0.mp3",
|
|
207
|
-
"https://particles.js.org/audio/explosion1.mp3",
|
|
208
|
-
"https://particles.js.org/audio/explosion2.mp3",
|
|
209
|
-
],
|
|
210
|
-
},
|
|
211
|
-
],
|
|
212
|
-
volume: 50,
|
|
213
|
-
},
|
|
214
|
-
};
|
|
215
|
-
}
|
|
216
|
-
async function getFireworksInstance(id, sourceOptions, canvas) {
|
|
217
|
-
await initPlugins(tsParticles);
|
|
218
|
-
const options = new FireworkOptions();
|
|
219
|
-
options.load(sourceOptions);
|
|
220
|
-
const particlesOptions = getOptions(options, canvas), container = await tsParticles.load({ id, element: canvas, options: particlesOptions });
|
|
221
|
-
if (!container) {
|
|
222
|
-
return;
|
|
34
|
+
async function initPlugins(engine) {
|
|
35
|
+
if (initPromise) {
|
|
36
|
+
return initPromise;
|
|
223
37
|
}
|
|
224
|
-
|
|
225
|
-
return
|
|
38
|
+
initPromise = doInitPlugins(engine);
|
|
39
|
+
return initPromise;
|
|
226
40
|
}
|
|
227
41
|
export async function fireworks(idOrOptions, sourceOptions) {
|
|
42
|
+
await initPlugins(tsParticles);
|
|
228
43
|
let id, options;
|
|
229
44
|
if (isString(idOrOptions)) {
|
|
230
45
|
id = idOrOptions;
|
|
@@ -234,14 +49,15 @@ export async function fireworks(idOrOptions, sourceOptions) {
|
|
|
234
49
|
id = "fireworks";
|
|
235
50
|
options = idOrOptions ?? {};
|
|
236
51
|
}
|
|
237
|
-
return getFireworksInstance(id, options);
|
|
52
|
+
return getFireworksInstance(tsParticles, id, options);
|
|
238
53
|
}
|
|
239
54
|
fireworks.create = async (canvas, options) => {
|
|
240
|
-
|
|
241
|
-
|
|
55
|
+
await initPlugins(tsParticles);
|
|
56
|
+
const id = canvas?.id ?? "fireworks";
|
|
57
|
+
return getFireworksInstance(tsParticles, id, options ?? {}, canvas ?? undefined);
|
|
242
58
|
};
|
|
243
59
|
fireworks.init = async () => {
|
|
244
60
|
await initPlugins(tsParticles);
|
|
245
61
|
};
|
|
246
|
-
fireworks.version = "4.0.0
|
|
62
|
+
fireworks.version = "4.0.0";
|
|
247
63
|
globalThis.fireworks = fireworks;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { isString, tsParticles } from "@tsparticles/engine/lazy";
|
|
2
|
+
import { getFireworksInstance } from "./utils.js";
|
|
3
|
+
let initPromise = null;
|
|
4
|
+
async function doInitPlugins(engine) {
|
|
5
|
+
engine.checkVersion("4.0.0");
|
|
6
|
+
await engine.pluginManager.register(async (e) => {
|
|
7
|
+
const [{ loadBasic }, { loadLineShape }, { loadBlendPlugin }, { loadEmittersPluginSimple }, { loadEmittersShapeSquare }, { loadSoundsPlugin }, { loadRotateUpdater }, { loadDestroyUpdater }, { loadLifeUpdater }, { loadPaintUpdater },] = await Promise.all([
|
|
8
|
+
import("@tsparticles/basic/lazy"),
|
|
9
|
+
import("@tsparticles/shape-line"),
|
|
10
|
+
import("@tsparticles/plugin-blend"),
|
|
11
|
+
import("@tsparticles/plugin-emitters/plugin"),
|
|
12
|
+
import("@tsparticles/plugin-emitters-shape-square"),
|
|
13
|
+
import("@tsparticles/plugin-sounds"),
|
|
14
|
+
import("@tsparticles/updater-rotate/lazy"),
|
|
15
|
+
import("@tsparticles/updater-destroy/lazy"),
|
|
16
|
+
import("@tsparticles/updater-life/lazy"),
|
|
17
|
+
import("@tsparticles/updater-paint/lazy"),
|
|
18
|
+
]), loadEmittersForFireworks = async (e) => {
|
|
19
|
+
await loadEmittersPluginSimple(e);
|
|
20
|
+
await loadEmittersShapeSquare(e);
|
|
21
|
+
};
|
|
22
|
+
await Promise.all([
|
|
23
|
+
loadBasic(e),
|
|
24
|
+
loadLineShape(e),
|
|
25
|
+
loadBlendPlugin(e),
|
|
26
|
+
loadEmittersForFireworks(e),
|
|
27
|
+
loadSoundsPlugin(e),
|
|
28
|
+
loadRotateUpdater(e),
|
|
29
|
+
loadDestroyUpdater(e),
|
|
30
|
+
loadLifeUpdater(e),
|
|
31
|
+
loadPaintUpdater(e),
|
|
32
|
+
]);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
async function initPlugins(engine) {
|
|
36
|
+
if (initPromise) {
|
|
37
|
+
return initPromise;
|
|
38
|
+
}
|
|
39
|
+
initPromise = doInitPlugins(engine);
|
|
40
|
+
return initPromise;
|
|
41
|
+
}
|
|
42
|
+
export async function fireworks(idOrOptions, sourceOptions) {
|
|
43
|
+
await initPlugins(tsParticles);
|
|
44
|
+
let id, options;
|
|
45
|
+
if (isString(idOrOptions)) {
|
|
46
|
+
id = idOrOptions;
|
|
47
|
+
options = sourceOptions ?? {};
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
id = "fireworks";
|
|
51
|
+
options = idOrOptions ?? {};
|
|
52
|
+
}
|
|
53
|
+
return getFireworksInstance(tsParticles, id, options);
|
|
54
|
+
}
|
|
55
|
+
fireworks.create = async (canvas, options) => {
|
|
56
|
+
await initPlugins(tsParticles);
|
|
57
|
+
const id = canvas?.id ?? "fireworks";
|
|
58
|
+
return getFireworksInstance(tsParticles, id, options ?? {}, canvas ?? undefined);
|
|
59
|
+
};
|
|
60
|
+
fireworks.init = async () => {
|
|
61
|
+
await initPlugins(tsParticles);
|
|
62
|
+
};
|
|
63
|
+
fireworks.version = "4.0.0";
|
|
64
|
+
globalThis.fireworks = fireworks;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./fireworks.lazy.js";
|
package/browser/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|