tsparticles 3.0.1 → 3.0.3
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/package.json +14 -14
- package/report.html +2 -2
- package/tsparticles.bundle.js +67 -48
- package/tsparticles.bundle.min.js +1 -1
- package/tsparticles.bundle.min.js.LICENSE.txt +1 -1
- package/tsparticles.js +1 -1
- package/tsparticles.min.js.LICENSE.txt +1 -1
package/tsparticles.bundle.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Demo / Generator : https://particles.js.org/
|
|
5
5
|
* GitHub : https://www.github.com/matteobruni/tsparticles
|
|
6
6
|
* How to use? : Check the GitHub README
|
|
7
|
-
* v3.0.
|
|
7
|
+
* v3.0.3
|
|
8
8
|
*/
|
|
9
9
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
10
10
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
@@ -3901,6 +3901,12 @@ class Particle {
|
|
|
3901
3901
|
updater.particleDestroyed && updater.particleDestroyed(this, override);
|
|
3902
3902
|
}
|
|
3903
3903
|
pathGenerator && pathGenerator.reset(this);
|
|
3904
|
+
this._engine.dispatchEvent("particleDestroyed", {
|
|
3905
|
+
container: this.container,
|
|
3906
|
+
data: {
|
|
3907
|
+
particle: this
|
|
3908
|
+
}
|
|
3909
|
+
});
|
|
3904
3910
|
}
|
|
3905
3911
|
draw(delta) {
|
|
3906
3912
|
const container = this.container,
|
|
@@ -4253,6 +4259,11 @@ const qTreeRectangle = canvasSize => {
|
|
|
4253
4259
|
};
|
|
4254
4260
|
class Particles {
|
|
4255
4261
|
constructor(engine, container) {
|
|
4262
|
+
this._addToPool = (...particles) => {
|
|
4263
|
+
for (const particle of particles) {
|
|
4264
|
+
this._pool.push(particle);
|
|
4265
|
+
}
|
|
4266
|
+
};
|
|
4256
4267
|
this._applyDensity = (options, manualCount, group) => {
|
|
4257
4268
|
const numberOptions = options.number;
|
|
4258
4269
|
if (!options.number.density?.enable) {
|
|
@@ -4323,17 +4334,17 @@ class Particles {
|
|
|
4323
4334
|
if (!particle || particle.group !== group) {
|
|
4324
4335
|
return false;
|
|
4325
4336
|
}
|
|
4326
|
-
particle.destroy(override);
|
|
4327
4337
|
const zIdx = this._zArray.indexOf(particle);
|
|
4328
4338
|
this._array.splice(index, 1);
|
|
4329
4339
|
this._zArray.splice(zIdx, 1);
|
|
4330
|
-
|
|
4340
|
+
particle.destroy(override);
|
|
4331
4341
|
this._engine.dispatchEvent("particleRemoved", {
|
|
4332
4342
|
container: this._container,
|
|
4333
4343
|
data: {
|
|
4334
4344
|
particle
|
|
4335
4345
|
}
|
|
4336
4346
|
});
|
|
4347
|
+
this._addToPool(particle);
|
|
4337
4348
|
return true;
|
|
4338
4349
|
};
|
|
4339
4350
|
this._engine = engine;
|
|
@@ -4531,7 +4542,15 @@ class Particles {
|
|
|
4531
4542
|
const checkDelete = p => !particlesToDelete.has(p);
|
|
4532
4543
|
this._array = this.filter(checkDelete);
|
|
4533
4544
|
this._zArray = this._zArray.filter(checkDelete);
|
|
4534
|
-
|
|
4545
|
+
for (const particle of particlesToDelete) {
|
|
4546
|
+
this._engine.dispatchEvent("particleRemoved", {
|
|
4547
|
+
container: this._container,
|
|
4548
|
+
data: {
|
|
4549
|
+
particle
|
|
4550
|
+
}
|
|
4551
|
+
});
|
|
4552
|
+
}
|
|
4553
|
+
this._addToPool(...particlesToDelete);
|
|
4535
4554
|
}
|
|
4536
4555
|
await this._interactionManager.externalInteract(delta);
|
|
4537
4556
|
for (const particle of this._array) {
|
|
@@ -5147,7 +5166,7 @@ class Engine {
|
|
|
5147
5166
|
return res;
|
|
5148
5167
|
}
|
|
5149
5168
|
get version() {
|
|
5150
|
-
return "3.0.
|
|
5169
|
+
return "3.0.3";
|
|
5151
5170
|
}
|
|
5152
5171
|
addConfig(config) {
|
|
5153
5172
|
const name = config.name ?? "default";
|
|
@@ -5262,7 +5281,7 @@ class Engine {
|
|
|
5262
5281
|
this._initialized = true;
|
|
5263
5282
|
}
|
|
5264
5283
|
async load(params) {
|
|
5265
|
-
const id = params.id ?? `tsparticles${Math.floor(getRandom() * 10000)}`,
|
|
5284
|
+
const id = params.id ?? params.element?.id ?? `tsparticles${Math.floor(getRandom() * 10000)}`,
|
|
5266
5285
|
{
|
|
5267
5286
|
index,
|
|
5268
5287
|
url
|
|
@@ -6512,6 +6531,7 @@ class EmitterInstance {
|
|
|
6512
6531
|
}
|
|
6513
6532
|
if (this._lifeCount > 0 || this._immortal) {
|
|
6514
6533
|
this.position = this._calcPosition();
|
|
6534
|
+
this._shape?.resize(this.position, this.size);
|
|
6515
6535
|
this._spawnDelay = getRangeValue(this.options.life.delay ?? 0) * 1000 / this.container.retina.reduceFactor;
|
|
6516
6536
|
} else {
|
|
6517
6537
|
this._destroy();
|
|
@@ -8162,8 +8182,9 @@ class EmojiDrawer {
|
|
|
8162
8182
|
this._emojiShapeDict = new Map();
|
|
8163
8183
|
}
|
|
8164
8184
|
destroy() {
|
|
8165
|
-
for (const [, emojiData] of this._emojiShapeDict) {
|
|
8185
|
+
for (const [key, emojiData] of this._emojiShapeDict) {
|
|
8166
8186
|
emojiData instanceof ImageBitmap && emojiData?.close();
|
|
8187
|
+
this._emojiShapeDict.delete(key);
|
|
8167
8188
|
}
|
|
8168
8189
|
}
|
|
8169
8190
|
draw(data) {
|
|
@@ -8198,52 +8219,50 @@ class EmojiDrawer {
|
|
|
8198
8219
|
delete particle.emojiData;
|
|
8199
8220
|
}
|
|
8200
8221
|
particleInit(container, particle) {
|
|
8201
|
-
|
|
8202
|
-
|
|
8203
|
-
|
|
8204
|
-
|
|
8205
|
-
|
|
8206
|
-
|
|
8207
|
-
|
|
8208
|
-
|
|
8222
|
+
const shapeData = particle.shapeData;
|
|
8223
|
+
if (!shapeData?.value) {
|
|
8224
|
+
return;
|
|
8225
|
+
}
|
|
8226
|
+
const emoji = itemFromSingleOrMultiple(shapeData.value, particle.randomIndexData),
|
|
8227
|
+
font = shapeData.font ?? defaultFont;
|
|
8228
|
+
if (!emoji) {
|
|
8229
|
+
return;
|
|
8230
|
+
}
|
|
8231
|
+
const key = `${emoji}_${font}`,
|
|
8232
|
+
existingData = this._emojiShapeDict.get(key);
|
|
8233
|
+
if (existingData) {
|
|
8234
|
+
particle.emojiData = existingData;
|
|
8235
|
+
return;
|
|
8236
|
+
}
|
|
8237
|
+
const canvasSize = getRangeMax(particle.size.value) * 2;
|
|
8238
|
+
let emojiData;
|
|
8239
|
+
if (typeof OffscreenCanvas !== "undefined") {
|
|
8240
|
+
const canvas = new OffscreenCanvas(canvasSize, canvasSize),
|
|
8241
|
+
context = canvas.getContext("2d");
|
|
8242
|
+
if (!context) {
|
|
8209
8243
|
return;
|
|
8210
8244
|
}
|
|
8211
|
-
|
|
8212
|
-
|
|
8213
|
-
|
|
8214
|
-
|
|
8245
|
+
context.font = `400 ${getRangeMax(particle.size.value) * 2}px ${font}`;
|
|
8246
|
+
context.textBaseline = "middle";
|
|
8247
|
+
context.textAlign = "center";
|
|
8248
|
+
context.fillText(emoji, getRangeMax(particle.size.value), getRangeMax(particle.size.value));
|
|
8249
|
+
emojiData = canvas.transferToImageBitmap();
|
|
8250
|
+
} else {
|
|
8251
|
+
const canvas = document.createElement("canvas");
|
|
8252
|
+
canvas.width = canvasSize;
|
|
8253
|
+
canvas.height = canvasSize;
|
|
8254
|
+
const context = canvas.getContext("2d");
|
|
8255
|
+
if (!context) {
|
|
8215
8256
|
return;
|
|
8216
8257
|
}
|
|
8217
|
-
|
|
8218
|
-
|
|
8219
|
-
|
|
8220
|
-
|
|
8221
|
-
|
|
8222
|
-
if (!context) {
|
|
8223
|
-
return;
|
|
8224
|
-
}
|
|
8225
|
-
context.font = `400 ${getRangeMax(particle.size.value) * 2}px ${font}`;
|
|
8226
|
-
context.textBaseline = "middle";
|
|
8227
|
-
context.textAlign = "center";
|
|
8228
|
-
context.fillText(emoji, getRangeMax(particle.size.value), getRangeMax(particle.size.value));
|
|
8229
|
-
emojiData = canvas.transferToImageBitmap();
|
|
8230
|
-
} else {
|
|
8231
|
-
const canvas = document.createElement("canvas");
|
|
8232
|
-
canvas.width = canvasSize;
|
|
8233
|
-
canvas.height = canvasSize;
|
|
8234
|
-
const context = canvas.getContext("2d");
|
|
8235
|
-
if (!context) {
|
|
8236
|
-
return;
|
|
8237
|
-
}
|
|
8238
|
-
context.font = `400 ${getRangeMax(particle.size.value) * 2}px ${font}`;
|
|
8239
|
-
context.textBaseline = "middle";
|
|
8240
|
-
context.textAlign = "center";
|
|
8241
|
-
context.fillText(emoji, getRangeMax(particle.size.value), getRangeMax(particle.size.value));
|
|
8242
|
-
emojiData = canvas;
|
|
8243
|
-
}
|
|
8244
|
-
this._emojiShapeDict.set(key, emojiData);
|
|
8245
|
-
particle.emojiData = emojiData;
|
|
8258
|
+
context.font = `400 ${getRangeMax(particle.size.value) * 2}px ${font}`;
|
|
8259
|
+
context.textBaseline = "middle";
|
|
8260
|
+
context.textAlign = "center";
|
|
8261
|
+
context.fillText(emoji, getRangeMax(particle.size.value), getRangeMax(particle.size.value));
|
|
8262
|
+
emojiData = canvas;
|
|
8246
8263
|
}
|
|
8264
|
+
this._emojiShapeDict.set(key, emojiData);
|
|
8265
|
+
particle.emojiData = emojiData;
|
|
8247
8266
|
}
|
|
8248
8267
|
}
|
|
8249
8268
|
;// CONCATENATED MODULE: ../../shapes/emoji/dist/browser/index.js
|