@tsparticles/confetti 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/README.md +1 -1
- package/browser/confetti.js +6 -6
- package/cjs/confetti.js +6 -6
- package/esm/confetti.js +6 -6
- package/package.json +17 -17
- package/report.html +2 -2
- package/tsparticles.confetti.bundle.js +128 -96
- package/tsparticles.confetti.bundle.min.js +1 -1
- package/tsparticles.confetti.bundle.min.js.LICENSE.txt +1 -1
- package/tsparticles.confetti.js +19 -19
- package/tsparticles.confetti.min.js +1 -1
- package/tsparticles.confetti.min.js.LICENSE.txt +1 -1
- package/umd/confetti.js +7 -7
|
@@ -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
|
|
@@ -7201,6 +7220,7 @@ class EmitterInstance {
|
|
|
7201
7220
|
}
|
|
7202
7221
|
if (this._lifeCount > 0 || this._immortal) {
|
|
7203
7222
|
this.position = this._calcPosition();
|
|
7223
|
+
this._shape?.resize(this.position, this.size);
|
|
7204
7224
|
this._spawnDelay = getRangeValue(this.options.life.delay ?? 0) * 1000 / this.container.retina.reduceFactor;
|
|
7205
7225
|
} else {
|
|
7206
7226
|
this._destroy();
|
|
@@ -7561,6 +7581,103 @@ async function loadEmittersPlugin(engine, refresh = true) {
|
|
|
7561
7581
|
|
|
7562
7582
|
|
|
7563
7583
|
|
|
7584
|
+
;// CONCATENATED MODULE: ../../shapes/emoji/dist/browser/EmojiDrawer.js
|
|
7585
|
+
|
|
7586
|
+
const validTypes = ["emoji"];
|
|
7587
|
+
const defaultFont = '"Twemoji Mozilla", Apple Color Emoji, "Segoe UI Emoji", "Noto Color Emoji", "EmojiOne Color"';
|
|
7588
|
+
class EmojiDrawer {
|
|
7589
|
+
constructor() {
|
|
7590
|
+
this._emojiShapeDict = new Map();
|
|
7591
|
+
}
|
|
7592
|
+
destroy() {
|
|
7593
|
+
for (const [key, emojiData] of this._emojiShapeDict) {
|
|
7594
|
+
emojiData instanceof ImageBitmap && emojiData?.close();
|
|
7595
|
+
this._emojiShapeDict.delete(key);
|
|
7596
|
+
}
|
|
7597
|
+
}
|
|
7598
|
+
draw(data) {
|
|
7599
|
+
const {
|
|
7600
|
+
context,
|
|
7601
|
+
particle,
|
|
7602
|
+
radius,
|
|
7603
|
+
opacity
|
|
7604
|
+
} = data,
|
|
7605
|
+
emojiData = particle.emojiData;
|
|
7606
|
+
if (!emojiData) {
|
|
7607
|
+
return;
|
|
7608
|
+
}
|
|
7609
|
+
context.globalAlpha = opacity;
|
|
7610
|
+
context.drawImage(emojiData, -radius, -radius, radius * 2, radius * 2);
|
|
7611
|
+
context.globalAlpha = 1;
|
|
7612
|
+
}
|
|
7613
|
+
async init(container) {
|
|
7614
|
+
const options = container.actualOptions;
|
|
7615
|
+
if (validTypes.find(t => isInArray(t, options.particles.shape.type))) {
|
|
7616
|
+
const promises = [loadFont(defaultFont)],
|
|
7617
|
+
shapeOptions = validTypes.map(t => options.particles.shape.options[t]).find(t => !!t);
|
|
7618
|
+
if (shapeOptions) {
|
|
7619
|
+
executeOnSingleOrMultiple(shapeOptions, shape => {
|
|
7620
|
+
shape.font && promises.push(loadFont(shape.font));
|
|
7621
|
+
});
|
|
7622
|
+
}
|
|
7623
|
+
await Promise.all(promises);
|
|
7624
|
+
}
|
|
7625
|
+
}
|
|
7626
|
+
particleDestroy(particle) {
|
|
7627
|
+
delete particle.emojiData;
|
|
7628
|
+
}
|
|
7629
|
+
particleInit(container, particle) {
|
|
7630
|
+
const shapeData = particle.shapeData;
|
|
7631
|
+
if (!shapeData?.value) {
|
|
7632
|
+
return;
|
|
7633
|
+
}
|
|
7634
|
+
const emoji = itemFromSingleOrMultiple(shapeData.value, particle.randomIndexData),
|
|
7635
|
+
font = shapeData.font ?? defaultFont;
|
|
7636
|
+
if (!emoji) {
|
|
7637
|
+
return;
|
|
7638
|
+
}
|
|
7639
|
+
const key = `${emoji}_${font}`,
|
|
7640
|
+
existingData = this._emojiShapeDict.get(key);
|
|
7641
|
+
if (existingData) {
|
|
7642
|
+
particle.emojiData = existingData;
|
|
7643
|
+
return;
|
|
7644
|
+
}
|
|
7645
|
+
const canvasSize = getRangeMax(particle.size.value) * 2;
|
|
7646
|
+
let emojiData;
|
|
7647
|
+
if (typeof OffscreenCanvas !== "undefined") {
|
|
7648
|
+
const canvas = new OffscreenCanvas(canvasSize, canvasSize),
|
|
7649
|
+
context = canvas.getContext("2d");
|
|
7650
|
+
if (!context) {
|
|
7651
|
+
return;
|
|
7652
|
+
}
|
|
7653
|
+
context.font = `400 ${getRangeMax(particle.size.value) * 2}px ${font}`;
|
|
7654
|
+
context.textBaseline = "middle";
|
|
7655
|
+
context.textAlign = "center";
|
|
7656
|
+
context.fillText(emoji, getRangeMax(particle.size.value), getRangeMax(particle.size.value));
|
|
7657
|
+
emojiData = canvas.transferToImageBitmap();
|
|
7658
|
+
} else {
|
|
7659
|
+
const canvas = document.createElement("canvas");
|
|
7660
|
+
canvas.width = canvasSize;
|
|
7661
|
+
canvas.height = canvasSize;
|
|
7662
|
+
const context = canvas.getContext("2d");
|
|
7663
|
+
if (!context) {
|
|
7664
|
+
return;
|
|
7665
|
+
}
|
|
7666
|
+
context.font = `400 ${getRangeMax(particle.size.value) * 2}px ${font}`;
|
|
7667
|
+
context.textBaseline = "middle";
|
|
7668
|
+
context.textAlign = "center";
|
|
7669
|
+
context.fillText(emoji, getRangeMax(particle.size.value), getRangeMax(particle.size.value));
|
|
7670
|
+
emojiData = canvas;
|
|
7671
|
+
}
|
|
7672
|
+
this._emojiShapeDict.set(key, emojiData);
|
|
7673
|
+
particle.emojiData = emojiData;
|
|
7674
|
+
}
|
|
7675
|
+
}
|
|
7676
|
+
;// CONCATENATED MODULE: ../../shapes/emoji/dist/browser/index.js
|
|
7677
|
+
|
|
7678
|
+
async function loadEmojiShape(engine, refresh = true) {
|
|
7679
|
+
await engine.addShape(validTypes, new EmojiDrawer(), refresh);
|
|
7680
|
+
}
|
|
7564
7681
|
;// CONCATENATED MODULE: ../../shapes/heart/dist/browser/HeartDrawer.js
|
|
7565
7682
|
class HeartDrawer_HeartDrawer {
|
|
7566
7683
|
draw(data) {
|
|
@@ -9130,91 +9247,6 @@ class StarDrawer {
|
|
|
9130
9247
|
async function loadStarShape(engine, refresh = true) {
|
|
9131
9248
|
await engine.addShape("star", new StarDrawer(), refresh);
|
|
9132
9249
|
}
|
|
9133
|
-
;// CONCATENATED MODULE: ../../shapes/text/dist/browser/TextDrawer.js
|
|
9134
|
-
|
|
9135
|
-
const validTypes = ["text", "character", "char", "multiline-text"];
|
|
9136
|
-
class TextDrawer {
|
|
9137
|
-
constructor() {
|
|
9138
|
-
this._drawLine = (context, line, radius, opacity, index, fill) => {
|
|
9139
|
-
const offsetX = line.length * radius / 2,
|
|
9140
|
-
pos = {
|
|
9141
|
-
x: -offsetX,
|
|
9142
|
-
y: radius / 2
|
|
9143
|
-
},
|
|
9144
|
-
diameter = radius * 2;
|
|
9145
|
-
if (fill) {
|
|
9146
|
-
context.fillText(line, pos.x, pos.y + diameter * index);
|
|
9147
|
-
} else {
|
|
9148
|
-
context.strokeText(line, pos.x, pos.y + diameter * index);
|
|
9149
|
-
}
|
|
9150
|
-
};
|
|
9151
|
-
}
|
|
9152
|
-
draw(data) {
|
|
9153
|
-
const {
|
|
9154
|
-
context,
|
|
9155
|
-
particle,
|
|
9156
|
-
radius,
|
|
9157
|
-
opacity
|
|
9158
|
-
} = data,
|
|
9159
|
-
character = particle.shapeData;
|
|
9160
|
-
if (!character) {
|
|
9161
|
-
return;
|
|
9162
|
-
}
|
|
9163
|
-
const textData = character.value;
|
|
9164
|
-
if (textData === undefined) {
|
|
9165
|
-
return;
|
|
9166
|
-
}
|
|
9167
|
-
if (particle.text === undefined) {
|
|
9168
|
-
particle.text = itemFromSingleOrMultiple(textData, particle.randomIndexData);
|
|
9169
|
-
}
|
|
9170
|
-
const text = particle.text,
|
|
9171
|
-
style = character.style ?? "",
|
|
9172
|
-
weight = character.weight ?? "400",
|
|
9173
|
-
size = Math.round(radius) * 2,
|
|
9174
|
-
font = character.font ?? "Verdana",
|
|
9175
|
-
fill = particle.shapeFill;
|
|
9176
|
-
const lines = text?.split("\n");
|
|
9177
|
-
if (!lines) {
|
|
9178
|
-
return;
|
|
9179
|
-
}
|
|
9180
|
-
context.font = `${style} ${weight} ${size}px "${font}"`;
|
|
9181
|
-
context.globalAlpha = opacity;
|
|
9182
|
-
for (let i = 0; i < lines.length; i++) {
|
|
9183
|
-
this._drawLine(context, lines[i], radius, opacity, i, fill);
|
|
9184
|
-
}
|
|
9185
|
-
context.globalAlpha = 1;
|
|
9186
|
-
}
|
|
9187
|
-
async init(container) {
|
|
9188
|
-
const options = container.actualOptions;
|
|
9189
|
-
if (validTypes.find(t => isInArray(t, options.particles.shape.type))) {
|
|
9190
|
-
const shapeOptions = validTypes.map(t => options.particles.shape.options[t]).find(t => !!t),
|
|
9191
|
-
promises = [];
|
|
9192
|
-
executeOnSingleOrMultiple(shapeOptions, shape => {
|
|
9193
|
-
promises.push(loadFont(shape.font, shape.weight));
|
|
9194
|
-
});
|
|
9195
|
-
await Promise.all(promises);
|
|
9196
|
-
}
|
|
9197
|
-
}
|
|
9198
|
-
particleInit(container, particle) {
|
|
9199
|
-
if (!particle.shape || !validTypes.includes(particle.shape)) {
|
|
9200
|
-
return;
|
|
9201
|
-
}
|
|
9202
|
-
const character = particle.shapeData;
|
|
9203
|
-
if (character === undefined) {
|
|
9204
|
-
return;
|
|
9205
|
-
}
|
|
9206
|
-
const textData = character.value;
|
|
9207
|
-
if (textData === undefined) {
|
|
9208
|
-
return;
|
|
9209
|
-
}
|
|
9210
|
-
particle.text = itemFromSingleOrMultiple(textData, particle.randomIndexData);
|
|
9211
|
-
}
|
|
9212
|
-
}
|
|
9213
|
-
;// CONCATENATED MODULE: ../../shapes/text/dist/browser/index.js
|
|
9214
|
-
|
|
9215
|
-
async function loadTextShape(engine, refresh = true) {
|
|
9216
|
-
await engine.addShape(validTypes, new TextDrawer(), refresh);
|
|
9217
|
-
}
|
|
9218
9250
|
;// CONCATENATED MODULE: ../../updaters/tilt/dist/browser/Options/Classes/TiltAnimation.js
|
|
9219
9251
|
|
|
9220
9252
|
class TiltAnimation {
|
|
@@ -9546,7 +9578,7 @@ async function initPlugins(engine) {
|
|
|
9546
9578
|
await loadPolygonShape(engine, false);
|
|
9547
9579
|
await loadSquareShape(engine, false);
|
|
9548
9580
|
await loadStarShape(engine, false);
|
|
9549
|
-
await
|
|
9581
|
+
await loadEmojiShape(engine, false);
|
|
9550
9582
|
await loadRotateUpdater(engine, false);
|
|
9551
9583
|
await loadLifeUpdater(engine, false);
|
|
9552
9584
|
await loadRollUpdater(engine, false);
|
|
@@ -9701,13 +9733,13 @@ async function setConfetti(params) {
|
|
|
9701
9733
|
},
|
|
9702
9734
|
direction: "random",
|
|
9703
9735
|
animation: {
|
|
9704
|
-
enable: actualOptions.flat,
|
|
9736
|
+
enable: !actualOptions.flat,
|
|
9705
9737
|
speed: 60
|
|
9706
9738
|
}
|
|
9707
9739
|
},
|
|
9708
9740
|
tilt: {
|
|
9709
9741
|
direction: "random",
|
|
9710
|
-
enable: actualOptions.flat,
|
|
9742
|
+
enable: !actualOptions.flat,
|
|
9711
9743
|
value: actualOptions.flat ? 0 : {
|
|
9712
9744
|
min: 0,
|
|
9713
9745
|
max: 360
|
|
@@ -9722,7 +9754,7 @@ async function setConfetti(params) {
|
|
|
9722
9754
|
enable: true,
|
|
9723
9755
|
value: 25
|
|
9724
9756
|
},
|
|
9725
|
-
enable: actualOptions.flat,
|
|
9757
|
+
enable: !actualOptions.flat,
|
|
9726
9758
|
speed: {
|
|
9727
9759
|
min: 15,
|
|
9728
9760
|
max: 25
|
|
@@ -9730,7 +9762,7 @@ async function setConfetti(params) {
|
|
|
9730
9762
|
},
|
|
9731
9763
|
wobble: {
|
|
9732
9764
|
distance: 30,
|
|
9733
|
-
enable: actualOptions.flat,
|
|
9765
|
+
enable: !actualOptions.flat,
|
|
9734
9766
|
speed: {
|
|
9735
9767
|
min: -15,
|
|
9736
9768
|
max: 15
|