@tsparticles/preset-fireworks 3.0.0-alpha.1

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/umd/options.js ADDED
@@ -0,0 +1,216 @@
1
+ (function (factory) {
2
+ if (typeof module === "object" && typeof module.exports === "object") {
3
+ var v = factory(require, exports);
4
+ if (v !== undefined) module.exports = v;
5
+ }
6
+ else if (typeof define === "function" && define.amd) {
7
+ define(["require", "exports", "@tsparticles/engine"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.options = void 0;
13
+ const engine_1 = require("@tsparticles/engine");
14
+ const explodeSoundCheck = (args) => {
15
+ const data = args.data;
16
+ return data.particle.shape === "line";
17
+ };
18
+ const fixRange = (value, min, max) => {
19
+ const diffSMax = value.max > max ? value.max - max : 0;
20
+ let res = (0, engine_1.setRangeValue)(value);
21
+ if (diffSMax) {
22
+ res = (0, engine_1.setRangeValue)(value.min - diffSMax, max);
23
+ }
24
+ const diffSMin = value.min < min ? value.min : 0;
25
+ if (diffSMin) {
26
+ res = (0, engine_1.setRangeValue)(0, value.max + diffSMin);
27
+ }
28
+ return res;
29
+ };
30
+ const fireworksOptions = ["#ff595e", "#ffca3a", "#8ac926", "#1982c4", "#6a4c93"]
31
+ .map((color) => {
32
+ const rgb = (0, engine_1.stringToRgb)(color);
33
+ if (!rgb) {
34
+ return undefined;
35
+ }
36
+ const hsl = (0, engine_1.rgbToHsl)(rgb), sRange = fixRange({ min: hsl.s - 30, max: hsl.s + 30 }, 0, 100), lRange = fixRange({ min: hsl.l - 30, max: hsl.l + 30 }, 0, 100);
37
+ return {
38
+ color: {
39
+ value: {
40
+ h: hsl.h,
41
+ s: sRange,
42
+ l: lRange,
43
+ },
44
+ },
45
+ stroke: {
46
+ width: 0,
47
+ },
48
+ number: {
49
+ value: 0,
50
+ },
51
+ opacity: {
52
+ value: {
53
+ min: 0.1,
54
+ max: 1,
55
+ },
56
+ animation: {
57
+ enable: true,
58
+ speed: 0.7,
59
+ sync: false,
60
+ startValue: "max",
61
+ destroy: "min",
62
+ },
63
+ },
64
+ shape: {
65
+ type: "circle",
66
+ },
67
+ size: {
68
+ value: { min: 1, max: 2 },
69
+ animation: {
70
+ enable: true,
71
+ speed: 5,
72
+ count: 1,
73
+ sync: false,
74
+ startValue: "min",
75
+ destroy: "none",
76
+ },
77
+ },
78
+ life: {
79
+ count: 1,
80
+ duration: {
81
+ value: {
82
+ min: 1,
83
+ max: 2,
84
+ },
85
+ },
86
+ },
87
+ move: {
88
+ decay: { min: 0.075, max: 0.1 },
89
+ enable: true,
90
+ gravity: {
91
+ enable: true,
92
+ inverse: false,
93
+ acceleration: 5,
94
+ },
95
+ speed: { min: 5, max: 15 },
96
+ direction: "none",
97
+ outModes: "destroy",
98
+ },
99
+ };
100
+ })
101
+ .filter((t) => t !== undefined);
102
+ exports.options = {
103
+ detectRetina: true,
104
+ background: {
105
+ color: "#000",
106
+ },
107
+ fpsLimit: 120,
108
+ emitters: {
109
+ direction: "top",
110
+ life: {
111
+ count: 0,
112
+ duration: 0.1,
113
+ delay: 0.1,
114
+ },
115
+ rate: {
116
+ delay: 0.05,
117
+ quantity: 1,
118
+ },
119
+ size: {
120
+ width: 100,
121
+ height: 0,
122
+ },
123
+ position: {
124
+ y: 100,
125
+ x: 50,
126
+ },
127
+ },
128
+ particles: {
129
+ number: {
130
+ value: 0,
131
+ },
132
+ destroy: {
133
+ mode: "split",
134
+ bounds: {
135
+ top: { min: 10, max: 30 },
136
+ },
137
+ split: {
138
+ sizeOffset: false,
139
+ count: 1,
140
+ factor: {
141
+ value: 0.333333,
142
+ },
143
+ rate: {
144
+ value: { min: 75, max: 150 },
145
+ },
146
+ particles: fireworksOptions,
147
+ },
148
+ },
149
+ life: {
150
+ count: 1,
151
+ },
152
+ shape: {
153
+ type: "line",
154
+ },
155
+ size: {
156
+ value: {
157
+ min: 0.1,
158
+ max: 50,
159
+ },
160
+ animation: {
161
+ enable: true,
162
+ sync: true,
163
+ speed: 90,
164
+ startValue: "max",
165
+ destroy: "min",
166
+ },
167
+ },
168
+ stroke: {
169
+ color: {
170
+ value: "#ffffff",
171
+ },
172
+ width: 1,
173
+ },
174
+ rotate: {
175
+ path: true,
176
+ },
177
+ move: {
178
+ enable: true,
179
+ gravity: {
180
+ acceleration: 15,
181
+ enable: true,
182
+ inverse: true,
183
+ maxSpeed: 100,
184
+ },
185
+ speed: {
186
+ min: 10,
187
+ max: 20,
188
+ },
189
+ outModes: {
190
+ default: "destroy",
191
+ top: "none",
192
+ },
193
+ trail: {
194
+ fillColor: "#000",
195
+ enable: true,
196
+ length: 10,
197
+ },
198
+ },
199
+ },
200
+ sounds: {
201
+ enable: true,
202
+ events: [
203
+ {
204
+ event: "particleRemoved",
205
+ filter: explodeSoundCheck,
206
+ audio: [
207
+ "https://particles.js.org/audio/explosion0.mp3",
208
+ "https://particles.js.org/audio/explosion1.mp3",
209
+ "https://particles.js.org/audio/explosion2.mp3",
210
+ ],
211
+ },
212
+ ],
213
+ volume: 50,
214
+ },
215
+ };
216
+ });