@tsparticles/preset-fireworks 3.0.2 → 3.2.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 +11 -7
- package/browser/bundle.js +0 -1
- package/browser/index.js +3 -2
- package/browser/options.js +197 -191
- package/cjs/bundle.js +0 -1
- package/cjs/index.js +3 -2
- package/cjs/options.js +198 -191
- package/esm/bundle.js +0 -1
- package/esm/index.js +3 -2
- package/esm/options.js +197 -191
- package/package.json +11 -11
- package/report.html +3 -3
- package/tsparticles.preset.fireworks.bundle.js +2818 -8444
- package/tsparticles.preset.fireworks.bundle.min.js +1 -1
- package/tsparticles.preset.fireworks.bundle.min.js.LICENSE.txt +1 -1
- package/tsparticles.preset.fireworks.js +101 -313
- package/tsparticles.preset.fireworks.min.js +1 -1
- package/tsparticles.preset.fireworks.min.js.LICENSE.txt +1 -1
- package/types/options.d.ts +2 -2
- package/umd/bundle.js +0 -1
- package/umd/index.js +4 -3
- package/umd/options.js +198 -191
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
[tsParticles](https://github.com/tsparticles/tsparticles) preset for fireworks effect.
|
|
8
8
|
|
|
9
|
-
[](https://discord.gg/hACwv45Hme) [](https://t.me/tsparticles)
|
|
10
10
|
|
|
11
11
|
[](https://www.producthunt.com/posts/tsparticles?utm_source=badge-featured&utm_medium=badge&utm_souce=badge-tsparticles") <a href="https://www.buymeacoffee.com/matteobruni"><img src="https://img.buymeacoffee.com/button-api/?text=Buy me a beer&emoji=🍺&slug=matteobruni&button_colour=5F7FFF&font_colour=ffffff&font_family=Arial&outline_colour=000000&coffee_colour=FFDD00"></a>
|
|
12
12
|
|
|
@@ -27,12 +27,16 @@
|
|
|
27
27
|
Once the scripts are loaded you can set up `tsParticles` like this:
|
|
28
28
|
|
|
29
29
|
```javascript
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
(async () => {
|
|
31
|
+
await loadFireworksPreset(tsParticles);
|
|
32
|
+
|
|
33
|
+
await tsParticles.load({
|
|
34
|
+
id: "tsparticles",
|
|
35
|
+
options: {
|
|
36
|
+
preset: "fireworks",
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
})();
|
|
36
40
|
```
|
|
37
41
|
|
|
38
42
|
#### Customization
|
package/browser/bundle.js
CHANGED
package/browser/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { initOptions } from "./options.js";
|
|
1
2
|
import { loadBasic } from "@tsparticles/basic";
|
|
2
3
|
import { loadDestroyUpdater } from "@tsparticles/updater-destroy";
|
|
3
4
|
import { loadEmittersPlugin } from "@tsparticles/plugin-emitters";
|
|
@@ -7,7 +8,6 @@ import { loadLineShape } from "@tsparticles/shape-line";
|
|
|
7
8
|
import { loadRotateUpdater } from "@tsparticles/updater-rotate";
|
|
8
9
|
import { loadSoundsPlugin } from "@tsparticles/plugin-sounds";
|
|
9
10
|
import { loadStrokeColorUpdater } from "@tsparticles/updater-stroke-color";
|
|
10
|
-
import { options } from "./options.js";
|
|
11
11
|
export async function loadFireworksPreset(engine, refresh = true) {
|
|
12
12
|
await loadBasic(engine, false);
|
|
13
13
|
await loadEmittersPlugin(engine, false);
|
|
@@ -18,5 +18,6 @@ export async function loadFireworksPreset(engine, refresh = true) {
|
|
|
18
18
|
await loadDestroyUpdater(engine, false);
|
|
19
19
|
await loadLifeUpdater(engine, false);
|
|
20
20
|
await loadStrokeColorUpdater(engine, false);
|
|
21
|
-
await engine.addPreset("fireworks",
|
|
21
|
+
await engine.addPreset("fireworks", initOptions(engine), false);
|
|
22
|
+
await engine.refresh(refresh);
|
|
22
23
|
}
|
package/browser/options.js
CHANGED
|
@@ -1,211 +1,217 @@
|
|
|
1
|
-
import { rgbToHsl, setRangeValue, stringToRgb, } from "@tsparticles/engine";
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
value: 0,
|
|
44
|
-
},
|
|
45
|
-
opacity: {
|
|
46
|
-
value: {
|
|
47
|
-
min: 0.1,
|
|
48
|
-
max: 1,
|
|
1
|
+
import { DestroyType, EventType, MoveDirection, OutMode, StartValueType, rgbToHsl, setRangeValue, stringToRgb, } from "@tsparticles/engine";
|
|
2
|
+
export function initOptions(engine) {
|
|
3
|
+
const explodeSoundCheck = (args) => {
|
|
4
|
+
const data = args.data;
|
|
5
|
+
return data.particle.shape === "line";
|
|
6
|
+
}, fixRange = (value, min, max) => {
|
|
7
|
+
const minValue = 0, diffSMax = value.max > max ? value.max - max : minValue;
|
|
8
|
+
let res = setRangeValue(value);
|
|
9
|
+
if (diffSMax) {
|
|
10
|
+
res = setRangeValue(value.min - diffSMax, max);
|
|
11
|
+
}
|
|
12
|
+
const diffSMin = value.min < min ? value.min : minValue;
|
|
13
|
+
if (diffSMin) {
|
|
14
|
+
res = setRangeValue(minValue, value.max + diffSMin);
|
|
15
|
+
}
|
|
16
|
+
return res;
|
|
17
|
+
}, fireworksOptions = [
|
|
18
|
+
"#ff595e",
|
|
19
|
+
"#ffca3a",
|
|
20
|
+
"#8ac926",
|
|
21
|
+
"#1982c4",
|
|
22
|
+
"#6a4c93",
|
|
23
|
+
]
|
|
24
|
+
.map(color => {
|
|
25
|
+
const rgb = stringToRgb(engine, color);
|
|
26
|
+
if (!rgb) {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
const hsl = rgbToHsl(rgb), sOffset = 30, lOffset = 30, sBounds = {
|
|
30
|
+
min: 0,
|
|
31
|
+
max: 100,
|
|
32
|
+
}, lBounds = {
|
|
33
|
+
min: 0,
|
|
34
|
+
max: 100,
|
|
35
|
+
}, sRange = fixRange({ min: hsl.s - sOffset, max: hsl.s + sOffset }, sBounds.min, sBounds.max), lRange = fixRange({ min: hsl.l - lOffset, max: hsl.l + lOffset }, lBounds.min, lBounds.max);
|
|
36
|
+
return {
|
|
37
|
+
color: {
|
|
38
|
+
value: {
|
|
39
|
+
h: hsl.h,
|
|
40
|
+
s: sRange,
|
|
41
|
+
l: lRange,
|
|
42
|
+
},
|
|
49
43
|
},
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
speed: 0.7,
|
|
53
|
-
sync: false,
|
|
54
|
-
startValue: "max",
|
|
55
|
-
destroy: "min",
|
|
44
|
+
stroke: {
|
|
45
|
+
width: 0,
|
|
56
46
|
},
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
type: "circle",
|
|
60
|
-
},
|
|
61
|
-
size: {
|
|
62
|
-
value: { min: 1, max: 2 },
|
|
63
|
-
animation: {
|
|
64
|
-
enable: true,
|
|
65
|
-
speed: 5,
|
|
66
|
-
count: 1,
|
|
67
|
-
sync: false,
|
|
68
|
-
startValue: "min",
|
|
69
|
-
destroy: "none",
|
|
47
|
+
number: {
|
|
48
|
+
value: 0,
|
|
70
49
|
},
|
|
71
|
-
|
|
72
|
-
life: {
|
|
73
|
-
count: 1,
|
|
74
|
-
duration: {
|
|
50
|
+
opacity: {
|
|
75
51
|
value: {
|
|
76
|
-
min: 1,
|
|
77
|
-
max:
|
|
52
|
+
min: 0.1,
|
|
53
|
+
max: 1,
|
|
54
|
+
},
|
|
55
|
+
animation: {
|
|
56
|
+
enable: true,
|
|
57
|
+
speed: 0.7,
|
|
58
|
+
sync: false,
|
|
59
|
+
startValue: StartValueType.max,
|
|
60
|
+
destroy: DestroyType.min,
|
|
78
61
|
},
|
|
79
62
|
},
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
};
|
|
94
|
-
})
|
|
95
|
-
.filter((t) => t !== undefined);
|
|
96
|
-
export const options = {
|
|
97
|
-
detectRetina: true,
|
|
98
|
-
background: {
|
|
99
|
-
color: "#000",
|
|
100
|
-
},
|
|
101
|
-
fpsLimit: 120,
|
|
102
|
-
emitters: {
|
|
103
|
-
direction: "top",
|
|
104
|
-
life: {
|
|
105
|
-
count: 0,
|
|
106
|
-
duration: 0.1,
|
|
107
|
-
delay: 0.1,
|
|
108
|
-
},
|
|
109
|
-
rate: {
|
|
110
|
-
delay: 0.05,
|
|
111
|
-
quantity: 1,
|
|
112
|
-
},
|
|
113
|
-
size: {
|
|
114
|
-
width: 100,
|
|
115
|
-
height: 0,
|
|
116
|
-
},
|
|
117
|
-
position: {
|
|
118
|
-
y: 100,
|
|
119
|
-
x: 50,
|
|
120
|
-
},
|
|
121
|
-
},
|
|
122
|
-
particles: {
|
|
123
|
-
number: {
|
|
124
|
-
value: 0,
|
|
125
|
-
},
|
|
126
|
-
destroy: {
|
|
127
|
-
mode: "split",
|
|
128
|
-
bounds: {
|
|
129
|
-
top: { min: 10, max: 30 },
|
|
63
|
+
shape: {
|
|
64
|
+
type: "circle",
|
|
65
|
+
},
|
|
66
|
+
size: {
|
|
67
|
+
value: { min: 1, max: 2 },
|
|
68
|
+
animation: {
|
|
69
|
+
enable: true,
|
|
70
|
+
speed: 5,
|
|
71
|
+
count: 1,
|
|
72
|
+
sync: false,
|
|
73
|
+
startValue: StartValueType.min,
|
|
74
|
+
destroy: DestroyType.none,
|
|
75
|
+
},
|
|
130
76
|
},
|
|
131
|
-
|
|
132
|
-
sizeOffset: false,
|
|
77
|
+
life: {
|
|
133
78
|
count: 1,
|
|
134
|
-
|
|
135
|
-
value:
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
79
|
+
duration: {
|
|
80
|
+
value: {
|
|
81
|
+
min: 1,
|
|
82
|
+
max: 2,
|
|
83
|
+
},
|
|
139
84
|
},
|
|
140
|
-
particles: fireworksOptions,
|
|
141
85
|
},
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
count: 1,
|
|
145
|
-
},
|
|
146
|
-
shape: {
|
|
147
|
-
type: "line",
|
|
148
|
-
},
|
|
149
|
-
size: {
|
|
150
|
-
value: {
|
|
151
|
-
min: 0.1,
|
|
152
|
-
max: 50,
|
|
153
|
-
},
|
|
154
|
-
animation: {
|
|
86
|
+
move: {
|
|
87
|
+
decay: { min: 0.075, max: 0.1 },
|
|
155
88
|
enable: true,
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
89
|
+
gravity: {
|
|
90
|
+
enable: true,
|
|
91
|
+
inverse: false,
|
|
92
|
+
acceleration: 5,
|
|
93
|
+
},
|
|
94
|
+
speed: { min: 5, max: 15 },
|
|
95
|
+
direction: "none",
|
|
96
|
+
outModes: OutMode.destroy,
|
|
160
97
|
},
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
98
|
+
};
|
|
99
|
+
})
|
|
100
|
+
.filter(t => t !== undefined);
|
|
101
|
+
return {
|
|
102
|
+
detectRetina: true,
|
|
103
|
+
background: {
|
|
104
|
+
color: "#000",
|
|
105
|
+
},
|
|
106
|
+
fpsLimit: 120,
|
|
107
|
+
emitters: {
|
|
108
|
+
direction: MoveDirection.top,
|
|
109
|
+
life: {
|
|
110
|
+
count: 0,
|
|
111
|
+
duration: 0.1,
|
|
112
|
+
delay: 0.1,
|
|
113
|
+
},
|
|
114
|
+
rate: {
|
|
115
|
+
delay: 0.05,
|
|
116
|
+
quantity: 1,
|
|
117
|
+
},
|
|
118
|
+
size: {
|
|
119
|
+
width: 100,
|
|
120
|
+
height: 0,
|
|
121
|
+
},
|
|
122
|
+
position: {
|
|
123
|
+
y: 100,
|
|
124
|
+
x: 50,
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
particles: {
|
|
128
|
+
number: {
|
|
129
|
+
value: 0,
|
|
130
|
+
},
|
|
131
|
+
destroy: {
|
|
132
|
+
mode: "split",
|
|
133
|
+
bounds: {
|
|
134
|
+
top: { min: 10, max: 30 },
|
|
135
|
+
},
|
|
136
|
+
split: {
|
|
137
|
+
sizeOffset: false,
|
|
138
|
+
count: 1,
|
|
139
|
+
factor: {
|
|
140
|
+
value: 0.333333,
|
|
141
|
+
},
|
|
142
|
+
rate: {
|
|
143
|
+
value: { min: 75, max: 150 },
|
|
144
|
+
},
|
|
145
|
+
particles: fireworksOptions,
|
|
146
|
+
},
|
|
165
147
|
},
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
rotate: {
|
|
169
|
-
path: true,
|
|
170
|
-
},
|
|
171
|
-
move: {
|
|
172
|
-
enable: true,
|
|
173
|
-
gravity: {
|
|
174
|
-
acceleration: 15,
|
|
175
|
-
enable: true,
|
|
176
|
-
inverse: true,
|
|
177
|
-
maxSpeed: 100,
|
|
148
|
+
life: {
|
|
149
|
+
count: 1,
|
|
178
150
|
},
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
max: 20,
|
|
151
|
+
shape: {
|
|
152
|
+
type: "line",
|
|
182
153
|
},
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
154
|
+
size: {
|
|
155
|
+
value: {
|
|
156
|
+
min: 0.1,
|
|
157
|
+
max: 50,
|
|
158
|
+
},
|
|
159
|
+
animation: {
|
|
160
|
+
enable: true,
|
|
161
|
+
sync: true,
|
|
162
|
+
speed: 90,
|
|
163
|
+
startValue: StartValueType.max,
|
|
164
|
+
destroy: DestroyType.min,
|
|
165
|
+
},
|
|
186
166
|
},
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
167
|
+
stroke: {
|
|
168
|
+
color: {
|
|
169
|
+
value: "#ffffff",
|
|
190
170
|
},
|
|
171
|
+
width: 1,
|
|
172
|
+
},
|
|
173
|
+
rotate: {
|
|
174
|
+
path: true,
|
|
175
|
+
},
|
|
176
|
+
move: {
|
|
191
177
|
enable: true,
|
|
192
|
-
|
|
178
|
+
gravity: {
|
|
179
|
+
acceleration: 15,
|
|
180
|
+
enable: true,
|
|
181
|
+
inverse: true,
|
|
182
|
+
maxSpeed: 100,
|
|
183
|
+
},
|
|
184
|
+
speed: {
|
|
185
|
+
min: 10,
|
|
186
|
+
max: 20,
|
|
187
|
+
},
|
|
188
|
+
outModes: {
|
|
189
|
+
default: OutMode.destroy,
|
|
190
|
+
top: OutMode.none,
|
|
191
|
+
},
|
|
192
|
+
trail: {
|
|
193
|
+
fill: {
|
|
194
|
+
color: "#000",
|
|
195
|
+
},
|
|
196
|
+
enable: true,
|
|
197
|
+
length: 10,
|
|
198
|
+
},
|
|
193
199
|
},
|
|
194
200
|
},
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
}
|
|
211
|
-
}
|
|
201
|
+
sounds: {
|
|
202
|
+
enable: true,
|
|
203
|
+
events: [
|
|
204
|
+
{
|
|
205
|
+
event: EventType.particleRemoved,
|
|
206
|
+
filter: explodeSoundCheck,
|
|
207
|
+
audio: [
|
|
208
|
+
"https://particles.js.org/audio/explosion0.mp3",
|
|
209
|
+
"https://particles.js.org/audio/explosion1.mp3",
|
|
210
|
+
"https://particles.js.org/audio/explosion2.mp3",
|
|
211
|
+
],
|
|
212
|
+
},
|
|
213
|
+
],
|
|
214
|
+
volume: 50,
|
|
215
|
+
},
|
|
216
|
+
};
|
|
217
|
+
}
|
package/cjs/bundle.js
CHANGED
|
@@ -5,4 +5,3 @@ const index_js_1 = require("./index.js");
|
|
|
5
5
|
Object.defineProperty(exports, "loadFireworksPreset", { enumerable: true, get: function () { return index_js_1.loadFireworksPreset; } });
|
|
6
6
|
const engine_1 = require("@tsparticles/engine");
|
|
7
7
|
Object.defineProperty(exports, "tsParticles", { enumerable: true, get: function () { return engine_1.tsParticles; } });
|
|
8
|
-
void (0, index_js_1.loadFireworksPreset)(engine_1.tsParticles);
|
package/cjs/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.loadFireworksPreset = void 0;
|
|
4
|
+
const options_js_1 = require("./options.js");
|
|
4
5
|
const basic_1 = require("@tsparticles/basic");
|
|
5
6
|
const updater_destroy_1 = require("@tsparticles/updater-destroy");
|
|
6
7
|
const plugin_emitters_1 = require("@tsparticles/plugin-emitters");
|
|
@@ -10,7 +11,6 @@ const shape_line_1 = require("@tsparticles/shape-line");
|
|
|
10
11
|
const updater_rotate_1 = require("@tsparticles/updater-rotate");
|
|
11
12
|
const plugin_sounds_1 = require("@tsparticles/plugin-sounds");
|
|
12
13
|
const updater_stroke_color_1 = require("@tsparticles/updater-stroke-color");
|
|
13
|
-
const options_js_1 = require("./options.js");
|
|
14
14
|
async function loadFireworksPreset(engine, refresh = true) {
|
|
15
15
|
await (0, basic_1.loadBasic)(engine, false);
|
|
16
16
|
await (0, plugin_emitters_1.loadEmittersPlugin)(engine, false);
|
|
@@ -21,6 +21,7 @@ async function loadFireworksPreset(engine, refresh = true) {
|
|
|
21
21
|
await (0, updater_destroy_1.loadDestroyUpdater)(engine, false);
|
|
22
22
|
await (0, updater_life_1.loadLifeUpdater)(engine, false);
|
|
23
23
|
await (0, updater_stroke_color_1.loadStrokeColorUpdater)(engine, false);
|
|
24
|
-
await engine.addPreset("fireworks", options_js_1.
|
|
24
|
+
await engine.addPreset("fireworks", (0, options_js_1.initOptions)(engine), false);
|
|
25
|
+
await engine.refresh(refresh);
|
|
25
26
|
}
|
|
26
27
|
exports.loadFireworksPreset = loadFireworksPreset;
|