@tsparticles/slim 3.0.0-beta.4 → 3.0.0-beta.5

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.0-beta.4
7
+ * v3.0.0-beta.5
8
8
  */
9
9
  (function webpackUniversalModuleDefinition(root, factory) {
10
10
  if(typeof exports === 'object' && typeof module === 'object')
@@ -2401,11 +2401,7 @@ class Events {
2401
2401
  });
2402
2402
  }
2403
2403
  this.onHover.load(data.onHover);
2404
- if (isBoolean(data.resize)) {
2405
- this.resize.enable = data.resize;
2406
- } else {
2407
- this.resize.load(data.resize);
2408
- }
2404
+ this.resize.load(data.resize);
2409
2405
  }
2410
2406
  }
2411
2407
  ;// CONCATENATED MODULE: ../../engine/dist/browser/Options/Classes/Interactivity/Modes/Modes.js
@@ -3430,23 +3426,26 @@ class ParticlesOptions {
3430
3426
  if (!data) {
3431
3427
  return;
3432
3428
  }
3433
- this.bounce.load(data.bounce);
3434
- this.color.load(AnimatableColor.create(this.color, data.color));
3435
- this.effect.load(data.effect);
3436
3429
  if (data.groups !== undefined) {
3437
- for (const group in data.groups) {
3430
+ for (const group of Object.keys(data.groups)) {
3431
+ if (!Object.hasOwn(data.groups, group)) {
3432
+ continue;
3433
+ }
3438
3434
  const item = data.groups[group];
3439
3435
  if (item !== undefined) {
3440
3436
  this.groups[group] = deepExtend(this.groups[group] ?? {}, item);
3441
3437
  }
3442
3438
  }
3443
3439
  }
3444
- this.move.load(data.move);
3445
- this.number.load(data.number);
3446
- this.opacity.load(data.opacity);
3447
3440
  if (data.reduceDuplicates !== undefined) {
3448
3441
  this.reduceDuplicates = data.reduceDuplicates;
3449
3442
  }
3443
+ this.bounce.load(data.bounce);
3444
+ this.color.load(AnimatableColor.create(this.color, data.color));
3445
+ this.effect.load(data.effect);
3446
+ this.move.load(data.move);
3447
+ this.number.load(data.number);
3448
+ this.opacity.load(data.opacity);
3450
3449
  this.shape.load(data.shape);
3451
3450
  this.size.load(data.size);
3452
3451
  this.shadow.load(data.shadow);
@@ -3871,7 +3870,9 @@ class Particle {
3871
3870
  this.bubble.inRange = false;
3872
3871
  this.slow.inRange = false;
3873
3872
  const container = this.container,
3874
- pathGenerator = this.pathGenerator;
3873
+ pathGenerator = this.pathGenerator,
3874
+ shapeDrawer = container.shapeDrawers.get(this.shape);
3875
+ shapeDrawer && shapeDrawer.particleDestroy && shapeDrawer.particleDestroy(this);
3875
3876
  for (const [, plugin] of container.plugins) {
3876
3877
  plugin.particleDestroyed && plugin.particleDestroyed(this, override);
3877
3878
  }
@@ -5125,7 +5126,7 @@ class Engine {
5125
5126
  return res;
5126
5127
  }
5127
5128
  get version() {
5128
- return "3.0.0-beta.4";
5129
+ return "3.0.0-beta.5";
5129
5130
  }
5130
5131
  addConfig(config) {
5131
5132
  const name = config.name ?? "default";
@@ -5536,140 +5537,6 @@ if (!isSsr()) {
5536
5537
 
5537
5538
 
5538
5539
 
5539
- ;// CONCATENATED MODULE: ../pjs/dist/browser/marcbruederlin/Particles.js
5540
-
5541
- class Particles_Particles {
5542
- static init(options) {
5543
- const particles = new Particles_Particles(),
5544
- selector = options.selector;
5545
- if (!selector) {
5546
- throw new Error("No selector provided");
5547
- }
5548
- const el = document.querySelector(selector);
5549
- if (!el) {
5550
- throw new Error("No element found for selector");
5551
- }
5552
- tsParticles.load({
5553
- id: selector.replace(".", "").replace("!", ""),
5554
- element: el,
5555
- options: {
5556
- fullScreen: {
5557
- enable: false
5558
- },
5559
- particles: {
5560
- color: {
5561
- value: options.color ?? "!000000"
5562
- },
5563
- links: {
5564
- color: "random",
5565
- distance: options.minDistance ?? 120,
5566
- enable: options.connectParticles ?? false
5567
- },
5568
- move: {
5569
- enable: true,
5570
- speed: options.speed ?? 0.5
5571
- },
5572
- number: {
5573
- value: options.maxParticles ?? 100
5574
- },
5575
- size: {
5576
- value: {
5577
- min: 1,
5578
- max: options.sizeVariations ?? 3
5579
- }
5580
- }
5581
- },
5582
- responsive: options.responsive?.map(responsive => ({
5583
- maxWidth: responsive.breakpoint,
5584
- options: {
5585
- particles: {
5586
- color: {
5587
- value: responsive.options?.color
5588
- },
5589
- links: {
5590
- distance: responsive.options?.minDistance,
5591
- enable: responsive.options?.connectParticles
5592
- },
5593
- number: {
5594
- value: options.maxParticles
5595
- },
5596
- move: {
5597
- enable: true,
5598
- speed: responsive.options?.speed
5599
- },
5600
- size: {
5601
- value: responsive.options?.sizeVariations
5602
- }
5603
- }
5604
- }
5605
- }))
5606
- }
5607
- }).then(container => {
5608
- particles._container = container;
5609
- });
5610
- return particles;
5611
- }
5612
- destroy() {
5613
- const container = this._container;
5614
- container && container.destroy();
5615
- }
5616
- pauseAnimation() {
5617
- const container = this._container;
5618
- container && container.pause();
5619
- }
5620
- resumeAnimation() {
5621
- const container = this._container;
5622
- container && container.play();
5623
- }
5624
- }
5625
- ;// CONCATENATED MODULE: ../pjs/dist/browser/VincentGarreau/particles.js
5626
- const initParticlesJS = engine => {
5627
- const particlesJS = (tagId, options) => {
5628
- return engine.load({
5629
- id: tagId,
5630
- options
5631
- });
5632
- };
5633
- particlesJS.load = (tagId, pathConfigJson, callback) => {
5634
- engine.load({
5635
- id: tagId,
5636
- url: pathConfigJson
5637
- }).then(container => {
5638
- if (container) {
5639
- callback(container);
5640
- }
5641
- }).catch(() => {
5642
- callback(undefined);
5643
- });
5644
- };
5645
- particlesJS.setOnClickHandler = callback => {
5646
- engine.setOnClickHandler(callback);
5647
- };
5648
- const pJSDom = engine.dom();
5649
- return {
5650
- particlesJS,
5651
- pJSDom
5652
- };
5653
- };
5654
-
5655
- ;// CONCATENATED MODULE: ../pjs/dist/browser/index.js
5656
-
5657
-
5658
- const initPjs = engine => {
5659
- const {
5660
- particlesJS,
5661
- pJSDom
5662
- } = initParticlesJS(engine);
5663
- window.particlesJS = particlesJS;
5664
- window.pJSDom = pJSDom;
5665
- window.Particles = Particles_Particles;
5666
- return {
5667
- particlesJS,
5668
- pJSDom,
5669
- Particles: Particles_Particles
5670
- };
5671
- };
5672
-
5673
5540
  ;// CONCATENATED MODULE: ../../move/base/dist/browser/Utils.js
5674
5541
 
5675
5542
  function applyDistance(particle) {
@@ -6571,6 +6438,88 @@ async function loadEasingQuadPlugin() {
6571
6438
  addEasing("ease-out-quad", value => 1 - (1 - value) ** 2);
6572
6439
  addEasing("ease-in-out-quad", value => value < 0.5 ? 2 * value ** 2 : 1 - (-2 * value + 2) ** 2 / 2);
6573
6440
  }
6441
+ ;// CONCATENATED MODULE: ../../shapes/emoji/dist/browser/EmojiDrawer.js
6442
+
6443
+ const validTypes = ["emoji"];
6444
+ const defaultFont = '"Twemoji Mozilla", Apple Color Emoji, "Segoe UI Emoji", "Noto Color Emoji", "EmojiOne Color"';
6445
+ class EmojiDrawer {
6446
+ constructor() {
6447
+ this._emojiShapeDict = new Map();
6448
+ }
6449
+ destroy() {
6450
+ for (const [, emojiData] of this._emojiShapeDict) {
6451
+ emojiData?.close();
6452
+ }
6453
+ }
6454
+ draw(data) {
6455
+ const {
6456
+ context,
6457
+ particle,
6458
+ radius,
6459
+ opacity
6460
+ } = data,
6461
+ emojiData = particle.emojiData;
6462
+ if (!emojiData) {
6463
+ return;
6464
+ }
6465
+ context.globalAlpha = opacity;
6466
+ context.drawImage(emojiData, -radius, -radius, radius * 2, radius * 2);
6467
+ context.globalAlpha = 1;
6468
+ }
6469
+ async init(container) {
6470
+ const options = container.actualOptions;
6471
+ if (validTypes.find(t => isInArray(t, options.particles.shape.type))) {
6472
+ const promises = [loadFont(defaultFont)],
6473
+ shapeOptions = validTypes.map(t => options.particles.shape.options[t]).find(t => !!t);
6474
+ if (shapeOptions) {
6475
+ executeOnSingleOrMultiple(shapeOptions, shape => {
6476
+ shape.font && promises.push(loadFont(shape.font));
6477
+ });
6478
+ }
6479
+ await Promise.all(promises);
6480
+ }
6481
+ }
6482
+ particleDestroy(particle) {
6483
+ delete particle.emojiData;
6484
+ }
6485
+ particleInit(container, particle) {
6486
+ if (!particle.emojiData) {
6487
+ const shapeData = particle.shapeData;
6488
+ if (!shapeData?.value) {
6489
+ return;
6490
+ }
6491
+ const emoji = itemFromSingleOrMultiple(shapeData.value, particle.randomIndexData),
6492
+ font = shapeData.font ?? defaultFont;
6493
+ if (!emoji) {
6494
+ return;
6495
+ }
6496
+ const key = `${emoji}_${font}`,
6497
+ existingData = this._emojiShapeDict.get(key);
6498
+ if (existingData) {
6499
+ particle.emojiData = existingData;
6500
+ return;
6501
+ }
6502
+ const canvasSize = getRangeMax(particle.size.value) * 2,
6503
+ canvas = new OffscreenCanvas(canvasSize, canvasSize);
6504
+ const context = canvas.getContext("2d");
6505
+ if (!context) {
6506
+ return;
6507
+ }
6508
+ context.font = `400 ${getRangeMax(particle.size.value) * 2}px ${font}`;
6509
+ context.textBaseline = "middle";
6510
+ context.textAlign = "center";
6511
+ context.fillText(emoji, getRangeMax(particle.size.value), getRangeMax(particle.size.value));
6512
+ const emojiData = canvas.transferToImageBitmap();
6513
+ this._emojiShapeDict.set(key, emojiData);
6514
+ particle.emojiData = emojiData;
6515
+ }
6516
+ }
6517
+ }
6518
+ ;// CONCATENATED MODULE: ../../shapes/emoji/dist/browser/index.js
6519
+
6520
+ async function loadEmojiShape(engine, refresh = true) {
6521
+ await engine.addShape(validTypes, new EmojiDrawer(), refresh);
6522
+ }
6574
6523
  ;// CONCATENATED MODULE: ../../interactions/external/attract/dist/browser/Options/Classes/Attract.js
6575
6524
  class Attract {
6576
6525
  constructor() {
@@ -7471,18 +7420,6 @@ class Grab {
7471
7420
  this.distance = 100;
7472
7421
  this.links = new GrabLinks();
7473
7422
  }
7474
- get lineLinked() {
7475
- return this.links;
7476
- }
7477
- set lineLinked(value) {
7478
- this.links = value;
7479
- }
7480
- get line_linked() {
7481
- return this.links;
7482
- }
7483
- set line_linked(value) {
7484
- this.links = value;
7485
- }
7486
7423
  load(data) {
7487
7424
  if (!data) {
7488
7425
  return;
@@ -7490,7 +7427,7 @@ class Grab {
7490
7427
  if (data.distance !== undefined) {
7491
7428
  this.distance = data.distance;
7492
7429
  }
7493
- this.links.load(data.links ?? data.lineLinked ?? data.line_linked);
7430
+ this.links.load(data.links);
7494
7431
  }
7495
7432
  }
7496
7433
  ;// CONCATENATED MODULE: ../../interactions/external/grab/dist/browser/Utils.js
@@ -7629,12 +7566,6 @@ class Push {
7629
7566
  this.groups = [];
7630
7567
  this.quantity = 4;
7631
7568
  }
7632
- get particles_nb() {
7633
- return this.quantity;
7634
- }
7635
- set particles_nb(value) {
7636
- this.quantity = setRangeValue(value);
7637
- }
7638
7569
  load(data) {
7639
7570
  if (!data) {
7640
7571
  return;
@@ -7648,7 +7579,7 @@ class Push {
7648
7579
  if (!this.groups.length) {
7649
7580
  this.default = true;
7650
7581
  }
7651
- const quantity = data.quantity ?? data.particles_nb;
7582
+ const quantity = data.quantity;
7652
7583
  if (quantity !== undefined) {
7653
7584
  this.quantity = setRangeValue(quantity);
7654
7585
  }
@@ -7709,17 +7640,11 @@ class Remove {
7709
7640
  constructor() {
7710
7641
  this.quantity = 2;
7711
7642
  }
7712
- get particles_nb() {
7713
- return this.quantity;
7714
- }
7715
- set particles_nb(value) {
7716
- this.quantity = setRangeValue(value);
7717
- }
7718
7643
  load(data) {
7719
7644
  if (!data) {
7720
7645
  return;
7721
7646
  }
7722
- const quantity = data.quantity ?? data.particles_nb;
7647
+ const quantity = data.quantity;
7723
7648
  if (quantity !== undefined) {
7724
7649
  this.quantity = setRangeValue(quantity);
7725
7650
  }
@@ -8782,8 +8707,9 @@ class ImageDrawer {
8782
8707
  pos = {
8783
8708
  x: -radius,
8784
8709
  y: -radius
8785
- };
8786
- context.drawImage(element, pos.x, pos.y, radius * 2, radius * 2 / ratio);
8710
+ },
8711
+ diameter = radius * 2;
8712
+ context.drawImage(element, pos.x, pos.y, diameter, diameter / ratio);
8787
8713
  }
8788
8714
  context.globalAlpha = 1;
8789
8715
  }
@@ -9620,7 +9546,7 @@ class Linker extends ParticlesInteractorBase {
9620
9546
  options.links = new Links();
9621
9547
  }
9622
9548
  for (const source of sources) {
9623
- options.links.load(source?.links ?? source?.lineLinked ?? source?.line_linked);
9549
+ options.links.load(source?.links);
9624
9550
  }
9625
9551
  }
9626
9552
  reset() {}
@@ -10373,90 +10299,6 @@ class StrokeColorUpdater {
10373
10299
  async function loadStrokeColorUpdater(engine, refresh = true) {
10374
10300
  await engine.addParticleUpdater("strokeColor", container => new StrokeColorUpdater(container), refresh);
10375
10301
  }
10376
- ;// CONCATENATED MODULE: ../../shapes/text/dist/browser/TextDrawer.js
10377
-
10378
- const validTypes = ["text", "character", "char", "multiline-text"];
10379
- class TextDrawer {
10380
- constructor() {
10381
- this._drawLine = (context, line, radius, opacity, index, fill) => {
10382
- const offsetX = line.length * radius / 2,
10383
- pos = {
10384
- x: -offsetX,
10385
- y: radius / 2
10386
- };
10387
- if (fill) {
10388
- context.fillText(line, pos.x, pos.y + radius * 2 * index);
10389
- } else {
10390
- context.strokeText(line, pos.x, pos.y + radius * 2 * index);
10391
- }
10392
- };
10393
- }
10394
- draw(data) {
10395
- const {
10396
- context,
10397
- particle,
10398
- radius,
10399
- opacity
10400
- } = data,
10401
- character = particle.shapeData;
10402
- if (!character) {
10403
- return;
10404
- }
10405
- const textData = character.value;
10406
- if (textData === undefined) {
10407
- return;
10408
- }
10409
- if (particle.text === undefined) {
10410
- particle.text = itemFromSingleOrMultiple(textData, particle.randomIndexData);
10411
- }
10412
- const text = particle.text,
10413
- style = character.style ?? "",
10414
- weight = character.weight ?? "400",
10415
- size = Math.round(radius) * 2,
10416
- font = character.font ?? "Verdana",
10417
- fill = particle.shapeFill;
10418
- const lines = text?.split("\n");
10419
- if (!lines) {
10420
- return;
10421
- }
10422
- context.font = `${style} ${weight} ${size}px "${font}"`;
10423
- context.globalAlpha = opacity;
10424
- for (let i = 0; i < lines.length; i++) {
10425
- this._drawLine(context, lines[i], radius, opacity, i, fill);
10426
- }
10427
- context.globalAlpha = 1;
10428
- }
10429
- async init(container) {
10430
- const options = container.actualOptions;
10431
- if (validTypes.find(t => isInArray(t, options.particles.shape.type))) {
10432
- const shapeOptions = validTypes.map(t => options.particles.shape.options[t]).find(t => !!t),
10433
- promises = [];
10434
- executeOnSingleOrMultiple(shapeOptions, shape => {
10435
- promises.push(loadFont(shape.font, shape.weight));
10436
- });
10437
- await Promise.all(promises);
10438
- }
10439
- }
10440
- particleInit(container, particle) {
10441
- if (!particle.shape || !validTypes.includes(particle.shape)) {
10442
- return;
10443
- }
10444
- const character = particle.shapeData;
10445
- if (character === undefined) {
10446
- return;
10447
- }
10448
- const textData = character.value;
10449
- if (textData === undefined) {
10450
- return;
10451
- }
10452
- particle.text = itemFromSingleOrMultiple(textData, particle.randomIndexData);
10453
- }
10454
- }
10455
- ;// CONCATENATED MODULE: ../../shapes/text/dist/browser/index.js
10456
-
10457
- async function loadTextShape(engine, refresh = true) {
10458
- await engine.addShape(validTypes, new TextDrawer(), refresh);
10459
- }
10460
10302
  ;// CONCATENATED MODULE: ./dist/browser/index.js
10461
10303
 
10462
10304
 
@@ -10481,11 +10323,9 @@ async function loadTextShape(engine, refresh = true) {
10481
10323
 
10482
10324
 
10483
10325
 
10484
-
10485
10326
 
10486
10327
 
10487
10328
  async function loadSlim(engine, refresh = true) {
10488
- initPjs(engine);
10489
10329
  await loadParallaxMover(engine, false);
10490
10330
  await loadExternalAttractInteraction(engine, false);
10491
10331
  await loadExternalBounceInteraction(engine, false);
@@ -10501,12 +10341,12 @@ async function loadSlim(engine, refresh = true) {
10501
10341
  await loadParticlesCollisionsInteraction(engine, false);
10502
10342
  await loadParticlesLinksInteraction(engine, false);
10503
10343
  await loadEasingQuadPlugin();
10344
+ await loadEmojiShape(engine, false);
10504
10345
  await loadImageShape(engine, false);
10505
10346
  await loadLineShape(engine, false);
10506
10347
  await loadPolygonShape(engine, false);
10507
10348
  await loadSquareShape(engine, false);
10508
10349
  await loadStarShape(engine, false);
10509
- await loadTextShape(engine, false);
10510
10350
  await loadLifeUpdater(engine, false);
10511
10351
  await loadRotateUpdater(engine, false);
10512
10352
  await loadStrokeColorUpdater(engine, false);