@tsparticles/slim 3.0.0-beta.5 → 3.0.1

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.5
7
+ * v3.0.1
8
8
  */
9
9
  (function webpackUniversalModuleDefinition(root, factory) {
10
10
  if(typeof exports === 'object' && typeof module === 'object')
@@ -1227,7 +1227,8 @@ function drawParticle(data) {
1227
1227
  particle,
1228
1228
  radius,
1229
1229
  opacity,
1230
- delta
1230
+ delta,
1231
+ transformData
1231
1232
  };
1232
1233
  context.beginPath();
1233
1234
  drawShape(drawData);
@@ -1252,7 +1253,8 @@ function drawEffect(data) {
1252
1253
  particle,
1253
1254
  radius,
1254
1255
  opacity,
1255
- delta
1256
+ delta,
1257
+ transformData
1256
1258
  } = data;
1257
1259
  if (!particle.effect) {
1258
1260
  return;
@@ -1267,7 +1269,10 @@ function drawEffect(data) {
1267
1269
  radius,
1268
1270
  opacity,
1269
1271
  delta,
1270
- pixelRatio: container.retina.pixelRatio
1272
+ pixelRatio: container.retina.pixelRatio,
1273
+ transformData: {
1274
+ ...transformData
1275
+ }
1271
1276
  });
1272
1277
  }
1273
1278
  function drawShape(data) {
@@ -1277,7 +1282,8 @@ function drawShape(data) {
1277
1282
  particle,
1278
1283
  radius,
1279
1284
  opacity,
1280
- delta
1285
+ delta,
1286
+ transformData
1281
1287
  } = data;
1282
1288
  if (!particle.shape) {
1283
1289
  return;
@@ -1292,7 +1298,10 @@ function drawShape(data) {
1292
1298
  radius,
1293
1299
  opacity,
1294
1300
  delta,
1295
- pixelRatio: container.retina.pixelRatio
1301
+ pixelRatio: container.retina.pixelRatio,
1302
+ transformData: {
1303
+ ...transformData
1304
+ }
1296
1305
  });
1297
1306
  }
1298
1307
  function drawShapeAfterDraw(data) {
@@ -1302,7 +1311,8 @@ function drawShapeAfterDraw(data) {
1302
1311
  particle,
1303
1312
  radius,
1304
1313
  opacity,
1305
- delta
1314
+ delta,
1315
+ transformData
1306
1316
  } = data;
1307
1317
  if (!particle.shape) {
1308
1318
  return;
@@ -1317,7 +1327,10 @@ function drawShapeAfterDraw(data) {
1317
1327
  radius,
1318
1328
  opacity,
1319
1329
  delta,
1320
- pixelRatio: container.retina.pixelRatio
1330
+ pixelRatio: container.retina.pixelRatio,
1331
+ transformData: {
1332
+ ...transformData
1333
+ }
1321
1334
  });
1322
1335
  }
1323
1336
  function drawPlugin(context, plugin, delta) {
@@ -1554,7 +1567,7 @@ class Canvas {
1554
1567
  } else if (trailFill.image) {
1555
1568
  this._paintImage(trailFill.image, trailFill.opacity);
1556
1569
  }
1557
- } else {
1570
+ } else if (options.clear) {
1558
1571
  this.draw(ctx => {
1559
1572
  clear(ctx, this.size);
1560
1573
  });
@@ -3518,6 +3531,7 @@ class Options {
3518
3531
  this.autoPlay = true;
3519
3532
  this.background = new Background();
3520
3533
  this.backgroundMask = new BackgroundMask();
3534
+ this.clear = true;
3521
3535
  this.defaultThemes = {};
3522
3536
  this.delay = 0;
3523
3537
  this.fullScreen = new FullScreen();
@@ -3545,6 +3559,12 @@ class Options {
3545
3559
  if (data.autoPlay !== undefined) {
3546
3560
  this.autoPlay = data.autoPlay;
3547
3561
  }
3562
+ if (data.clear !== undefined) {
3563
+ this.clear = data.clear;
3564
+ }
3565
+ if (data.name !== undefined) {
3566
+ this.name = data.name;
3567
+ }
3548
3568
  if (data.delay !== undefined) {
3549
3569
  this.delay = setRangeValue(data.delay);
3550
3570
  }
@@ -4237,7 +4257,7 @@ class Particles {
4237
4257
  if (!options.number.density?.enable) {
4238
4258
  if (group === undefined) {
4239
4259
  this._limit = numberOptions.limit.value;
4240
- } else {
4260
+ } else if (numberOptions.limit) {
4241
4261
  this._groupLimits.set(group, numberOptions.limit.value);
4242
4262
  }
4243
4263
  return;
@@ -5126,7 +5146,7 @@ class Engine {
5126
5146
  return res;
5127
5147
  }
5128
5148
  get version() {
5129
- return "3.0.0-beta.5";
5149
+ return "3.0.1";
5130
5150
  }
5131
5151
  addConfig(config) {
5132
5152
  const name = config.name ?? "default";
@@ -6237,7 +6257,7 @@ class OutOutMode {
6237
6257
  }
6238
6258
  case "normal":
6239
6259
  {
6240
- const wrap = particle.options.move.warp,
6260
+ const warp = particle.options.move.warp,
6241
6261
  canvasSize = container.canvas.size,
6242
6262
  newPos = {
6243
6263
  bottom: canvasSize.height + particle.getRadius() + particle.offset.y,
@@ -6250,27 +6270,27 @@ class OutOutMode {
6250
6270
  if (direction === "right" && nextBounds.left > canvasSize.width + particle.offset.x) {
6251
6271
  particle.position.x = newPos.left;
6252
6272
  particle.initialPosition.x = particle.position.x;
6253
- if (!wrap) {
6273
+ if (!warp) {
6254
6274
  particle.position.y = getRandom() * canvasSize.height;
6255
6275
  particle.initialPosition.y = particle.position.y;
6256
6276
  }
6257
6277
  } else if (direction === "left" && nextBounds.right < -particle.offset.x) {
6258
6278
  particle.position.x = newPos.right;
6259
6279
  particle.initialPosition.x = particle.position.x;
6260
- if (!wrap) {
6280
+ if (!warp) {
6261
6281
  particle.position.y = getRandom() * canvasSize.height;
6262
6282
  particle.initialPosition.y = particle.position.y;
6263
6283
  }
6264
6284
  }
6265
6285
  if (direction === "bottom" && nextBounds.top > canvasSize.height + particle.offset.y) {
6266
- if (!wrap) {
6286
+ if (!warp) {
6267
6287
  particle.position.x = getRandom() * canvasSize.width;
6268
6288
  particle.initialPosition.x = particle.position.x;
6269
6289
  }
6270
6290
  particle.position.y = newPos.top;
6271
6291
  particle.initialPosition.y = particle.position.y;
6272
6292
  } else if (direction === "top" && nextBounds.bottom < -particle.offset.y) {
6273
- if (!wrap) {
6293
+ if (!warp) {
6274
6294
  particle.position.x = getRandom() * canvasSize.width;
6275
6295
  particle.initialPosition.x = particle.position.x;
6276
6296
  }
@@ -6448,7 +6468,7 @@ class EmojiDrawer {
6448
6468
  }
6449
6469
  destroy() {
6450
6470
  for (const [, emojiData] of this._emojiShapeDict) {
6451
- emojiData?.close();
6471
+ emojiData instanceof ImageBitmap && emojiData?.close();
6452
6472
  }
6453
6473
  }
6454
6474
  draw(data) {
@@ -6499,17 +6519,33 @@ class EmojiDrawer {
6499
6519
  particle.emojiData = existingData;
6500
6520
  return;
6501
6521
  }
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;
6522
+ const canvasSize = getRangeMax(particle.size.value) * 2;
6523
+ let emojiData;
6524
+ if (typeof OffscreenCanvas !== "undefined") {
6525
+ const canvas = new OffscreenCanvas(canvasSize, canvasSize),
6526
+ context = canvas.getContext("2d");
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;
6507
6548
  }
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
6549
  this._emojiShapeDict.set(key, emojiData);
6514
6550
  particle.emojiData = emojiData;
6515
6551
  }