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