@tsparticles/slim 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.
|
@@ -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')
|
|
@@ -3900,6 +3900,12 @@ class Particle {
|
|
|
3900
3900
|
updater.particleDestroyed && updater.particleDestroyed(this, override);
|
|
3901
3901
|
}
|
|
3902
3902
|
pathGenerator && pathGenerator.reset(this);
|
|
3903
|
+
this._engine.dispatchEvent("particleDestroyed", {
|
|
3904
|
+
container: this.container,
|
|
3905
|
+
data: {
|
|
3906
|
+
particle: this
|
|
3907
|
+
}
|
|
3908
|
+
});
|
|
3903
3909
|
}
|
|
3904
3910
|
draw(delta) {
|
|
3905
3911
|
const container = this.container,
|
|
@@ -4252,6 +4258,11 @@ const qTreeRectangle = canvasSize => {
|
|
|
4252
4258
|
};
|
|
4253
4259
|
class Particles {
|
|
4254
4260
|
constructor(engine, container) {
|
|
4261
|
+
this._addToPool = (...particles) => {
|
|
4262
|
+
for (const particle of particles) {
|
|
4263
|
+
this._pool.push(particle);
|
|
4264
|
+
}
|
|
4265
|
+
};
|
|
4255
4266
|
this._applyDensity = (options, manualCount, group) => {
|
|
4256
4267
|
const numberOptions = options.number;
|
|
4257
4268
|
if (!options.number.density?.enable) {
|
|
@@ -4322,17 +4333,17 @@ class Particles {
|
|
|
4322
4333
|
if (!particle || particle.group !== group) {
|
|
4323
4334
|
return false;
|
|
4324
4335
|
}
|
|
4325
|
-
particle.destroy(override);
|
|
4326
4336
|
const zIdx = this._zArray.indexOf(particle);
|
|
4327
4337
|
this._array.splice(index, 1);
|
|
4328
4338
|
this._zArray.splice(zIdx, 1);
|
|
4329
|
-
|
|
4339
|
+
particle.destroy(override);
|
|
4330
4340
|
this._engine.dispatchEvent("particleRemoved", {
|
|
4331
4341
|
container: this._container,
|
|
4332
4342
|
data: {
|
|
4333
4343
|
particle
|
|
4334
4344
|
}
|
|
4335
4345
|
});
|
|
4346
|
+
this._addToPool(particle);
|
|
4336
4347
|
return true;
|
|
4337
4348
|
};
|
|
4338
4349
|
this._engine = engine;
|
|
@@ -4530,7 +4541,15 @@ class Particles {
|
|
|
4530
4541
|
const checkDelete = p => !particlesToDelete.has(p);
|
|
4531
4542
|
this._array = this.filter(checkDelete);
|
|
4532
4543
|
this._zArray = this._zArray.filter(checkDelete);
|
|
4533
|
-
|
|
4544
|
+
for (const particle of particlesToDelete) {
|
|
4545
|
+
this._engine.dispatchEvent("particleRemoved", {
|
|
4546
|
+
container: this._container,
|
|
4547
|
+
data: {
|
|
4548
|
+
particle
|
|
4549
|
+
}
|
|
4550
|
+
});
|
|
4551
|
+
}
|
|
4552
|
+
this._addToPool(...particlesToDelete);
|
|
4534
4553
|
}
|
|
4535
4554
|
await this._interactionManager.externalInteract(delta);
|
|
4536
4555
|
for (const particle of this._array) {
|
|
@@ -5146,7 +5165,7 @@ class Engine {
|
|
|
5146
5165
|
return res;
|
|
5147
5166
|
}
|
|
5148
5167
|
get version() {
|
|
5149
|
-
return "3.0.
|
|
5168
|
+
return "3.0.3";
|
|
5150
5169
|
}
|
|
5151
5170
|
addConfig(config) {
|
|
5152
5171
|
const name = config.name ?? "default";
|
|
@@ -5261,7 +5280,7 @@ class Engine {
|
|
|
5261
5280
|
this._initialized = true;
|
|
5262
5281
|
}
|
|
5263
5282
|
async load(params) {
|
|
5264
|
-
const id = params.id ?? `tsparticles${Math.floor(getRandom() * 10000)}`,
|
|
5283
|
+
const id = params.id ?? params.element?.id ?? `tsparticles${Math.floor(getRandom() * 10000)}`,
|
|
5265
5284
|
{
|
|
5266
5285
|
index,
|
|
5267
5286
|
url
|
|
@@ -6467,8 +6486,9 @@ class EmojiDrawer {
|
|
|
6467
6486
|
this._emojiShapeDict = new Map();
|
|
6468
6487
|
}
|
|
6469
6488
|
destroy() {
|
|
6470
|
-
for (const [, emojiData] of this._emojiShapeDict) {
|
|
6489
|
+
for (const [key, emojiData] of this._emojiShapeDict) {
|
|
6471
6490
|
emojiData instanceof ImageBitmap && emojiData?.close();
|
|
6491
|
+
this._emojiShapeDict.delete(key);
|
|
6472
6492
|
}
|
|
6473
6493
|
}
|
|
6474
6494
|
draw(data) {
|
|
@@ -6503,52 +6523,50 @@ class EmojiDrawer {
|
|
|
6503
6523
|
delete particle.emojiData;
|
|
6504
6524
|
}
|
|
6505
6525
|
particleInit(container, particle) {
|
|
6506
|
-
|
|
6507
|
-
|
|
6508
|
-
|
|
6509
|
-
|
|
6510
|
-
|
|
6511
|
-
|
|
6512
|
-
|
|
6513
|
-
|
|
6526
|
+
const shapeData = particle.shapeData;
|
|
6527
|
+
if (!shapeData?.value) {
|
|
6528
|
+
return;
|
|
6529
|
+
}
|
|
6530
|
+
const emoji = itemFromSingleOrMultiple(shapeData.value, particle.randomIndexData),
|
|
6531
|
+
font = shapeData.font ?? defaultFont;
|
|
6532
|
+
if (!emoji) {
|
|
6533
|
+
return;
|
|
6534
|
+
}
|
|
6535
|
+
const key = `${emoji}_${font}`,
|
|
6536
|
+
existingData = this._emojiShapeDict.get(key);
|
|
6537
|
+
if (existingData) {
|
|
6538
|
+
particle.emojiData = existingData;
|
|
6539
|
+
return;
|
|
6540
|
+
}
|
|
6541
|
+
const canvasSize = getRangeMax(particle.size.value) * 2;
|
|
6542
|
+
let emojiData;
|
|
6543
|
+
if (typeof OffscreenCanvas !== "undefined") {
|
|
6544
|
+
const canvas = new OffscreenCanvas(canvasSize, canvasSize),
|
|
6545
|
+
context = canvas.getContext("2d");
|
|
6546
|
+
if (!context) {
|
|
6514
6547
|
return;
|
|
6515
6548
|
}
|
|
6516
|
-
|
|
6517
|
-
|
|
6518
|
-
|
|
6519
|
-
|
|
6549
|
+
context.font = `400 ${getRangeMax(particle.size.value) * 2}px ${font}`;
|
|
6550
|
+
context.textBaseline = "middle";
|
|
6551
|
+
context.textAlign = "center";
|
|
6552
|
+
context.fillText(emoji, getRangeMax(particle.size.value), getRangeMax(particle.size.value));
|
|
6553
|
+
emojiData = canvas.transferToImageBitmap();
|
|
6554
|
+
} else {
|
|
6555
|
+
const canvas = document.createElement("canvas");
|
|
6556
|
+
canvas.width = canvasSize;
|
|
6557
|
+
canvas.height = canvasSize;
|
|
6558
|
+
const context = canvas.getContext("2d");
|
|
6559
|
+
if (!context) {
|
|
6520
6560
|
return;
|
|
6521
6561
|
}
|
|
6522
|
-
|
|
6523
|
-
|
|
6524
|
-
|
|
6525
|
-
|
|
6526
|
-
|
|
6527
|
-
if (!context) {
|
|
6528
|
-
return;
|
|
6529
|
-
}
|
|
6530
|
-
context.font = `400 ${getRangeMax(particle.size.value) * 2}px ${font}`;
|
|
6531
|
-
context.textBaseline = "middle";
|
|
6532
|
-
context.textAlign = "center";
|
|
6533
|
-
context.fillText(emoji, getRangeMax(particle.size.value), getRangeMax(particle.size.value));
|
|
6534
|
-
emojiData = canvas.transferToImageBitmap();
|
|
6535
|
-
} else {
|
|
6536
|
-
const canvas = document.createElement("canvas");
|
|
6537
|
-
canvas.width = canvasSize;
|
|
6538
|
-
canvas.height = canvasSize;
|
|
6539
|
-
const context = canvas.getContext("2d");
|
|
6540
|
-
if (!context) {
|
|
6541
|
-
return;
|
|
6542
|
-
}
|
|
6543
|
-
context.font = `400 ${getRangeMax(particle.size.value) * 2}px ${font}`;
|
|
6544
|
-
context.textBaseline = "middle";
|
|
6545
|
-
context.textAlign = "center";
|
|
6546
|
-
context.fillText(emoji, getRangeMax(particle.size.value), getRangeMax(particle.size.value));
|
|
6547
|
-
emojiData = canvas;
|
|
6548
|
-
}
|
|
6549
|
-
this._emojiShapeDict.set(key, emojiData);
|
|
6550
|
-
particle.emojiData = emojiData;
|
|
6562
|
+
context.font = `400 ${getRangeMax(particle.size.value) * 2}px ${font}`;
|
|
6563
|
+
context.textBaseline = "middle";
|
|
6564
|
+
context.textAlign = "center";
|
|
6565
|
+
context.fillText(emoji, getRangeMax(particle.size.value), getRangeMax(particle.size.value));
|
|
6566
|
+
emojiData = canvas;
|
|
6551
6567
|
}
|
|
6568
|
+
this._emojiShapeDict.set(key, emojiData);
|
|
6569
|
+
particle.emojiData = emojiData;
|
|
6552
6570
|
}
|
|
6553
6571
|
}
|
|
6554
6572
|
;// CONCATENATED MODULE: ../../shapes/emoji/dist/browser/index.js
|