@tsparticles/confetti 4.0.0-beta.15 → 4.0.0-beta.17

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.
@@ -1,5 +1,5 @@
1
1
  (function(g){g.__tsParticlesInternals=g.__tsParticlesInternals||{};g.__tsParticlesInternals.bundles=g.__tsParticlesInternals.bundles||{};g.__tsParticlesInternals.effects=g.__tsParticlesInternals.effects||{};g.__tsParticlesInternals.engine=g.__tsParticlesInternals.engine||{};g.__tsParticlesInternals.interactions=g.__tsParticlesInternals.interactions||{};g.__tsParticlesInternals.palettes=g.__tsParticlesInternals.palettes||{};g.__tsParticlesInternals.paths=g.__tsParticlesInternals.paths||{};g.__tsParticlesInternals.plugins=g.__tsParticlesInternals.plugins||{};g.__tsParticlesInternals.plugins=g.__tsParticlesInternals.plugins||{};g.__tsParticlesInternals.plugins.emittersShapes=g.__tsParticlesInternals.plugins.emittersShapes||{};g.__tsParticlesInternals.presets=g.__tsParticlesInternals.presets||{};g.__tsParticlesInternals.shapes=g.__tsParticlesInternals.shapes||{};g.__tsParticlesInternals.updaters=g.__tsParticlesInternals.updaters||{};g.__tsParticlesInternals.utils=g.__tsParticlesInternals.utils||{};g.__tsParticlesInternals.canvas=g.__tsParticlesInternals.canvas||{};g.__tsParticlesInternals.canvas=g.__tsParticlesInternals.canvas||{};g.__tsParticlesInternals.canvas.utils=g.__tsParticlesInternals.canvas.utils||{};g.__tsParticlesInternals.path=g.__tsParticlesInternals.path||{};g.__tsParticlesInternals.path=g.__tsParticlesInternals.path||{};g.__tsParticlesInternals.path.utils=g.__tsParticlesInternals.path.utils||{};var __tsProxyFactory=typeof Proxy!=="undefined"?function(obj){return new Proxy(obj,{get:function(target,key){if(!(key in target)){target[key]={};}return target[key];}});}:function(obj){return obj;};g.__tsParticlesInternals.bundles=__tsProxyFactory(g.__tsParticlesInternals.bundles);g.__tsParticlesInternals.effects=__tsProxyFactory(g.__tsParticlesInternals.effects);g.__tsParticlesInternals.interactions=__tsProxyFactory(g.__tsParticlesInternals.interactions);g.__tsParticlesInternals.palettes=__tsProxyFactory(g.__tsParticlesInternals.palettes);g.__tsParticlesInternals.paths=__tsProxyFactory(g.__tsParticlesInternals.paths);g.__tsParticlesInternals.plugins=__tsProxyFactory(g.__tsParticlesInternals.plugins);g.__tsParticlesInternals.plugins.emittersShapes=__tsProxyFactory(g.__tsParticlesInternals.plugins.emittersShapes);g.__tsParticlesInternals.presets=__tsProxyFactory(g.__tsParticlesInternals.presets);g.__tsParticlesInternals.shapes=__tsProxyFactory(g.__tsParticlesInternals.shapes);g.__tsParticlesInternals.updaters=__tsProxyFactory(g.__tsParticlesInternals.updaters);g.__tsParticlesInternals.utils=__tsProxyFactory(g.__tsParticlesInternals.utils);g.__tsParticlesInternals.canvas=__tsProxyFactory(g.__tsParticlesInternals.canvas);g.__tsParticlesInternals.path=__tsProxyFactory(g.__tsParticlesInternals.path);g.tsparticlesInternalExports=g.tsparticlesInternalExports||{};})(typeof globalThis!=="undefined"?globalThis:typeof window!=="undefined"?window:this);
2
- /* tsParticles v4.0.0-beta.15 */
2
+ /* tsParticles v4.0.0-beta.17 */
3
3
  (function (global, factory) {
4
4
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
5
5
  typeof define === 'function' && define.amd ? define(['exports'], factory) :
@@ -1081,7 +1081,7 @@
1081
1081
  }
1082
1082
  }
1083
1083
  else {
1084
- const existingCanvases = domContainer.getElementsByTagName(canvasTag), foundCanvas = existingCanvases[canvasFirstIndex];
1084
+ const existingCanvases = domContainer.getElementsByTagName(canvasTag), foundCanvas = existingCanvases.item(canvasFirstIndex);
1085
1085
  if (foundCanvas) {
1086
1086
  canvasEl = foundCanvas;
1087
1087
  canvasEl.dataset[generatedAttribute] = generatedFalse;
@@ -1118,7 +1118,7 @@
1118
1118
  return this._domArray;
1119
1119
  }
1120
1120
  get version() {
1121
- return "4.0.0-beta.15";
1121
+ return "4.0.0-beta.17";
1122
1122
  }
1123
1123
  addEventListener(type, listener) {
1124
1124
  this._eventDispatcher.addEventListener(type, listener);
@@ -1149,7 +1149,11 @@
1149
1149
  }
1150
1150
  async load(params) {
1151
1151
  await this.init();
1152
- const { Container } = await Promise.resolve().then(function () { return Container$1; }), id = params.id ?? params.element?.id ?? `tsparticles${Math.floor(getRandom() * loadRandomFactor).toString()}`, { index, url } = params, options = url ? await getDataFromUrl({ fallback: params.options, url, index }) : params.options, currentOptions = itemFromSingleOrMultiple(options, index), { items } = this, oldIndex = items.findIndex(v => v.id.description === id), newItem = new Container({
1152
+ let domSourceElement;
1153
+ if (typeof HTMLElement !== "undefined" && params.element instanceof HTMLElement) {
1154
+ domSourceElement = params.element;
1155
+ }
1156
+ const { Container } = await Promise.resolve().then(function () { return Container$1; }), id = params.id ?? domSourceElement?.id ?? `tsparticles${Math.floor(getRandom() * loadRandomFactor).toString()}`, { index, url } = params, options = url ? await getDataFromUrl({ fallback: params.options, url, index }) : params.options, currentOptions = itemFromSingleOrMultiple(options, index), { items } = this, oldIndex = items.findIndex(v => v.id.description === id), newItem = new Container({
1153
1157
  dispatchCallback: (eventType, args) => {
1154
1158
  this.dispatchEvent(eventType, args);
1155
1159
  },
@@ -1176,8 +1180,10 @@
1176
1180
  else {
1177
1181
  items.push(newItem);
1178
1182
  }
1179
- const domContainer = getDomContainer(id, params.element), canvasEl = getCanvasFromContainer(domContainer);
1180
- newItem.canvas.loadCanvas(canvasEl);
1183
+ const sourceCanvas = typeof OffscreenCanvas !== "undefined" && params.element instanceof OffscreenCanvas
1184
+ ? params.element
1185
+ : getCanvasFromContainer(getDomContainer(id, domSourceElement));
1186
+ newItem.canvas.loadCanvas(sourceCanvas);
1181
1187
  await newItem.start();
1182
1188
  return newItem;
1183
1189
  }
@@ -3034,7 +3040,7 @@
3034
3040
  }
3035
3041
 
3036
3042
  async function loadCircleShape(engine) {
3037
- engine.checkVersion("4.0.0-beta.15");
3043
+ engine.checkVersion("4.0.0-beta.17");
3038
3044
  await engine.pluginManager.register(e => {
3039
3045
  e.pluginManager.addShape(["circle"], () => {
3040
3046
  return Promise.resolve(new CircleDrawer());
@@ -3082,7 +3088,7 @@
3082
3088
  }
3083
3089
 
3084
3090
  async function loadHexColorPlugin(engine) {
3085
- engine.checkVersion("4.0.0-beta.15");
3091
+ engine.checkVersion("4.0.0-beta.17");
3086
3092
  await engine.pluginManager.register(e => {
3087
3093
  e.pluginManager.addColorManager("hex", new HexColorManager());
3088
3094
  });
@@ -3135,7 +3141,7 @@
3135
3141
  }
3136
3142
 
3137
3143
  async function loadHslColorPlugin(engine) {
3138
- engine.checkVersion("4.0.0-beta.15");
3144
+ engine.checkVersion("4.0.0-beta.17");
3139
3145
  await engine.pluginManager.register(e => {
3140
3146
  e.pluginManager.addColorManager("hsl", new HslColorManager());
3141
3147
  });
@@ -3159,7 +3165,7 @@
3159
3165
  }
3160
3166
 
3161
3167
  async function loadMovePlugin(engine) {
3162
- engine.checkVersion("4.0.0-beta.15");
3168
+ engine.checkVersion("4.0.0-beta.17");
3163
3169
  await engine.pluginManager.register(e => {
3164
3170
  const moveEngine = e, movePluginManager = moveEngine.pluginManager;
3165
3171
  movePluginManager.initializers.pathGenerators ??= new Map();
@@ -3220,7 +3226,7 @@
3220
3226
  }
3221
3227
 
3222
3228
  async function loadOpacityUpdater(engine) {
3223
- engine.checkVersion("4.0.0-beta.15");
3229
+ engine.checkVersion("4.0.0-beta.17");
3224
3230
  await engine.pluginManager.register(e => {
3225
3231
  e.pluginManager.addParticleUpdater("opacity", container => {
3226
3232
  return Promise.resolve(new OpacityUpdater(container));
@@ -3572,7 +3578,7 @@
3572
3578
  }
3573
3579
 
3574
3580
  async function loadOutModesUpdater(engine) {
3575
- engine.checkVersion("4.0.0-beta.15");
3581
+ engine.checkVersion("4.0.0-beta.17");
3576
3582
  await engine.pluginManager.register(e => {
3577
3583
  e.pluginManager.addParticleUpdater("outModes", container => {
3578
3584
  return Promise.resolve(new OutOfCanvasUpdater(container));
@@ -3643,7 +3649,7 @@
3643
3649
  }
3644
3650
 
3645
3651
  async function loadPaintUpdater(engine) {
3646
- engine.checkVersion("4.0.0-beta.15");
3652
+ engine.checkVersion("4.0.0-beta.17");
3647
3653
  await engine.pluginManager.register(e => {
3648
3654
  e.pluginManager.addParticleUpdater("paint", container => {
3649
3655
  return Promise.resolve(new PaintUpdater(e.pluginManager, container));
@@ -3698,7 +3704,7 @@
3698
3704
  }
3699
3705
 
3700
3706
  async function loadRgbColorPlugin(engine) {
3701
- engine.checkVersion("4.0.0-beta.15");
3707
+ engine.checkVersion("4.0.0-beta.17");
3702
3708
  await engine.pluginManager.register(e => {
3703
3709
  e.pluginManager.addColorManager("rgb", new RgbColorManager());
3704
3710
  });
@@ -3741,7 +3747,7 @@
3741
3747
  }
3742
3748
 
3743
3749
  async function loadSizeUpdater(engine) {
3744
- engine.checkVersion("4.0.0-beta.15");
3750
+ engine.checkVersion("4.0.0-beta.17");
3745
3751
  await engine.pluginManager.register(e => {
3746
3752
  e.pluginManager.addParticleUpdater("size", container => {
3747
3753
  return Promise.resolve(new SizeUpdater(container));
@@ -3750,7 +3756,7 @@
3750
3756
  }
3751
3757
 
3752
3758
  async function loadBasic(engine) {
3753
- engine.checkVersion("4.0.0-beta.15");
3759
+ engine.checkVersion("4.0.0-beta.17");
3754
3760
  await engine.pluginManager.register(async (e) => {
3755
3761
  await Promise.all([
3756
3762
  loadHexColorPlugin(e),
@@ -4049,7 +4055,7 @@
4049
4055
  }
4050
4056
 
4051
4057
  async function loadClubsSuitShape(engine) {
4052
- engine.checkVersion("4.0.0-beta.15");
4058
+ engine.checkVersion("4.0.0-beta.17");
4053
4059
  await engine.pluginManager.register(e => {
4054
4060
  e.pluginManager.addShape(["club", "clubs"], () => Promise.resolve(new ClubDrawer()));
4055
4061
  });
@@ -4063,7 +4069,7 @@
4063
4069
  }
4064
4070
 
4065
4071
  async function loadDiamondsSuitShape(engine) {
4066
- engine.checkVersion("4.0.0-beta.15");
4072
+ engine.checkVersion("4.0.0-beta.17");
4067
4073
  await engine.pluginManager.register(e => {
4068
4074
  e.pluginManager.addShape(["diamond", "diamonds"], () => Promise.resolve(new DiamondDrawer()));
4069
4075
  });
@@ -4077,7 +4083,7 @@
4077
4083
  };
4078
4084
 
4079
4085
  async function loadHeartsSuitShape(engine) {
4080
- engine.checkVersion("4.0.0-beta.15");
4086
+ engine.checkVersion("4.0.0-beta.17");
4081
4087
  await engine.pluginManager.register(e => {
4082
4088
  e.pluginManager.addShape(["heart", "hearts"], () => Promise.resolve(new HeartDrawer$1()));
4083
4089
  });
@@ -4091,14 +4097,14 @@
4091
4097
  }
4092
4098
 
4093
4099
  async function loadSpadesSuitShape(engine) {
4094
- engine.checkVersion("4.0.0-beta.15");
4100
+ engine.checkVersion("4.0.0-beta.17");
4095
4101
  await engine.pluginManager.register(e => {
4096
4102
  e.pluginManager.addShape(["spade", "spades"], () => Promise.resolve(new SpadeDrawer()));
4097
4103
  });
4098
4104
  }
4099
4105
 
4100
4106
  async function loadCardSuitsShape(engine) {
4101
- engine.checkVersion("4.0.0-beta.15");
4107
+ engine.checkVersion("4.0.0-beta.17");
4102
4108
  await Promise.all([
4103
4109
  loadClubsSuitShape(engine),
4104
4110
  loadDiamondsSuitShape(engine),
@@ -4375,7 +4381,7 @@
4375
4381
  })(EmitterClickMode || (EmitterClickMode = {}));
4376
4382
 
4377
4383
  async function loadEmittersPluginSimple(engine) {
4378
- engine.checkVersion("4.0.0-beta.15");
4384
+ engine.checkVersion("4.0.0-beta.17");
4379
4385
  await engine.pluginManager.register(async (e) => {
4380
4386
  const instancesManager = await getEmittersInstancesManager(e);
4381
4387
  await addEmittersShapesManager(e);
@@ -4462,19 +4468,7 @@
4462
4468
  particle.emojiDataKey = cacheKey;
4463
4469
  return;
4464
4470
  }
4465
- const padding = emojiOptions.padding * double, maxSize = getRangeMax(particle.size.value), fullSize = maxSize + padding, canvasSize = fullSize * double;
4466
- let cacheCanvas, context;
4467
- if (typeof OffscreenCanvas === "undefined") {
4468
- const canvas = safeDocument().createElement("canvas");
4469
- canvas.width = canvasSize;
4470
- canvas.height = canvasSize;
4471
- context = canvas.getContext("2d", container.canvas.render.settings);
4472
- cacheCanvas = canvas;
4473
- }
4474
- else {
4475
- cacheCanvas = new OffscreenCanvas(canvasSize, canvasSize);
4476
- context = cacheCanvas.getContext("2d", container.canvas.render.settings);
4477
- }
4471
+ const padding = emojiOptions.padding * double, maxSize = getRangeMax(particle.size.value), fullSize = maxSize + padding, canvasSize = fullSize * double, cacheCanvas = new OffscreenCanvas(canvasSize, canvasSize), context = cacheCanvas.getContext("2d", container.canvas.render.settings);
4478
4472
  if (!context) {
4479
4473
  return;
4480
4474
  }
@@ -4489,7 +4483,7 @@
4489
4483
  }
4490
4484
 
4491
4485
  async function loadEmojiShape(engine) {
4492
- engine.checkVersion("4.0.0-beta.15");
4486
+ engine.checkVersion("4.0.0-beta.17");
4493
4487
  await engine.pluginManager.register(e => {
4494
4488
  e.pluginManager.addShape(validTypes, () => Promise.resolve(new EmojiDrawer()));
4495
4489
  });
@@ -4515,7 +4509,7 @@
4515
4509
  }
4516
4510
 
4517
4511
  async function loadHeartShape(engine) {
4518
- engine.checkVersion("4.0.0-beta.15");
4512
+ engine.checkVersion("4.0.0-beta.17");
4519
4513
  await engine.pluginManager.register(e => {
4520
4514
  e.pluginManager.addShape(["heart"], () => Promise.resolve(new HeartDrawer()));
4521
4515
  });
@@ -5340,7 +5334,7 @@
5340
5334
  };
5341
5335
  }
5342
5336
  async function loadImageShape(engine) {
5343
- engine.checkVersion("4.0.0-beta.15");
5337
+ engine.checkVersion("4.0.0-beta.17");
5344
5338
  await engine.pluginManager.register(e => {
5345
5339
  addLoadImageToEngine(e);
5346
5340
  e.pluginManager.addPlugin(new ImagePreloaderPlugin(e));
@@ -5507,7 +5501,7 @@
5507
5501
  }
5508
5502
 
5509
5503
  async function loadLifeUpdater(engine) {
5510
- engine.checkVersion("4.0.0-beta.15");
5504
+ engine.checkVersion("4.0.0-beta.17");
5511
5505
  await engine.pluginManager.register(e => {
5512
5506
  e.pluginManager.addParticleUpdater("life", container => {
5513
5507
  return Promise.resolve(new LifeUpdater(container));
@@ -5575,7 +5569,7 @@
5575
5569
  }
5576
5570
 
5577
5571
  async function loadMotionPlugin(engine) {
5578
- engine.checkVersion("4.0.0-beta.15");
5572
+ engine.checkVersion("4.0.0-beta.17");
5579
5573
  await engine.pluginManager.register(e => {
5580
5574
  e.pluginManager.addPlugin(new MotionPlugin());
5581
5575
  });
@@ -5660,19 +5654,19 @@
5660
5654
  }
5661
5655
 
5662
5656
  async function loadGenericPolygonShape(engine) {
5663
- engine.checkVersion("4.0.0-beta.15");
5657
+ engine.checkVersion("4.0.0-beta.17");
5664
5658
  await engine.pluginManager.register(e => {
5665
5659
  e.pluginManager.addShape(["polygon"], () => Promise.resolve(new PolygonDrawer()));
5666
5660
  });
5667
5661
  }
5668
5662
  async function loadTriangleShape(engine) {
5669
- engine.checkVersion("4.0.0-beta.15");
5663
+ engine.checkVersion("4.0.0-beta.17");
5670
5664
  await engine.pluginManager.register(e => {
5671
5665
  e.pluginManager.addShape(["triangle"], () => Promise.resolve(new TriangleDrawer()));
5672
5666
  });
5673
5667
  }
5674
5668
  async function loadPolygonShape(engine) {
5675
- engine.checkVersion("4.0.0-beta.15");
5669
+ engine.checkVersion("4.0.0-beta.17");
5676
5670
  await Promise.all([
5677
5671
  loadGenericPolygonShape(engine),
5678
5672
  loadTriangleShape(engine),
@@ -5830,7 +5824,7 @@
5830
5824
  }
5831
5825
 
5832
5826
  async function loadRollUpdater(engine) {
5833
- engine.checkVersion("4.0.0-beta.15");
5827
+ engine.checkVersion("4.0.0-beta.17");
5834
5828
  await engine.pluginManager.register(e => {
5835
5829
  e.pluginManager.addParticleUpdater("roll", () => {
5836
5830
  return Promise.resolve(new RollUpdater(e.pluginManager));
@@ -5964,7 +5958,7 @@
5964
5958
  }
5965
5959
 
5966
5960
  async function loadRotateUpdater(engine) {
5967
- engine.checkVersion("4.0.0-beta.15");
5961
+ engine.checkVersion("4.0.0-beta.17");
5968
5962
  await engine.pluginManager.register(e => {
5969
5963
  e.pluginManager.addParticleUpdater("rotate", container => {
5970
5964
  return Promise.resolve(new RotateUpdater(container));
@@ -5988,7 +5982,7 @@
5988
5982
  }
5989
5983
 
5990
5984
  async function loadSquareShape(engine) {
5991
- engine.checkVersion("4.0.0-beta.15");
5985
+ engine.checkVersion("4.0.0-beta.17");
5992
5986
  await engine.pluginManager.register(e => {
5993
5987
  e.pluginManager.addShape(["edge", "square"], () => Promise.resolve(new SquareDrawer()));
5994
5988
  });
@@ -6022,7 +6016,7 @@
6022
6016
  }
6023
6017
 
6024
6018
  async function loadStarShape(engine) {
6025
- engine.checkVersion("4.0.0-beta.15");
6019
+ engine.checkVersion("4.0.0-beta.17");
6026
6020
  await engine.pluginManager.register(e => {
6027
6021
  e.pluginManager.addShape(["star"], () => Promise.resolve(new StarDrawer()));
6028
6022
  });
@@ -6159,7 +6153,7 @@
6159
6153
  }
6160
6154
 
6161
6155
  async function loadTiltUpdater(engine) {
6162
- engine.checkVersion("4.0.0-beta.15");
6156
+ engine.checkVersion("4.0.0-beta.17");
6163
6157
  await engine.pluginManager.register(e => {
6164
6158
  e.pluginManager.addParticleUpdater("tilt", container => {
6165
6159
  return Promise.resolve(new TiltUpdater(container));
@@ -6281,7 +6275,7 @@
6281
6275
  }
6282
6276
 
6283
6277
  async function loadWobbleUpdater(engine) {
6284
- engine.checkVersion("4.0.0-beta.15");
6278
+ engine.checkVersion("4.0.0-beta.17");
6285
6279
  await engine.pluginManager.register(e => {
6286
6280
  e.pluginManager.addParticleUpdater("wobble", container => {
6287
6281
  return Promise.resolve(new WobbleUpdater(container));
@@ -6708,7 +6702,7 @@
6708
6702
 
6709
6703
  let initPromise = null;
6710
6704
  async function doInitPlugins(engine) {
6711
- engine.checkVersion("4.0.0-beta.15");
6705
+ engine.checkVersion("4.0.0-beta.17");
6712
6706
  await engine.pluginManager.register(async (e) => {
6713
6707
  await Promise.all([
6714
6708
  loadBasic(e),
@@ -6781,7 +6775,7 @@
6781
6775
  confetti.init = async () => {
6782
6776
  await initPlugins(tsParticles);
6783
6777
  };
6784
- confetti.version = "4.0.0-beta.15";
6778
+ confetti.version = "4.0.0-beta.17";
6785
6779
  globalThis.confetti = confetti;
6786
6780
 
6787
6781
  const globalObject = globalThis;
@@ -7089,6 +7083,25 @@
7089
7083
  };
7090
7084
  }
7091
7085
 
7086
+ const transferredCanvases = new WeakMap(), getTransferredCanvas = (canvas) => {
7087
+ const transferredCanvas = transferredCanvases.get(canvas);
7088
+ if (transferredCanvas) {
7089
+ return transferredCanvas;
7090
+ }
7091
+ if (typeof canvas.transferControlToOffscreen !== "function") {
7092
+ throw new TypeError("OffscreenCanvas is required but not supported by this browser");
7093
+ }
7094
+ try {
7095
+ const offscreenCanvas = canvas.transferControlToOffscreen();
7096
+ transferredCanvases.set(canvas, offscreenCanvas);
7097
+ return offscreenCanvas;
7098
+ }
7099
+ catch {
7100
+ throw new TypeError("OffscreenCanvas transfer failed");
7101
+ }
7102
+ }, isHtmlCanvasElement = (canvas) => {
7103
+ return typeof HTMLCanvasElement !== "undefined" && canvas instanceof HTMLCanvasElement;
7104
+ };
7092
7105
  function setStyle(canvas, style, important = false) {
7093
7106
  if (!style) {
7094
7107
  return;
@@ -7119,8 +7132,9 @@
7119
7132
  }
7120
7133
  }
7121
7134
  class CanvasManager {
7122
- element;
7135
+ domElement;
7123
7136
  render;
7137
+ renderCanvas;
7124
7138
  size;
7125
7139
  zoom = defaultZoom;
7126
7140
  _container;
@@ -7155,9 +7169,10 @@
7155
7169
  destroy() {
7156
7170
  this.stop();
7157
7171
  if (this._generated) {
7158
- const element = this.element;
7172
+ const element = this.domElement;
7159
7173
  element?.remove();
7160
- this.element = undefined;
7174
+ this.domElement = undefined;
7175
+ this.renderCanvas = undefined;
7161
7176
  }
7162
7177
  else {
7163
7178
  this._resetOriginalStyle();
@@ -7190,16 +7205,17 @@
7190
7205
  this._initStyle();
7191
7206
  this.initBackground();
7192
7207
  this._safeMutationObserver(obs => {
7193
- if (!this.element || !(this.element instanceof Node)) {
7208
+ const element = this.domElement;
7209
+ if (!element || !(element instanceof Node)) {
7194
7210
  return;
7195
7211
  }
7196
- obs.observe(this.element, { attributes: true });
7212
+ obs.observe(element, { attributes: true });
7197
7213
  });
7198
7214
  this.initPlugins();
7199
7215
  this.render.init();
7200
7216
  }
7201
7217
  initBackground() {
7202
- const { _container } = this, options = _container.actualOptions, background = options.background, element = this.element;
7218
+ const { _container } = this, options = _container.actualOptions, background = options.background, element = this.domElement;
7203
7219
  if (!element) {
7204
7220
  return;
7205
7221
  }
@@ -7224,21 +7240,30 @@
7224
7240
  }
7225
7241
  }
7226
7242
  loadCanvas(canvas) {
7227
- if (this._generated && this.element) {
7228
- this.element.remove();
7243
+ if (this._generated && this.domElement) {
7244
+ this.domElement.remove();
7245
+ }
7246
+ const container = this._container, domCanvas = isHtmlCanvasElement(canvas) ? canvas : undefined;
7247
+ this.domElement = domCanvas;
7248
+ this._generated = domCanvas ? domCanvas.dataset[generatedAttribute] === "true" : false;
7249
+ this.renderCanvas = domCanvas ? getTransferredCanvas(domCanvas) : canvas;
7250
+ const domElement = this.domElement;
7251
+ if (domElement) {
7252
+ domElement.ariaHidden = "true";
7253
+ this._originalStyle = cloneStyle(domElement.style);
7254
+ }
7255
+ const standardSize = this._standardSize, renderCanvas = this.renderCanvas;
7256
+ if (domElement) {
7257
+ standardSize.height = domElement.offsetHeight;
7258
+ standardSize.width = domElement.offsetWidth;
7259
+ }
7260
+ else {
7261
+ standardSize.height = renderCanvas.height;
7262
+ standardSize.width = renderCanvas.width;
7229
7263
  }
7230
- const container = this._container;
7231
- this._generated =
7232
- generatedAttribute in canvas.dataset ? canvas.dataset[generatedAttribute] === "true" : this._generated;
7233
- this.element = canvas;
7234
- this.element.ariaHidden = "true";
7235
- this._originalStyle = cloneStyle(this.element.style);
7236
- const standardSize = this._standardSize;
7237
- standardSize.height = canvas.offsetHeight;
7238
- standardSize.width = canvas.offsetWidth;
7239
7264
  const pxRatio = this._container.retina.pixelRatio, retinaSize = this.size;
7240
- canvas.height = retinaSize.height = standardSize.height * pxRatio;
7241
- canvas.width = retinaSize.width = standardSize.width * pxRatio;
7265
+ renderCanvas.height = retinaSize.height = standardSize.height * pxRatio;
7266
+ renderCanvas.width = retinaSize.width = standardSize.width * pxRatio;
7242
7267
  const canSupportHdrQuery = safeMatchMedia("(color-gamut: p3)");
7243
7268
  this.render.setContextSettings({
7244
7269
  alpha: true,
@@ -7246,42 +7271,48 @@
7246
7271
  desynchronized: true,
7247
7272
  willReadFrequently: false,
7248
7273
  });
7249
- this.render.setContext(this.element.getContext("2d", this.render.settings));
7274
+ this.render.setContext(renderCanvas.getContext("2d", this.render.settings));
7250
7275
  this._safeMutationObserver(obs => {
7251
7276
  obs.disconnect();
7252
7277
  });
7253
7278
  container.retina.init();
7254
7279
  this.initBackground();
7255
7280
  this._safeMutationObserver(obs => {
7256
- if (!this.element || !(this.element instanceof Node)) {
7281
+ const element = this.domElement;
7282
+ if (!element || !(element instanceof Node)) {
7257
7283
  return;
7258
7284
  }
7259
- obs.observe(this.element, { attributes: true });
7285
+ obs.observe(element, { attributes: true });
7260
7286
  });
7261
7287
  }
7262
7288
  resize() {
7263
- if (!this.element) {
7289
+ const element = this.domElement;
7290
+ if (!element) {
7291
+ return false;
7292
+ }
7293
+ const container = this._container, renderCanvas = this.renderCanvas;
7294
+ if (renderCanvas === undefined) {
7264
7295
  return false;
7265
7296
  }
7266
- const container = this._container, currentSize = container.canvas._standardSize, newSize = {
7267
- width: this.element.offsetWidth,
7268
- height: this.element.offsetHeight,
7297
+ const currentSize = container.canvas._standardSize, newSize = {
7298
+ width: element.offsetWidth,
7299
+ height: element.offsetHeight,
7269
7300
  }, pxRatio = container.retina.pixelRatio, retinaSize = {
7270
7301
  width: newSize.width * pxRatio,
7271
7302
  height: newSize.height * pxRatio,
7272
7303
  };
7273
7304
  if (newSize.height === currentSize.height &&
7274
7305
  newSize.width === currentSize.width &&
7275
- retinaSize.height === this.element.height &&
7276
- retinaSize.width === this.element.width) {
7306
+ retinaSize.height === renderCanvas.height &&
7307
+ retinaSize.width === renderCanvas.width) {
7277
7308
  return false;
7278
7309
  }
7279
7310
  const oldSize = { ...currentSize };
7280
7311
  currentSize.height = newSize.height;
7281
7312
  currentSize.width = newSize.width;
7282
7313
  const canvasSize = this.size;
7283
- this.element.width = canvasSize.width = retinaSize.width;
7284
- this.element.height = canvasSize.height = retinaSize.height;
7314
+ renderCanvas.width = canvasSize.width = retinaSize.width;
7315
+ renderCanvas.height = canvasSize.height = retinaSize.height;
7285
7316
  if (this._container.started) {
7286
7317
  container.particles.setResizeFactor({
7287
7318
  width: currentSize.width / oldSize.width,
@@ -7291,7 +7322,7 @@
7291
7322
  return true;
7292
7323
  }
7293
7324
  setPointerEvents(type) {
7294
- const element = this.element;
7325
+ const element = this.domElement;
7295
7326
  if (!element) {
7296
7327
  return;
7297
7328
  }
@@ -7310,7 +7341,7 @@
7310
7341
  this.render.stop();
7311
7342
  }
7312
7343
  async windowResize() {
7313
- if (!this.element || !this.resize()) {
7344
+ if (!this.domElement || !this.resize()) {
7314
7345
  return;
7315
7346
  }
7316
7347
  const container = this._container, needsRefresh = container.updateActualOptions();
@@ -7326,7 +7357,7 @@
7326
7357
  }
7327
7358
  };
7328
7359
  _initStyle = () => {
7329
- const element = this.element, options = this._container.actualOptions;
7360
+ const element = this.domElement, options = this._container.actualOptions;
7330
7361
  if (!element) {
7331
7362
  return;
7332
7363
  }
@@ -7348,7 +7379,7 @@
7348
7379
  }
7349
7380
  };
7350
7381
  _repairStyle = () => {
7351
- const element = this.element;
7382
+ const element = this.domElement;
7352
7383
  if (!element) {
7353
7384
  return;
7354
7385
  }
@@ -7368,7 +7399,7 @@
7368
7399
  });
7369
7400
  };
7370
7401
  _resetOriginalStyle = () => {
7371
- const element = this.element, originalStyle = this._originalStyle;
7402
+ const element = this.domElement, originalStyle = this._originalStyle;
7372
7403
  if (!element || !originalStyle) {
7373
7404
  return;
7374
7405
  }
@@ -7381,7 +7412,7 @@
7381
7412
  callback(this._mutationObserver);
7382
7413
  };
7383
7414
  _setFullScreenStyle = () => {
7384
- const element = this.element;
7415
+ const element = this.domElement;
7385
7416
  if (!element) {
7386
7417
  return;
7387
7418
  }
@@ -7455,7 +7486,7 @@
7455
7486
  manageListener(globalThis, resizeEvent, handlers.resize, add);
7456
7487
  return;
7457
7488
  }
7458
- const canvasEl = container.canvas.element;
7489
+ const canvasEl = container.canvas.domElement;
7459
7490
  if (this._resizeObserver && !add) {
7460
7491
  if (canvasEl) {
7461
7492
  this._resizeObserver.unobserve(canvasEl);
@@ -7710,8 +7741,6 @@
7710
7741
  this._initPosition(position);
7711
7742
  this.initialVelocity = this._calculateVelocity();
7712
7743
  this.velocity = this.initialVelocity.copy();
7713
- const particles = container.particles;
7714
- particles.setLastZIndex(this.position.z);
7715
7744
  this.zIndexFactor = this.position.z / container.zLayers;
7716
7745
  this.sides = 24;
7717
7746
  let effectDrawer, shapeDrawer;
@@ -7861,7 +7890,7 @@
7861
7890
  return color;
7862
7891
  };
7863
7892
  _initPosition = position => {
7864
- const container = this._container, zIndexValue = getRangeValue(this.options.zIndex.value), initialPosition = this._calcPosition(position, clamp(zIndexValue, minZ, container.zLayers));
7893
+ const container = this._container, zIndexValue = Math.floor(getRangeValue(this.options.zIndex.value)), initialPosition = this._calcPosition(position, clamp(zIndexValue, minZ, container.zLayers));
7865
7894
  if (!initialPosition) {
7866
7895
  throw new Error("a valid position cannot be found for particle");
7867
7896
  }
@@ -7995,10 +8024,8 @@
7995
8024
  _container;
7996
8025
  _groupLimits;
7997
8026
  _limit;
7998
- _maxZIndex;
7999
- _minZIndex;
8000
- _needsSort;
8001
8027
  _nextId;
8028
+ _particleBuckets;
8002
8029
  _particleResetPlugins;
8003
8030
  _particleUpdatePlugins;
8004
8031
  _pluginManager;
@@ -8007,19 +8034,17 @@
8007
8034
  _postUpdatePlugins;
8008
8035
  _resizeFactor;
8009
8036
  _updatePlugins;
8010
- _zArray;
8037
+ _zBuckets;
8011
8038
  constructor(pluginManager, container) {
8012
8039
  this._pluginManager = pluginManager;
8013
8040
  this._container = container;
8014
8041
  this._nextId = 0;
8015
8042
  this._array = [];
8016
- this._zArray = [];
8017
8043
  this._pool = [];
8018
8044
  this._limit = 0;
8019
8045
  this._groupLimits = new Map();
8020
- this._needsSort = false;
8021
- this._minZIndex = 0;
8022
- this._maxZIndex = 0;
8046
+ this._particleBuckets = new Map();
8047
+ this._zBuckets = this._createBuckets(this._container.zLayers);
8023
8048
  this.grid = new SpatialHashGrid(spatialHashGridCellSize);
8024
8049
  this.checkParticlePositionPlugins = [];
8025
8050
  this._particleResetPlugins = [];
@@ -8061,7 +8086,7 @@
8061
8086
  return;
8062
8087
  }
8063
8088
  this._array.push(particle);
8064
- this._zArray.push(particle);
8089
+ this._insertParticleIntoBucket(particle);
8065
8090
  this._nextId++;
8066
8091
  this._container.dispatchEvent(exports.EventType.particleAdded, {
8067
8092
  particle,
@@ -8075,12 +8100,14 @@
8075
8100
  }
8076
8101
  clear() {
8077
8102
  this._array = [];
8078
- this._zArray = [];
8103
+ this._particleBuckets.clear();
8104
+ this._resetBuckets(this._container.zLayers);
8079
8105
  }
8080
8106
  destroy() {
8081
8107
  this._array = [];
8082
8108
  this._pool.length = 0;
8083
- this._zArray = [];
8109
+ this._particleBuckets.clear();
8110
+ this._zBuckets = [];
8084
8111
  this.checkParticlePositionPlugins = [];
8085
8112
  this._particleResetPlugins = [];
8086
8113
  this._particleUpdatePlugins = [];
@@ -8089,8 +8116,14 @@
8089
8116
  this._updatePlugins = [];
8090
8117
  }
8091
8118
  drawParticles(delta) {
8092
- for (const particle of this._zArray) {
8093
- particle.draw(delta);
8119
+ for (let i = this._zBuckets.length - one; i >= minIndex; i--) {
8120
+ const bucket = this._zBuckets[i];
8121
+ if (!bucket) {
8122
+ continue;
8123
+ }
8124
+ for (const particle of bucket) {
8125
+ particle.draw(delta);
8126
+ }
8094
8127
  }
8095
8128
  }
8096
8129
  filter(condition) {
@@ -8104,15 +8137,14 @@
8104
8137
  }
8105
8138
  async init() {
8106
8139
  const container = this._container, options = container.actualOptions;
8107
- this._minZIndex = 0;
8108
- this._maxZIndex = 0;
8109
- this._needsSort = false;
8110
8140
  this.checkParticlePositionPlugins = [];
8111
8141
  this._updatePlugins = [];
8112
8142
  this._particleUpdatePlugins = [];
8113
8143
  this._postUpdatePlugins = [];
8114
8144
  this._particleResetPlugins = [];
8115
8145
  this._postParticleUpdatePlugins = [];
8146
+ this._particleBuckets.clear();
8147
+ this._resetBuckets(container.zLayers);
8116
8148
  this.grid = new SpatialHashGrid(spatialHashGridCellSize * container.retina.pixelRatio);
8117
8149
  for (const plugin of container.plugins) {
8118
8150
  if (plugin.redrawInit) {
@@ -8213,79 +8245,25 @@
8213
8245
  }
8214
8246
  this._applyDensity(options.particles, pluginsCount);
8215
8247
  }
8216
- setLastZIndex(zIndex) {
8217
- this._needsSort ||= zIndex >= this._maxZIndex || (zIndex > this._minZIndex && zIndex < this._maxZIndex);
8218
- }
8219
8248
  setResizeFactor(factor) {
8220
8249
  this._resizeFactor = factor;
8221
8250
  }
8222
8251
  update(delta) {
8223
- const particlesToDelete = new Set();
8224
8252
  this.grid.clear();
8225
8253
  for (const plugin of this._updatePlugins) {
8226
8254
  plugin.update?.(delta);
8227
8255
  }
8228
- const resizeFactor = this._resizeFactor;
8229
- for (const particle of this._array) {
8230
- if (resizeFactor && !particle.ignoresResizeRatio) {
8231
- particle.position.x *= resizeFactor.width;
8232
- particle.position.y *= resizeFactor.height;
8233
- particle.initialPosition.x *= resizeFactor.width;
8234
- particle.initialPosition.y *= resizeFactor.height;
8235
- }
8236
- particle.ignoresResizeRatio = false;
8237
- for (const plugin of this._particleResetPlugins) {
8238
- plugin.particleReset?.(particle);
8239
- }
8240
- for (const plugin of this._particleUpdatePlugins) {
8241
- if (particle.destroyed) {
8242
- break;
8243
- }
8244
- plugin.particleUpdate?.(particle, delta);
8245
- }
8246
- if (particle.destroyed) {
8247
- particlesToDelete.add(particle);
8248
- continue;
8249
- }
8250
- this.grid.insert(particle);
8251
- }
8256
+ const particlesToDelete = this._updateParticlesPhase1(delta);
8252
8257
  for (const plugin of this._postUpdatePlugins) {
8253
8258
  plugin.postUpdate?.(delta);
8254
8259
  }
8255
- for (const particle of this._array) {
8256
- if (particle.destroyed) {
8257
- particlesToDelete.add(particle);
8258
- continue;
8259
- }
8260
- for (const updater of this._container.particleUpdaters) {
8261
- updater.update(particle, delta);
8262
- }
8263
- if (!particle.destroyed && !particle.spawning) {
8264
- for (const plugin of this._postParticleUpdatePlugins) {
8265
- plugin.postParticleUpdate?.(particle, delta);
8266
- }
8267
- }
8268
- else if (particle.destroyed) {
8269
- particlesToDelete.add(particle);
8270
- }
8271
- }
8260
+ this._updateParticlesPhase2(delta, particlesToDelete);
8272
8261
  if (particlesToDelete.size) {
8273
8262
  for (const particle of particlesToDelete) {
8274
8263
  this.remove(particle);
8275
8264
  }
8276
8265
  }
8277
8266
  delete this._resizeFactor;
8278
- if (this._needsSort) {
8279
- const zArray = this._zArray;
8280
- zArray.sort((a, b) => b.position.z - a.position.z || a.id - b.id);
8281
- const firstItem = zArray[minIndex], lastItem = zArray[zArray.length - lengthOffset];
8282
- if (!firstItem || !lastItem) {
8283
- return;
8284
- }
8285
- this._maxZIndex = firstItem.position.z;
8286
- this._minZIndex = lastItem.position.z;
8287
- this._needsSort = false;
8288
- }
8289
8267
  }
8290
8268
  _addToPool = (...particles) => {
8291
8269
  this._pool.push(...particles);
@@ -8315,13 +8293,52 @@
8315
8293
  this.removeQuantity(particlesCount - particlesNumber, group);
8316
8294
  }
8317
8295
  };
8296
+ _createBuckets = (zLayers) => {
8297
+ const bucketCount = Math.max(Math.floor(zLayers), one);
8298
+ return Array.from({ length: bucketCount }, () => []);
8299
+ };
8300
+ _getBucketIndex = (zIndex) => {
8301
+ const maxBucketIndex = this._zBuckets.length - one;
8302
+ if (maxBucketIndex <= minIndex) {
8303
+ return minIndex;
8304
+ }
8305
+ return Math.min(Math.max(Math.floor(zIndex), minIndex), maxBucketIndex);
8306
+ };
8307
+ _getParticleInsertIndex = (bucket, particleId) => {
8308
+ let start = minIndex, end = bucket.length;
8309
+ while (start < end) {
8310
+ const middle = Math.floor((start + end) / double), middleParticle = bucket[middle];
8311
+ if (!middleParticle) {
8312
+ end = middle;
8313
+ continue;
8314
+ }
8315
+ if (middleParticle.id < particleId) {
8316
+ start = middle + one;
8317
+ }
8318
+ else {
8319
+ end = middle;
8320
+ }
8321
+ }
8322
+ return start;
8323
+ };
8318
8324
  _initDensityFactor = densityOptions => {
8319
8325
  const container = this._container;
8320
- if (!container.canvas.element || !densityOptions.enable) {
8326
+ if (!densityOptions.enable) {
8321
8327
  return defaultDensityFactor;
8322
8328
  }
8323
- const canvas = container.canvas.element, pxRatio = container.retina.pixelRatio;
8324
- return (canvas.width * canvas.height) / (densityOptions.height * densityOptions.width * pxRatio ** squareExp);
8329
+ const canvasSize = container.canvas.size, pxRatio = container.retina.pixelRatio;
8330
+ if (!canvasSize.width || !canvasSize.height) {
8331
+ return defaultDensityFactor;
8332
+ }
8333
+ return ((canvasSize.width * canvasSize.height) / (densityOptions.height * densityOptions.width * pxRatio ** squareExp));
8334
+ };
8335
+ _insertParticleIntoBucket = (particle) => {
8336
+ const bucketIndex = this._getBucketIndex(particle.position.z), bucket = this._zBuckets[bucketIndex];
8337
+ if (!bucket) {
8338
+ return;
8339
+ }
8340
+ bucket.splice(this._getParticleInsertIndex(bucket, particle.id), empty, particle);
8341
+ this._particleBuckets.set(particle.id, bucketIndex);
8325
8342
  };
8326
8343
  _removeParticle = (index, group, override) => {
8327
8344
  const particle = this._array[index];
@@ -8331,9 +8348,8 @@
8331
8348
  if (particle.group !== group) {
8332
8349
  return false;
8333
8350
  }
8334
- const zIdx = this._zArray.indexOf(particle);
8335
8351
  this._array.splice(index, deleteCount);
8336
- this._zArray.splice(zIdx, deleteCount);
8352
+ this._removeParticleFromBucket(particle);
8337
8353
  particle.destroy(override);
8338
8354
  this._container.dispatchEvent(exports.EventType.particleRemoved, {
8339
8355
  particle,
@@ -8341,6 +8357,98 @@
8341
8357
  this._addToPool(particle);
8342
8358
  return true;
8343
8359
  };
8360
+ _removeParticleFromBucket = (particle) => {
8361
+ const bucketIndex = this._particleBuckets.get(particle.id) ?? this._getBucketIndex(particle.position.z), bucket = this._zBuckets[bucketIndex];
8362
+ if (!bucket) {
8363
+ this._particleBuckets.delete(particle.id);
8364
+ return;
8365
+ }
8366
+ const particleIndex = this._getParticleInsertIndex(bucket, particle.id);
8367
+ if (bucket[particleIndex]?.id !== particle.id) {
8368
+ this._particleBuckets.delete(particle.id);
8369
+ return;
8370
+ }
8371
+ bucket.splice(particleIndex, deleteCount);
8372
+ this._particleBuckets.delete(particle.id);
8373
+ };
8374
+ _resetBuckets = (zLayers) => {
8375
+ const bucketCount = Math.max(Math.floor(zLayers), one);
8376
+ if (this._zBuckets.length !== bucketCount) {
8377
+ this._zBuckets = this._createBuckets(bucketCount);
8378
+ return;
8379
+ }
8380
+ for (const bucket of this._zBuckets) {
8381
+ bucket.length = minIndex;
8382
+ }
8383
+ };
8384
+ _updateParticleBucket = (particle) => {
8385
+ const newBucketIndex = this._getBucketIndex(particle.position.z), currentBucketIndex = this._particleBuckets.get(particle.id);
8386
+ if (currentBucketIndex === undefined) {
8387
+ this._insertParticleIntoBucket(particle);
8388
+ return;
8389
+ }
8390
+ if (currentBucketIndex === newBucketIndex) {
8391
+ return;
8392
+ }
8393
+ const currentBucket = this._zBuckets[currentBucketIndex];
8394
+ if (currentBucket) {
8395
+ const particleIndex = this._getParticleInsertIndex(currentBucket, particle.id);
8396
+ if (currentBucket[particleIndex]?.id === particle.id) {
8397
+ currentBucket.splice(particleIndex, deleteCount);
8398
+ }
8399
+ }
8400
+ const newBucket = this._zBuckets[newBucketIndex];
8401
+ if (!newBucket) {
8402
+ this._particleBuckets.set(particle.id, newBucketIndex);
8403
+ return;
8404
+ }
8405
+ newBucket.splice(this._getParticleInsertIndex(newBucket, particle.id), empty, particle);
8406
+ this._particleBuckets.set(particle.id, newBucketIndex);
8407
+ };
8408
+ _updateParticlesPhase1 = (delta) => {
8409
+ const particlesToDelete = new Set(), resizeFactor = this._resizeFactor;
8410
+ for (const particle of this._array) {
8411
+ if (resizeFactor && !particle.ignoresResizeRatio) {
8412
+ particle.position.x *= resizeFactor.width;
8413
+ particle.position.y *= resizeFactor.height;
8414
+ particle.initialPosition.x *= resizeFactor.width;
8415
+ particle.initialPosition.y *= resizeFactor.height;
8416
+ }
8417
+ particle.ignoresResizeRatio = false;
8418
+ for (const plugin of this._particleResetPlugins) {
8419
+ plugin.particleReset?.(particle);
8420
+ }
8421
+ for (const plugin of this._particleUpdatePlugins) {
8422
+ if (particle.destroyed) {
8423
+ break;
8424
+ }
8425
+ plugin.particleUpdate?.(particle, delta);
8426
+ }
8427
+ if (particle.destroyed) {
8428
+ particlesToDelete.add(particle);
8429
+ continue;
8430
+ }
8431
+ this.grid.insert(particle);
8432
+ }
8433
+ return particlesToDelete;
8434
+ };
8435
+ _updateParticlesPhase2 = (delta, particlesToDelete) => {
8436
+ for (const particle of this._array) {
8437
+ if (particle.destroyed) {
8438
+ particlesToDelete.add(particle);
8439
+ continue;
8440
+ }
8441
+ for (const updater of this._container.particleUpdaters) {
8442
+ updater.update(particle, delta);
8443
+ }
8444
+ if (!particle.spawning) {
8445
+ for (const plugin of this._postParticleUpdatePlugins) {
8446
+ plugin.postParticleUpdate?.(particle, delta);
8447
+ }
8448
+ }
8449
+ this._updateParticleBucket(particle);
8450
+ }
8451
+ };
8344
8452
  }
8345
8453
 
8346
8454
  class Retina {
@@ -8356,9 +8464,8 @@
8356
8464
  const container = this.container, options = container.actualOptions;
8357
8465
  this.pixelRatio = options.detectRetina ? devicePixelRatio : defaultRatio;
8358
8466
  this.reduceFactor = defaultReduceFactor;
8359
- const ratio = this.pixelRatio, canvas = container.canvas;
8360
- if (canvas.element) {
8361
- const element = canvas.element;
8467
+ const ratio = this.pixelRatio, canvas = container.canvas, element = canvas.domElement;
8468
+ if (element) {
8362
8469
  canvas.size.width = element.offsetWidth * ratio;
8363
8470
  canvas.size.height = element.offsetHeight * ratio;
8364
8471
  }