tsparticles 1.42.0 → 1.42.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.
Files changed (81) hide show
  1. package/Core/Canvas.d.ts +1 -1
  2. package/Core/Canvas.js +16 -7
  3. package/Core/Particles.js +2 -3
  4. package/Plugins/Emitters/Options/Classes/Emitter.js +2 -2
  5. package/browser/Core/Canvas.d.ts +1 -1
  6. package/browser/Core/Canvas.js +16 -7
  7. package/browser/Core/Particles.js +3 -4
  8. package/browser/Plugins/Emitters/Options/Classes/Emitter.js +2 -2
  9. package/esm/Core/Canvas.d.ts +1 -1
  10. package/esm/Core/Canvas.js +16 -7
  11. package/esm/Core/Particles.js +2 -3
  12. package/esm/Plugins/Emitters/Options/Classes/Emitter.js +2 -2
  13. package/package.json +15 -3
  14. package/report.html +2 -2
  15. package/report.slim.html +2 -2
  16. package/tsparticles.engine.js +15 -10
  17. package/tsparticles.engine.min.js +2 -2
  18. package/tsparticles.interaction.external.attract.js +15 -10
  19. package/tsparticles.interaction.external.attract.min.js +1 -1
  20. package/tsparticles.interaction.external.bounce.js +15 -10
  21. package/tsparticles.interaction.external.bounce.min.js +1 -1
  22. package/tsparticles.interaction.external.bubble.js +15 -10
  23. package/tsparticles.interaction.external.bubble.min.js +1 -1
  24. package/tsparticles.interaction.external.connect.js +15 -10
  25. package/tsparticles.interaction.external.connect.min.js +1 -1
  26. package/tsparticles.interaction.external.grab.js +15 -10
  27. package/tsparticles.interaction.external.grab.min.js +1 -1
  28. package/tsparticles.interaction.external.repulse.js +15 -10
  29. package/tsparticles.interaction.external.repulse.min.js +1 -1
  30. package/tsparticles.interaction.external.trail.js +15 -10
  31. package/tsparticles.interaction.external.trail.min.js +1 -1
  32. package/tsparticles.interaction.particles.attract.js +15 -10
  33. package/tsparticles.interaction.particles.attract.min.js +1 -1
  34. package/tsparticles.interaction.particles.collisions.js +15 -10
  35. package/tsparticles.interaction.particles.collisions.min.js +1 -1
  36. package/tsparticles.interaction.particles.links.js +15 -10
  37. package/tsparticles.interaction.particles.links.min.js +1 -1
  38. package/tsparticles.js +17 -12
  39. package/tsparticles.min.js +2 -2
  40. package/tsparticles.pathseg.min.js +1 -1
  41. package/tsparticles.plugins.absorbers.js +15 -10
  42. package/tsparticles.plugins.absorbers.min.js +1 -1
  43. package/tsparticles.plugins.emitters.js +17 -12
  44. package/tsparticles.plugins.emitters.min.js +2 -2
  45. package/tsparticles.plugins.polygonMask.js +15 -10
  46. package/tsparticles.plugins.polygonMask.min.js +1 -1
  47. package/tsparticles.shape.circle.min.js +1 -1
  48. package/tsparticles.shape.image.js +15 -10
  49. package/tsparticles.shape.image.min.js +1 -1
  50. package/tsparticles.shape.line.min.js +1 -1
  51. package/tsparticles.shape.polygon.min.js +1 -1
  52. package/tsparticles.shape.square.min.js +1 -1
  53. package/tsparticles.shape.star.min.js +1 -1
  54. package/tsparticles.shape.text.js +15 -10
  55. package/tsparticles.shape.text.min.js +1 -1
  56. package/tsparticles.slim.js +15 -10
  57. package/tsparticles.slim.min.js +2 -2
  58. package/tsparticles.updater.angle.js +15 -10
  59. package/tsparticles.updater.angle.min.js +1 -1
  60. package/tsparticles.updater.color.js +15 -10
  61. package/tsparticles.updater.color.min.js +1 -1
  62. package/tsparticles.updater.life.js +15 -10
  63. package/tsparticles.updater.life.min.js +1 -1
  64. package/tsparticles.updater.opacity.js +15 -10
  65. package/tsparticles.updater.opacity.min.js +1 -1
  66. package/tsparticles.updater.outModes.js +15 -10
  67. package/tsparticles.updater.outModes.min.js +1 -1
  68. package/tsparticles.updater.roll.js +15 -10
  69. package/tsparticles.updater.roll.min.js +1 -1
  70. package/tsparticles.updater.size.js +15 -10
  71. package/tsparticles.updater.size.min.js +1 -1
  72. package/tsparticles.updater.strokeColor.js +15 -10
  73. package/tsparticles.updater.strokeColor.min.js +1 -1
  74. package/tsparticles.updater.tilt.js +15 -10
  75. package/tsparticles.updater.tilt.min.js +1 -1
  76. package/tsparticles.updater.wobble.js +15 -10
  77. package/tsparticles.updater.wobble.min.js +1 -1
  78. package/umd/Core/Canvas.d.ts +1 -1
  79. package/umd/Core/Canvas.js +16 -7
  80. package/umd/Core/Particles.js +2 -3
  81. package/umd/Plugins/Emitters/Options/Classes/Emitter.js +2 -2
package/Core/Canvas.d.ts CHANGED
@@ -8,7 +8,7 @@ export declare class Canvas {
8
8
  resizeFactor?: IDimension;
9
9
  private context;
10
10
  private generatedCanvas;
11
- private coverColor?;
11
+ private coverColorStyle?;
12
12
  private trailFillColor?;
13
13
  private originalStyle?;
14
14
  constructor(container: Container);
package/Core/Canvas.js CHANGED
@@ -50,9 +50,9 @@ class Canvas {
50
50
  paint() {
51
51
  const options = this.container.actualOptions;
52
52
  this.draw((ctx) => {
53
- if (options.backgroundMask.enable && options.backgroundMask.cover && this.coverColor) {
53
+ if (options.backgroundMask.enable && options.backgroundMask.cover) {
54
54
  (0, Utils_1.clear)(ctx, this.size);
55
- this.paintBase((0, Utils_1.getStyleFromRgb)(this.coverColor, this.coverColor.a));
55
+ this.paintBase(this.coverColorStyle);
56
56
  }
57
57
  else {
58
58
  this.paintBase();
@@ -98,11 +98,19 @@ class Canvas {
98
98
  const container = this.container;
99
99
  const pxRatio = container.retina.pixelRatio;
100
100
  const size = container.canvas.size;
101
+ const newSize = {
102
+ width: this.element.offsetWidth * pxRatio,
103
+ height: this.element.offsetHeight * pxRatio,
104
+ };
105
+ if (newSize.height === size.height &&
106
+ newSize.width === size.width &&
107
+ newSize.height === this.element.height &&
108
+ newSize.width === this.element.width) {
109
+ return;
110
+ }
101
111
  const oldSize = Object.assign({}, size);
102
- size.width = this.element.offsetWidth * pxRatio;
103
- size.height = this.element.offsetHeight * pxRatio;
104
- this.element.width = size.width;
105
- this.element.height = size.height;
112
+ this.element.width = size.width = this.element.offsetWidth * pxRatio;
113
+ this.element.height = size.height = this.element.offsetHeight * pxRatio;
106
114
  if (this.container.started) {
107
115
  this.resizeFactor = {
108
116
  width: size.width / oldSize.width,
@@ -229,12 +237,13 @@ class Canvas {
229
237
  const color = cover.color;
230
238
  const coverRgb = (0, Utils_1.colorToRgb)(color);
231
239
  if (coverRgb) {
232
- this.coverColor = {
240
+ const coverColor = {
233
241
  r: coverRgb.r,
234
242
  g: coverRgb.g,
235
243
  b: coverRgb.b,
236
244
  a: cover.opacity,
237
245
  };
246
+ this.coverColorStyle = (0, Utils_1.getStyleFromRgb)(coverColor, coverColor.a);
238
247
  }
239
248
  }
240
249
  initTrail() {
package/Core/Particles.js CHANGED
@@ -147,9 +147,7 @@ class Particles {
147
147
  delete container.canvas.resizeFactor;
148
148
  }
149
149
  async draw(delta) {
150
- const container = this.container;
151
- container.canvas.clear();
152
- const canvasSize = this.container.canvas.size;
150
+ const container = this.container, canvasSize = this.container.canvas.size;
153
151
  this.quadTree = new Utils_1.QuadTree(new Utils_1.Rectangle(-canvasSize.width / 4, -canvasSize.height / 4, (canvasSize.width * 3) / 2, (canvasSize.height * 3) / 2), 4);
154
152
  await this.update(delta);
155
153
  if (this.needsSort) {
@@ -157,6 +155,7 @@ class Particles {
157
155
  this.lastZIndex = this.zArray[this.zArray.length - 1].position.z;
158
156
  this.needsSort = false;
159
157
  }
158
+ container.canvas.clear();
160
159
  for (const [, plugin] of container.plugins) {
161
160
  container.canvas.drawPlugin(plugin, delta);
162
161
  }
@@ -46,10 +46,10 @@ class Emitter {
46
46
  }
47
47
  if (data.position !== undefined) {
48
48
  this.position = {};
49
- if (data.position.x) {
49
+ if (data.position.x !== undefined) {
50
50
  this.position.x = (0, Utils_1.setRangeValue)(data.position.x);
51
51
  }
52
- if (data.position.y) {
52
+ if (data.position.y !== undefined) {
53
53
  this.position.y = (0, Utils_1.setRangeValue)(data.position.y);
54
54
  }
55
55
  }
@@ -21,7 +21,7 @@ export declare class Canvas {
21
21
  */
22
22
  private context;
23
23
  private generatedCanvas;
24
- private coverColor?;
24
+ private coverColorStyle?;
25
25
  private trailFillColor?;
26
26
  private originalStyle?;
27
27
  /**
@@ -62,9 +62,9 @@ export class Canvas {
62
62
  paint() {
63
63
  const options = this.container.actualOptions;
64
64
  this.draw((ctx) => {
65
- if (options.backgroundMask.enable && options.backgroundMask.cover && this.coverColor) {
65
+ if (options.backgroundMask.enable && options.backgroundMask.cover) {
66
66
  clear(ctx, this.size);
67
- this.paintBase(getStyleFromRgb(this.coverColor, this.coverColor.a));
67
+ this.paintBase(this.coverColorStyle);
68
68
  }
69
69
  else {
70
70
  this.paintBase();
@@ -117,11 +117,19 @@ export class Canvas {
117
117
  const container = this.container;
118
118
  const pxRatio = container.retina.pixelRatio;
119
119
  const size = container.canvas.size;
120
+ const newSize = {
121
+ width: this.element.offsetWidth * pxRatio,
122
+ height: this.element.offsetHeight * pxRatio,
123
+ };
124
+ if (newSize.height === size.height &&
125
+ newSize.width === size.width &&
126
+ newSize.height === this.element.height &&
127
+ newSize.width === this.element.width) {
128
+ return;
129
+ }
120
130
  const oldSize = Object.assign({}, size);
121
- size.width = this.element.offsetWidth * pxRatio;
122
- size.height = this.element.offsetHeight * pxRatio;
123
- this.element.width = size.width;
124
- this.element.height = size.height;
131
+ this.element.width = size.width = this.element.offsetWidth * pxRatio;
132
+ this.element.height = size.height = this.element.offsetHeight * pxRatio;
125
133
  if (this.container.started) {
126
134
  this.resizeFactor = {
127
135
  width: size.width / oldSize.width,
@@ -248,12 +256,13 @@ export class Canvas {
248
256
  const color = cover.color;
249
257
  const coverRgb = colorToRgb(color);
250
258
  if (coverRgb) {
251
- this.coverColor = {
259
+ const coverColor = {
252
260
  r: coverRgb.r,
253
261
  g: coverRgb.g,
254
262
  b: coverRgb.b,
255
263
  a: cover.opacity,
256
264
  };
265
+ this.coverColorStyle = getStyleFromRgb(coverColor, coverColor.a);
257
266
  }
258
267
  }
259
268
  initTrail() {
@@ -158,10 +158,7 @@ export class Particles {
158
158
  delete container.canvas.resizeFactor;
159
159
  }
160
160
  async draw(delta) {
161
- const container = this.container;
162
- /* clear canvas */
163
- container.canvas.clear();
164
- const canvasSize = this.container.canvas.size;
161
+ const container = this.container, canvasSize = this.container.canvas.size;
165
162
  this.quadTree = new QuadTree(new Rectangle(-canvasSize.width / 4, -canvasSize.height / 4, (canvasSize.width * 3) / 2, (canvasSize.height * 3) / 2), 4);
166
163
  /* update each particles param */
167
164
  await this.update(delta);
@@ -170,6 +167,8 @@ export class Particles {
170
167
  this.lastZIndex = this.zArray[this.zArray.length - 1].position.z;
171
168
  this.needsSort = false;
172
169
  }
170
+ /* clear canvas */
171
+ container.canvas.clear();
173
172
  /* draw polygon shape in debug mode */
174
173
  for (const [, plugin] of container.plugins) {
175
174
  container.canvas.drawPlugin(plugin, delta);
@@ -47,10 +47,10 @@ export class Emitter {
47
47
  }
48
48
  if (data.position !== undefined) {
49
49
  this.position = {};
50
- if (data.position.x) {
50
+ if (data.position.x !== undefined) {
51
51
  this.position.x = setRangeValue(data.position.x);
52
52
  }
53
- if (data.position.y) {
53
+ if (data.position.y !== undefined) {
54
54
  this.position.y = setRangeValue(data.position.y);
55
55
  }
56
56
  }
@@ -8,7 +8,7 @@ export declare class Canvas {
8
8
  resizeFactor?: IDimension;
9
9
  private context;
10
10
  private generatedCanvas;
11
- private coverColor?;
11
+ private coverColorStyle?;
12
12
  private trailFillColor?;
13
13
  private originalStyle?;
14
14
  constructor(container: Container);
@@ -47,9 +47,9 @@ export class Canvas {
47
47
  paint() {
48
48
  const options = this.container.actualOptions;
49
49
  this.draw((ctx) => {
50
- if (options.backgroundMask.enable && options.backgroundMask.cover && this.coverColor) {
50
+ if (options.backgroundMask.enable && options.backgroundMask.cover) {
51
51
  clear(ctx, this.size);
52
- this.paintBase(getStyleFromRgb(this.coverColor, this.coverColor.a));
52
+ this.paintBase(this.coverColorStyle);
53
53
  }
54
54
  else {
55
55
  this.paintBase();
@@ -95,11 +95,19 @@ export class Canvas {
95
95
  const container = this.container;
96
96
  const pxRatio = container.retina.pixelRatio;
97
97
  const size = container.canvas.size;
98
+ const newSize = {
99
+ width: this.element.offsetWidth * pxRatio,
100
+ height: this.element.offsetHeight * pxRatio,
101
+ };
102
+ if (newSize.height === size.height &&
103
+ newSize.width === size.width &&
104
+ newSize.height === this.element.height &&
105
+ newSize.width === this.element.width) {
106
+ return;
107
+ }
98
108
  const oldSize = Object.assign({}, size);
99
- size.width = this.element.offsetWidth * pxRatio;
100
- size.height = this.element.offsetHeight * pxRatio;
101
- this.element.width = size.width;
102
- this.element.height = size.height;
109
+ this.element.width = size.width = this.element.offsetWidth * pxRatio;
110
+ this.element.height = size.height = this.element.offsetHeight * pxRatio;
103
111
  if (this.container.started) {
104
112
  this.resizeFactor = {
105
113
  width: size.width / oldSize.width,
@@ -226,12 +234,13 @@ export class Canvas {
226
234
  const color = cover.color;
227
235
  const coverRgb = colorToRgb(color);
228
236
  if (coverRgb) {
229
- this.coverColor = {
237
+ const coverColor = {
230
238
  r: coverRgb.r,
231
239
  g: coverRgb.g,
232
240
  b: coverRgb.b,
233
241
  a: cover.opacity,
234
242
  };
243
+ this.coverColorStyle = getStyleFromRgb(coverColor, coverColor.a);
235
244
  }
236
245
  }
237
246
  initTrail() {
@@ -144,9 +144,7 @@ export class Particles {
144
144
  delete container.canvas.resizeFactor;
145
145
  }
146
146
  async draw(delta) {
147
- const container = this.container;
148
- container.canvas.clear();
149
- const canvasSize = this.container.canvas.size;
147
+ const container = this.container, canvasSize = this.container.canvas.size;
150
148
  this.quadTree = new QuadTree(new Rectangle(-canvasSize.width / 4, -canvasSize.height / 4, (canvasSize.width * 3) / 2, (canvasSize.height * 3) / 2), 4);
151
149
  await this.update(delta);
152
150
  if (this.needsSort) {
@@ -154,6 +152,7 @@ export class Particles {
154
152
  this.lastZIndex = this.zArray[this.zArray.length - 1].position.z;
155
153
  this.needsSort = false;
156
154
  }
155
+ container.canvas.clear();
157
156
  for (const [, plugin] of container.plugins) {
158
157
  container.canvas.drawPlugin(plugin, delta);
159
158
  }
@@ -43,10 +43,10 @@ export class Emitter {
43
43
  }
44
44
  if (data.position !== undefined) {
45
45
  this.position = {};
46
- if (data.position.x) {
46
+ if (data.position.x !== undefined) {
47
47
  this.position.x = setRangeValue(data.position.x);
48
48
  }
49
- if (data.position.y) {
49
+ if (data.position.y !== undefined) {
50
50
  this.position.y = setRangeValue(data.position.y);
51
51
  }
52
52
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tsparticles",
3
- "version": "1.42.0",
4
- "description": "Easily create highly customizable particle animations and use them as animated backgrounds for your website. Ready to use components available also for React, Vue.js (2.x and 3.x), Angular, Svelte, jQuery, Preact, Riot.js, Inferno.",
3
+ "version": "1.42.3",
4
+ "description": "Easily create highly customizable particle, confetti and fireworks animations and use them as animated backgrounds for your website. Ready to use components available also for React, Vue.js (2.x and 3.x), Angular, Svelte, jQuery, Preact, Riot.js, Inferno.",
5
5
  "homepage": "https://particles.js.org/",
6
6
  "scripts": {
7
7
  "install": "node ./scripts/install.js"
@@ -30,6 +30,10 @@
30
30
  "react-particles",
31
31
  "react",
32
32
  "reactjs",
33
+ "vue-particles",
34
+ "ngx-particles",
35
+ "angular-particles",
36
+ "particleground",
33
37
  "vue",
34
38
  "vuejs",
35
39
  "preact",
@@ -48,7 +52,15 @@
48
52
  "html",
49
53
  "css3",
50
54
  "animated",
51
- "background"
55
+ "background",
56
+ "confetti",
57
+ "canvas",
58
+ "fireworks",
59
+ "fireworks-js",
60
+ "confetti-js",
61
+ "confettijs",
62
+ "fireworksjs",
63
+ "canvas-confetti"
52
64
  ],
53
65
  "author": "Matteo Bruni <matteo.bruni@me.com>",
54
66
  "contributors": [