@tsparticles/confetti 3.0.1 → 3.0.2
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 -95
- 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.2
|
|
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.2";
|
|
5150
5169
|
}
|
|
5151
5170
|
addConfig(config) {
|
|
5152
5171
|
const name = config.name ?? "default";
|
|
@@ -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,104 @@ 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 [, emojiData] of this._emojiShapeDict) {
|
|
7594
|
+
emojiData instanceof ImageBitmap && emojiData?.close();
|
|
7595
|
+
}
|
|
7596
|
+
}
|
|
7597
|
+
draw(data) {
|
|
7598
|
+
const {
|
|
7599
|
+
context,
|
|
7600
|
+
particle,
|
|
7601
|
+
radius,
|
|
7602
|
+
opacity
|
|
7603
|
+
} = data,
|
|
7604
|
+
emojiData = particle.emojiData;
|
|
7605
|
+
if (!emojiData) {
|
|
7606
|
+
return;
|
|
7607
|
+
}
|
|
7608
|
+
context.globalAlpha = opacity;
|
|
7609
|
+
context.drawImage(emojiData, -radius, -radius, radius * 2, radius * 2);
|
|
7610
|
+
context.globalAlpha = 1;
|
|
7611
|
+
}
|
|
7612
|
+
async init(container) {
|
|
7613
|
+
const options = container.actualOptions;
|
|
7614
|
+
if (validTypes.find(t => isInArray(t, options.particles.shape.type))) {
|
|
7615
|
+
const promises = [loadFont(defaultFont)],
|
|
7616
|
+
shapeOptions = validTypes.map(t => options.particles.shape.options[t]).find(t => !!t);
|
|
7617
|
+
if (shapeOptions) {
|
|
7618
|
+
executeOnSingleOrMultiple(shapeOptions, shape => {
|
|
7619
|
+
shape.font && promises.push(loadFont(shape.font));
|
|
7620
|
+
});
|
|
7621
|
+
}
|
|
7622
|
+
await Promise.all(promises);
|
|
7623
|
+
}
|
|
7624
|
+
}
|
|
7625
|
+
particleDestroy(particle) {
|
|
7626
|
+
delete particle.emojiData;
|
|
7627
|
+
}
|
|
7628
|
+
particleInit(container, particle) {
|
|
7629
|
+
if (!particle.emojiData) {
|
|
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
|
+
}
|
|
7677
|
+
;// CONCATENATED MODULE: ../../shapes/emoji/dist/browser/index.js
|
|
7678
|
+
|
|
7679
|
+
async function loadEmojiShape(engine, refresh = true) {
|
|
7680
|
+
await engine.addShape(validTypes, new EmojiDrawer(), refresh);
|
|
7681
|
+
}
|
|
7564
7682
|
;// CONCATENATED MODULE: ../../shapes/heart/dist/browser/HeartDrawer.js
|
|
7565
7683
|
class HeartDrawer_HeartDrawer {
|
|
7566
7684
|
draw(data) {
|
|
@@ -9130,91 +9248,6 @@ class StarDrawer {
|
|
|
9130
9248
|
async function loadStarShape(engine, refresh = true) {
|
|
9131
9249
|
await engine.addShape("star", new StarDrawer(), refresh);
|
|
9132
9250
|
}
|
|
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
9251
|
;// CONCATENATED MODULE: ../../updaters/tilt/dist/browser/Options/Classes/TiltAnimation.js
|
|
9219
9252
|
|
|
9220
9253
|
class TiltAnimation {
|
|
@@ -9546,7 +9579,7 @@ async function initPlugins(engine) {
|
|
|
9546
9579
|
await loadPolygonShape(engine, false);
|
|
9547
9580
|
await loadSquareShape(engine, false);
|
|
9548
9581
|
await loadStarShape(engine, false);
|
|
9549
|
-
await
|
|
9582
|
+
await loadEmojiShape(engine, false);
|
|
9550
9583
|
await loadRotateUpdater(engine, false);
|
|
9551
9584
|
await loadLifeUpdater(engine, false);
|
|
9552
9585
|
await loadRollUpdater(engine, false);
|
|
@@ -9701,13 +9734,13 @@ async function setConfetti(params) {
|
|
|
9701
9734
|
},
|
|
9702
9735
|
direction: "random",
|
|
9703
9736
|
animation: {
|
|
9704
|
-
enable: actualOptions.flat,
|
|
9737
|
+
enable: !actualOptions.flat,
|
|
9705
9738
|
speed: 60
|
|
9706
9739
|
}
|
|
9707
9740
|
},
|
|
9708
9741
|
tilt: {
|
|
9709
9742
|
direction: "random",
|
|
9710
|
-
enable: actualOptions.flat,
|
|
9743
|
+
enable: !actualOptions.flat,
|
|
9711
9744
|
value: actualOptions.flat ? 0 : {
|
|
9712
9745
|
min: 0,
|
|
9713
9746
|
max: 360
|
|
@@ -9722,7 +9755,7 @@ async function setConfetti(params) {
|
|
|
9722
9755
|
enable: true,
|
|
9723
9756
|
value: 25
|
|
9724
9757
|
},
|
|
9725
|
-
enable: actualOptions.flat,
|
|
9758
|
+
enable: !actualOptions.flat,
|
|
9726
9759
|
speed: {
|
|
9727
9760
|
min: 15,
|
|
9728
9761
|
max: 25
|
|
@@ -9730,7 +9763,7 @@ async function setConfetti(params) {
|
|
|
9730
9763
|
},
|
|
9731
9764
|
wobble: {
|
|
9732
9765
|
distance: 30,
|
|
9733
|
-
enable: actualOptions.flat,
|
|
9766
|
+
enable: !actualOptions.flat,
|
|
9734
9767
|
speed: {
|
|
9735
9768
|
min: -15,
|
|
9736
9769
|
max: 15
|