@tsparticles/updater-destroy 4.0.0-beta.8 → 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/browser/DestroyUpdater.js +44 -4
- package/browser/Enums/DestroyMode.js +1 -0
- package/browser/Options/Classes/Destroy.js +4 -0
- package/browser/Options/Classes/Explode.js +20 -0
- package/browser/Options/Interfaces/IExplode.js +1 -0
- package/browser/Utils.js +1 -1
- package/browser/browser.js +5 -0
- package/browser/index.js +4 -4
- package/browser/index.lazy.js +9 -0
- package/cjs/DestroyUpdater.js +44 -4
- package/cjs/Enums/DestroyMode.js +1 -0
- package/cjs/Options/Classes/Destroy.js +4 -0
- package/cjs/Options/Classes/Explode.js +20 -0
- package/cjs/Options/Interfaces/IExplode.js +1 -0
- package/cjs/Utils.js +1 -1
- package/cjs/browser.js +5 -0
- package/cjs/index.js +4 -4
- package/cjs/index.lazy.js +9 -0
- package/esm/DestroyUpdater.js +44 -4
- package/esm/Enums/DestroyMode.js +1 -0
- package/esm/Options/Classes/Destroy.js +4 -0
- package/esm/Options/Classes/Explode.js +20 -0
- package/esm/Options/Interfaces/IExplode.js +1 -0
- package/esm/Utils.js +1 -1
- package/esm/browser.js +5 -0
- package/esm/index.js +4 -4
- package/esm/index.lazy.js +9 -0
- package/package.json +9 -2
- package/report.html +4949 -94
- package/tsparticles.updater.destroy.js +371 -310
- package/tsparticles.updater.destroy.min.js +1 -2
- package/types/DestroyUpdater.d.ts +2 -2
- package/types/Enums/DestroyMode.d.ts +1 -0
- package/types/Options/Classes/Destroy.d.ts +2 -0
- package/types/Options/Classes/Explode.d.ts +8 -0
- package/types/Options/Interfaces/IDestroy.d.ts +2 -0
- package/types/Options/Interfaces/IExplode.d.ts +4 -0
- package/types/Types.d.ts +8 -0
- package/types/browser.d.ts +1 -0
- package/types/index.lazy.d.ts +2 -0
- package/960.min.js +0 -1
- package/dist_browser_DestroyUpdater_js.js +0 -100
|
@@ -1,317 +1,378 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*/
|
|
9
|
-
/*
|
|
10
|
-
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
11
|
-
* This devtool is neither made for production nor for readable output files.
|
|
12
|
-
* It uses "eval()" calls to create a separate source file in the browser devtools.
|
|
13
|
-
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
|
|
14
|
-
* or disable the default devtool with "devtool: false".
|
|
15
|
-
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
|
|
16
|
-
*/
|
|
17
|
-
(function webpackUniversalModuleDefinition(root, factory) {
|
|
18
|
-
if(typeof exports === 'object' && typeof module === 'object')
|
|
19
|
-
module.exports = factory(require("@tsparticles/engine"));
|
|
20
|
-
else if(typeof define === 'function' && define.amd)
|
|
21
|
-
define(["@tsparticles/engine"], factory);
|
|
22
|
-
else {
|
|
23
|
-
var a = typeof exports === 'object' ? factory(require("@tsparticles/engine")) : factory(root["window"]);
|
|
24
|
-
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
|
|
25
|
-
}
|
|
26
|
-
})(this, (__WEBPACK_EXTERNAL_MODULE__tsparticles_engine__) => {
|
|
27
|
-
return /******/ (() => { // webpackBootstrap
|
|
28
|
-
/******/ "use strict";
|
|
29
|
-
/******/ var __webpack_modules__ = ({
|
|
1
|
+
(function(g){g.__tsParticlesInternals=g.__tsParticlesInternals||{};g.__tsParticlesInternals.bundles=g.__tsParticlesInternals.bundles||{};g.__tsParticlesInternals.effects=g.__tsParticlesInternals.effects||{};g.__tsParticlesInternals.engine=g.__tsParticlesInternals.engine||{};g.__tsParticlesInternals.interactions=g.__tsParticlesInternals.interactions||{};g.__tsParticlesInternals.palettes=g.__tsParticlesInternals.palettes||{};g.__tsParticlesInternals.paths=g.__tsParticlesInternals.paths||{};g.__tsParticlesInternals.plugins=g.__tsParticlesInternals.plugins||{};g.__tsParticlesInternals.plugins=g.__tsParticlesInternals.plugins||{};g.__tsParticlesInternals.plugins.emittersShapes=g.__tsParticlesInternals.plugins.emittersShapes||{};g.__tsParticlesInternals.presets=g.__tsParticlesInternals.presets||{};g.__tsParticlesInternals.shapes=g.__tsParticlesInternals.shapes||{};g.__tsParticlesInternals.updaters=g.__tsParticlesInternals.updaters||{};g.__tsParticlesInternals.utils=g.__tsParticlesInternals.utils||{};g.__tsParticlesInternals.canvas=g.__tsParticlesInternals.canvas||{};g.__tsParticlesInternals.canvas=g.__tsParticlesInternals.canvas||{};g.__tsParticlesInternals.canvas.utils=g.__tsParticlesInternals.canvas.utils||{};g.__tsParticlesInternals.path=g.__tsParticlesInternals.path||{};g.__tsParticlesInternals.path=g.__tsParticlesInternals.path||{};g.__tsParticlesInternals.path.utils=g.__tsParticlesInternals.path.utils||{};var __tsProxyFactory=typeof Proxy!=="undefined"?function(obj){return new Proxy(obj,{get:function(target,key){if(!(key in target)){target[key]={};}return target[key];}});}:function(obj){return obj;};g.__tsParticlesInternals.bundles=__tsProxyFactory(g.__tsParticlesInternals.bundles);g.__tsParticlesInternals.effects=__tsProxyFactory(g.__tsParticlesInternals.effects);g.__tsParticlesInternals.interactions=__tsProxyFactory(g.__tsParticlesInternals.interactions);g.__tsParticlesInternals.palettes=__tsProxyFactory(g.__tsParticlesInternals.palettes);g.__tsParticlesInternals.paths=__tsProxyFactory(g.__tsParticlesInternals.paths);g.__tsParticlesInternals.plugins=__tsProxyFactory(g.__tsParticlesInternals.plugins);g.__tsParticlesInternals.plugins.emittersShapes=__tsProxyFactory(g.__tsParticlesInternals.plugins.emittersShapes);g.__tsParticlesInternals.presets=__tsProxyFactory(g.__tsParticlesInternals.presets);g.__tsParticlesInternals.shapes=__tsProxyFactory(g.__tsParticlesInternals.shapes);g.__tsParticlesInternals.updaters=__tsProxyFactory(g.__tsParticlesInternals.updaters);g.__tsParticlesInternals.utils=__tsProxyFactory(g.__tsParticlesInternals.utils);g.__tsParticlesInternals.canvas=__tsProxyFactory(g.__tsParticlesInternals.canvas);g.__tsParticlesInternals.path=__tsProxyFactory(g.__tsParticlesInternals.path);g.tsparticlesInternalExports=g.tsparticlesInternalExports||{};})(typeof globalThis!=="undefined"?globalThis:typeof window!=="undefined"?window:this);
|
|
2
|
+
/* Updater v4.0.0 */
|
|
3
|
+
(function (global, factory) {
|
|
4
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tsparticles/engine')) :
|
|
5
|
+
typeof define === 'function' && define.amd ? define(['exports', '@tsparticles/engine'], factory) :
|
|
6
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.__tsParticlesInternals = global.__tsParticlesInternals || {}, global.__tsParticlesInternals.updaters = global.__tsParticlesInternals.updaters || {}, global.__tsParticlesInternals.updaters.destroy = global.__tsParticlesInternals.updaters.destroy || {}), global.__tsParticlesInternals.engine));
|
|
7
|
+
})(this, (function (exports, engine) { 'use strict';
|
|
30
8
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
9
|
+
class DestroyBounds {
|
|
10
|
+
bottom;
|
|
11
|
+
left;
|
|
12
|
+
right;
|
|
13
|
+
top;
|
|
14
|
+
load(data) {
|
|
15
|
+
if (engine.isNull(data)) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (data.bottom !== undefined) {
|
|
19
|
+
this.bottom = engine.setRangeValue(data.bottom);
|
|
20
|
+
}
|
|
21
|
+
if (data.left !== undefined) {
|
|
22
|
+
this.left = engine.setRangeValue(data.left);
|
|
23
|
+
}
|
|
24
|
+
if (data.right !== undefined) {
|
|
25
|
+
this.right = engine.setRangeValue(data.right);
|
|
26
|
+
}
|
|
27
|
+
if (data.top !== undefined) {
|
|
28
|
+
this.top = engine.setRangeValue(data.top);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
36
32
|
|
|
37
|
-
|
|
33
|
+
var DestroyMode;
|
|
34
|
+
(function (DestroyMode) {
|
|
35
|
+
DestroyMode["explode"] = "explode";
|
|
36
|
+
DestroyMode["none"] = "none";
|
|
37
|
+
DestroyMode["split"] = "split";
|
|
38
|
+
})(DestroyMode || (DestroyMode = {}));
|
|
38
39
|
|
|
39
|
-
|
|
40
|
+
class Explode {
|
|
41
|
+
maxSizeFactor;
|
|
42
|
+
speed;
|
|
43
|
+
constructor() {
|
|
44
|
+
this.maxSizeFactor = 3;
|
|
45
|
+
this.speed = 2;
|
|
46
|
+
}
|
|
47
|
+
load(data) {
|
|
48
|
+
if (engine.isNull(data)) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (data.maxSizeFactor !== undefined) {
|
|
52
|
+
this.maxSizeFactor = data.maxSizeFactor;
|
|
53
|
+
}
|
|
54
|
+
if (data.speed !== undefined) {
|
|
55
|
+
this.speed = data.speed;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
40
59
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
60
|
+
class SplitFactor extends engine.ValueWithRandom {
|
|
61
|
+
constructor() {
|
|
62
|
+
super();
|
|
63
|
+
this.value = 3;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
46
66
|
|
|
47
|
-
|
|
67
|
+
class SplitRate extends engine.ValueWithRandom {
|
|
68
|
+
constructor() {
|
|
69
|
+
super();
|
|
70
|
+
this.value = { min: 4, max: 9 };
|
|
71
|
+
}
|
|
72
|
+
}
|
|
48
73
|
|
|
49
|
-
|
|
74
|
+
class Split {
|
|
75
|
+
count;
|
|
76
|
+
factor;
|
|
77
|
+
fillColor;
|
|
78
|
+
fillColorOffset;
|
|
79
|
+
particles;
|
|
80
|
+
rate;
|
|
81
|
+
sizeOffset;
|
|
82
|
+
strokeColor;
|
|
83
|
+
strokeColorOffset;
|
|
84
|
+
constructor() {
|
|
85
|
+
this.count = 1;
|
|
86
|
+
this.factor = new SplitFactor();
|
|
87
|
+
this.rate = new SplitRate();
|
|
88
|
+
this.sizeOffset = true;
|
|
89
|
+
}
|
|
90
|
+
load(data) {
|
|
91
|
+
if (engine.isNull(data)) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
if (data.fillColor !== undefined) {
|
|
95
|
+
this.fillColor = engine.OptionsColor.create(this.fillColor, data.fillColor);
|
|
96
|
+
}
|
|
97
|
+
if (data.strokeColor !== undefined) {
|
|
98
|
+
this.strokeColor = engine.OptionsColor.create(this.strokeColor, data.strokeColor);
|
|
99
|
+
}
|
|
100
|
+
if (data.count !== undefined) {
|
|
101
|
+
this.count = data.count;
|
|
102
|
+
}
|
|
103
|
+
this.factor.load(data.factor);
|
|
104
|
+
this.rate.load(data.rate);
|
|
105
|
+
this.particles = engine.executeOnSingleOrMultiple(data.particles, particles => {
|
|
106
|
+
return engine.deepExtend({}, particles);
|
|
107
|
+
});
|
|
108
|
+
if (data.sizeOffset !== undefined) {
|
|
109
|
+
this.sizeOffset = data.sizeOffset;
|
|
110
|
+
}
|
|
111
|
+
if (data.fillColorOffset) {
|
|
112
|
+
this.fillColorOffset = this.fillColorOffset ?? {};
|
|
113
|
+
if (data.fillColorOffset.h !== undefined) {
|
|
114
|
+
this.fillColorOffset.h = data.fillColorOffset.h;
|
|
115
|
+
}
|
|
116
|
+
if (data.fillColorOffset.s !== undefined) {
|
|
117
|
+
this.fillColorOffset.s = data.fillColorOffset.s;
|
|
118
|
+
}
|
|
119
|
+
if (data.fillColorOffset.l !== undefined) {
|
|
120
|
+
this.fillColorOffset.l = data.fillColorOffset.l;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
if (data.strokeColorOffset) {
|
|
124
|
+
this.strokeColorOffset = this.strokeColorOffset ?? {};
|
|
125
|
+
if (data.strokeColorOffset.h !== undefined) {
|
|
126
|
+
this.strokeColorOffset.h = data.strokeColorOffset.h;
|
|
127
|
+
}
|
|
128
|
+
if (data.strokeColorOffset.s !== undefined) {
|
|
129
|
+
this.strokeColorOffset.s = data.strokeColorOffset.s;
|
|
130
|
+
}
|
|
131
|
+
if (data.strokeColorOffset.l !== undefined) {
|
|
132
|
+
this.strokeColorOffset.l = data.strokeColorOffset.l;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
50
137
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
/******/ for(;i < chunkIds.length; i++) {
|
|
293
|
-
/******/ chunkId = chunkIds[i];
|
|
294
|
-
/******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {
|
|
295
|
-
/******/ installedChunks[chunkId][0]();
|
|
296
|
-
/******/ }
|
|
297
|
-
/******/ installedChunks[chunkId] = 0;
|
|
298
|
-
/******/ }
|
|
299
|
-
/******/
|
|
300
|
-
/******/ }
|
|
301
|
-
/******/
|
|
302
|
-
/******/ var chunkLoadingGlobal = this["webpackChunk_tsparticles_updater_destroy"] = this["webpackChunk_tsparticles_updater_destroy"] || [];
|
|
303
|
-
/******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));
|
|
304
|
-
/******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));
|
|
305
|
-
/******/ })();
|
|
306
|
-
/******/
|
|
307
|
-
/************************************************************************/
|
|
308
|
-
/******/
|
|
309
|
-
/******/ // startup
|
|
310
|
-
/******/ // Load entry module and return exports
|
|
311
|
-
/******/ // This entry module can't be inlined because the eval devtool is used.
|
|
312
|
-
/******/ var __webpack_exports__ = __webpack_require__("./dist/browser/index.js");
|
|
313
|
-
/******/
|
|
314
|
-
/******/ return __webpack_exports__;
|
|
315
|
-
/******/ })()
|
|
316
|
-
;
|
|
317
|
-
});
|
|
138
|
+
class Destroy {
|
|
139
|
+
bounds;
|
|
140
|
+
explode;
|
|
141
|
+
mode;
|
|
142
|
+
split;
|
|
143
|
+
constructor() {
|
|
144
|
+
this.bounds = new DestroyBounds();
|
|
145
|
+
this.explode = new Explode();
|
|
146
|
+
this.mode = DestroyMode.none;
|
|
147
|
+
this.split = new Split();
|
|
148
|
+
}
|
|
149
|
+
load(data) {
|
|
150
|
+
if (engine.isNull(data)) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
if (data.mode) {
|
|
154
|
+
this.mode = data.mode;
|
|
155
|
+
}
|
|
156
|
+
if (data.bounds) {
|
|
157
|
+
this.bounds.load(data.bounds);
|
|
158
|
+
}
|
|
159
|
+
this.explode.load(data.explode);
|
|
160
|
+
this.split.load(data.split);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const defaultOffset = 0, minDestroySize = 0.5, defaultSplitCount = 0, increment = 1, unbreakableTime = 500, minSplitCount = 0, minHue = 0, hueRange = 360, minSaturation = 0, maxSaturation = 100, minLightness = 0, maxLightness = 100;
|
|
165
|
+
function createParentColor(parentColor) {
|
|
166
|
+
return engine.AnimatableColor.create(undefined, {
|
|
167
|
+
value: {
|
|
168
|
+
hsl: parentColor,
|
|
169
|
+
},
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
function createOffsetColor(parentColor, offset) {
|
|
173
|
+
const offsetH = engine.getRangeValue(offset.h ?? defaultOffset), offsetS = engine.getRangeValue(offset.s ?? defaultOffset), offsetL = engine.getRangeValue(offset.l ?? defaultOffset), h = (parentColor.h + offsetH) % hueRange, s = Math.max(minSaturation, Math.min(maxSaturation, parentColor.s + offsetS)), l = Math.max(minLightness, Math.min(maxLightness, parentColor.l + offsetL));
|
|
174
|
+
return engine.AnimatableColor.create(undefined, {
|
|
175
|
+
value: {
|
|
176
|
+
hsl: {
|
|
177
|
+
h: h < minHue ? h + hueRange : h,
|
|
178
|
+
s,
|
|
179
|
+
l,
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
function resolveSplitColor(offset, splitColor, splitParticlesColor, parentColor) {
|
|
185
|
+
if (offset && parentColor) {
|
|
186
|
+
return createOffsetColor(parentColor, offset);
|
|
187
|
+
}
|
|
188
|
+
if (splitColor) {
|
|
189
|
+
return engine.AnimatableColor.create(undefined, splitColor);
|
|
190
|
+
}
|
|
191
|
+
if (splitParticlesColor) {
|
|
192
|
+
return engine.AnimatableColor.create(undefined, splitParticlesColor);
|
|
193
|
+
}
|
|
194
|
+
return parentColor ? createParentColor(parentColor) : undefined;
|
|
195
|
+
}
|
|
196
|
+
function addSplitParticle(pluginManager, container, parent, splitParticlesOptions) {
|
|
197
|
+
const destroyOptions = parent.options.destroy;
|
|
198
|
+
if (!destroyOptions) {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
const splitOptions = destroyOptions.split, splitParticleOptions = engine.loadParticlesOptions(pluginManager, container, parent.options), splitFillColor = engine.itemFromSingleOrMultiple(splitOptions.fillColor), splitStrokeColor = engine.itemFromSingleOrMultiple(splitOptions.strokeColor), parentFillColor = parent.getFillColor(), parentStrokeColor = parent.getStrokeColor();
|
|
202
|
+
splitParticleOptions.move.load({
|
|
203
|
+
center: {
|
|
204
|
+
x: parent.position.x,
|
|
205
|
+
y: parent.position.y,
|
|
206
|
+
mode: engine.PixelMode.precise,
|
|
207
|
+
},
|
|
208
|
+
});
|
|
209
|
+
const factor = engine.identity / engine.getRangeValue(splitOptions.factor.value);
|
|
210
|
+
if (engine.isNumber(splitParticleOptions.size.value)) {
|
|
211
|
+
splitParticleOptions.size.value *= factor;
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
splitParticleOptions.size.value.min *= factor;
|
|
215
|
+
splitParticleOptions.size.value.max *= factor;
|
|
216
|
+
}
|
|
217
|
+
splitParticleOptions.load(splitParticlesOptions);
|
|
218
|
+
const splitParticlePaintOptions = engine.itemFromSingleOrMultiple(splitParticleOptions.paint), splitParticleFillOptions = splitParticlePaintOptions?.fill, splitParticleStrokeOptions = splitParticlePaintOptions?.stroke, fillColor = resolveSplitColor(splitOptions.fillColorOffset, splitFillColor, splitParticleFillOptions?.color, parentFillColor), strokeColor = resolveSplitColor(splitOptions.strokeColorOffset, splitStrokeColor, splitParticleStrokeOptions?.color, parentStrokeColor);
|
|
219
|
+
if (fillColor && splitParticleFillOptions) {
|
|
220
|
+
splitParticleFillOptions.color = fillColor;
|
|
221
|
+
}
|
|
222
|
+
if (strokeColor && splitParticleStrokeOptions) {
|
|
223
|
+
splitParticleStrokeOptions.color = strokeColor;
|
|
224
|
+
}
|
|
225
|
+
const offset = splitOptions.sizeOffset ? engine.setRangeValue(-parent.size.value, parent.size.value) : defaultOffset, position = {
|
|
226
|
+
x: parent.position.x + engine.randomInRangeValue(offset),
|
|
227
|
+
y: parent.position.y + engine.randomInRangeValue(offset),
|
|
228
|
+
};
|
|
229
|
+
return container.particles.addParticle(position, splitParticleOptions, parent.group, (particle) => {
|
|
230
|
+
if (particle.size.value < minDestroySize) {
|
|
231
|
+
return false;
|
|
232
|
+
}
|
|
233
|
+
particle.velocity.length = engine.randomInRangeValue(engine.setRangeValue(parent.velocity.length, particle.velocity.length));
|
|
234
|
+
particle.splitCount = (parent.splitCount ?? defaultSplitCount) + increment;
|
|
235
|
+
particle.unbreakable = true;
|
|
236
|
+
particle.unbreakableUntil = performance.now() + unbreakableTime;
|
|
237
|
+
return true;
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
function split(pluginManager, container, particle) {
|
|
241
|
+
const destroyOptions = particle.options.destroy;
|
|
242
|
+
if (!destroyOptions) {
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
const splitOptions = destroyOptions.split;
|
|
246
|
+
if (splitOptions.count >= minSplitCount) {
|
|
247
|
+
if (particle.splitCount === undefined || particle.splitCount > splitOptions.count) {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
particle.splitCount++;
|
|
251
|
+
}
|
|
252
|
+
const rate = engine.getRangeValue(splitOptions.rate.value), particlesSplitOptions = engine.itemFromSingleOrMultiple(splitOptions.particles);
|
|
253
|
+
for (let i = 0; i < rate; i++) {
|
|
254
|
+
addSplitParticle(pluginManager, container, particle, particlesSplitOptions);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
const defaultDeltaFactor = 1, fpsFactor = 60, minExplodeSpeed = 0.01, maxExplodeProgress = 1;
|
|
259
|
+
class DestroyUpdater {
|
|
260
|
+
_container;
|
|
261
|
+
_pluginManager;
|
|
262
|
+
constructor(pluginManager, container) {
|
|
263
|
+
this._container = container;
|
|
264
|
+
this._pluginManager = pluginManager;
|
|
265
|
+
}
|
|
266
|
+
init(particle) {
|
|
267
|
+
const container = this._container, particlesOptions = particle.options, destroyOptions = particlesOptions.destroy;
|
|
268
|
+
if (!destroyOptions) {
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
particle.exploding = undefined;
|
|
272
|
+
particle.splitCount = 0;
|
|
273
|
+
const destroyBoundsOptions = destroyOptions.bounds;
|
|
274
|
+
particle.destroyBounds ??= {};
|
|
275
|
+
const { bottom, left, right, top } = destroyBoundsOptions, { destroyBounds } = particle, canvasSize = container.canvas.size;
|
|
276
|
+
if (bottom) {
|
|
277
|
+
destroyBounds.bottom = (engine.getRangeValue(bottom) * canvasSize.height) / engine.percentDenominator;
|
|
278
|
+
}
|
|
279
|
+
if (left) {
|
|
280
|
+
destroyBounds.left = (engine.getRangeValue(left) * canvasSize.width) / engine.percentDenominator;
|
|
281
|
+
}
|
|
282
|
+
if (right) {
|
|
283
|
+
destroyBounds.right = (engine.getRangeValue(right) * canvasSize.width) / engine.percentDenominator;
|
|
284
|
+
}
|
|
285
|
+
if (top) {
|
|
286
|
+
destroyBounds.top = (engine.getRangeValue(top) * canvasSize.height) / engine.percentDenominator;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
isEnabled(particle) {
|
|
290
|
+
const destroyParticle = particle;
|
|
291
|
+
return !destroyParticle.destroyed || !!destroyParticle.exploding;
|
|
292
|
+
}
|
|
293
|
+
loadOptions(options, ...sources) {
|
|
294
|
+
options.destroy ??= new Destroy();
|
|
295
|
+
for (const source of sources) {
|
|
296
|
+
options.destroy.load(source?.destroy);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
particleDestroyed(particle, override) {
|
|
300
|
+
if (override) {
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
const destroyOptions = particle.options.destroy;
|
|
304
|
+
switch (destroyOptions?.mode) {
|
|
305
|
+
case DestroyMode.split:
|
|
306
|
+
split(this._pluginManager, this._container, particle);
|
|
307
|
+
break;
|
|
308
|
+
case DestroyMode.explode: {
|
|
309
|
+
if (particle.exploding) {
|
|
310
|
+
particle.destroyed = false;
|
|
311
|
+
break;
|
|
312
|
+
}
|
|
313
|
+
const { explode } = destroyOptions, initialSize = particle.size.value, maxSize = initialSize * explode.maxSizeFactor, opacity = particle.getOpacity();
|
|
314
|
+
particle.exploding = {
|
|
315
|
+
initialFillOpacity: opacity.fillOpacity,
|
|
316
|
+
initialSize,
|
|
317
|
+
initialStrokeOpacity: opacity.strokeOpacity,
|
|
318
|
+
maxSize,
|
|
319
|
+
progress: 0,
|
|
320
|
+
speed: Math.max(explode.speed, minExplodeSpeed),
|
|
321
|
+
};
|
|
322
|
+
particle.fillOpacity = opacity.fillOpacity;
|
|
323
|
+
particle.strokeOpacity = opacity.strokeOpacity;
|
|
324
|
+
particle.destroyed = false;
|
|
325
|
+
break;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
update(particle, delta) {
|
|
330
|
+
if (particle.exploding) {
|
|
331
|
+
const explosionState = particle.exploding, deltaFactor = delta.factor || defaultDeltaFactor;
|
|
332
|
+
explosionState.progress = Math.min(maxExplodeProgress, explosionState.progress + (explosionState.speed * deltaFactor) / fpsFactor);
|
|
333
|
+
const progress = explosionState.progress;
|
|
334
|
+
particle.size.value =
|
|
335
|
+
explosionState.initialSize + (explosionState.maxSize - explosionState.initialSize) * progress;
|
|
336
|
+
particle.fillOpacity = explosionState.initialFillOpacity * (maxExplodeProgress - progress);
|
|
337
|
+
particle.strokeOpacity = explosionState.initialStrokeOpacity * (maxExplodeProgress - progress);
|
|
338
|
+
if (progress >= maxExplodeProgress) {
|
|
339
|
+
particle.exploding = undefined;
|
|
340
|
+
particle.destroy(true);
|
|
341
|
+
}
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
if (particle.unbreakableUntil !== undefined && performance.now() >= particle.unbreakableUntil) {
|
|
345
|
+
particle.unbreakable = false;
|
|
346
|
+
particle.unbreakableUntil = undefined;
|
|
347
|
+
}
|
|
348
|
+
const position = particle.getPosition(), bounds = particle.destroyBounds;
|
|
349
|
+
if (!bounds) {
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
if ((bounds.bottom !== undefined && position.y >= bounds.bottom) ||
|
|
353
|
+
(bounds.left !== undefined && position.x <= bounds.left) ||
|
|
354
|
+
(bounds.right !== undefined && position.x >= bounds.right) ||
|
|
355
|
+
(bounds.top !== undefined && position.y <= bounds.top)) {
|
|
356
|
+
particle.destroy();
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
async function loadDestroyUpdater(engine) {
|
|
362
|
+
engine.checkVersion("4.0.0");
|
|
363
|
+
await engine.pluginManager.register(e => {
|
|
364
|
+
e.pluginManager.addParticleUpdater("destroy", container => {
|
|
365
|
+
return Promise.resolve(new DestroyUpdater(e.pluginManager, container));
|
|
366
|
+
});
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
const globalObject = globalThis;
|
|
371
|
+
globalObject.__tsParticlesInternals = globalObject.__tsParticlesInternals ?? {};
|
|
372
|
+
globalObject.loadDestroyUpdater = loadDestroyUpdater;
|
|
373
|
+
|
|
374
|
+
exports.loadDestroyUpdater = loadDestroyUpdater;
|
|
375
|
+
|
|
376
|
+
}));
|
|
377
|
+
Object.assign(globalThis.window || globalThis, { loadDestroyUpdater: (globalThis.__tsParticlesInternals.updaters.destroy || {}).loadDestroyUpdater });
|
|
378
|
+
delete (globalThis.window || globalThis).tsparticlesInternalExports;
|