@tsparticles/plugin-poisson-disc 3.4.0 → 3.6.0-beta.0

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/cjs/index.js CHANGED
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.loadPoissonDiscPlugin = void 0;
3
+ exports.loadPoissonDiscPlugin = loadPoissonDiscPlugin;
4
4
  const PoissonDiscPlugin_js_1 = require("./PoissonDiscPlugin.js");
5
5
  async function loadPoissonDiscPlugin(engine, refresh = true) {
6
6
  await engine.addPlugin(new PoissonDiscPlugin_js_1.PoissonDiscPlugin(engine), refresh);
7
7
  }
8
- exports.loadPoissonDiscPlugin = loadPoissonDiscPlugin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/plugin-poisson-disc",
3
- "version": "3.4.0",
3
+ "version": "3.6.0-beta.0",
4
4
  "description": "tsParticles poisson disc plugin",
5
5
  "homepage": "https://particles.js.org",
6
6
  "repository": {
@@ -85,7 +85,7 @@
85
85
  "./package.json": "./package.json"
86
86
  },
87
87
  "dependencies": {
88
- "@tsparticles/engine": "^3.4.0"
88
+ "@tsparticles/engine": "^3.6.0-beta.0"
89
89
  },
90
90
  "publishConfig": {
91
91
  "access": "public"
package/report.html CHANGED
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
  <meta charset="UTF-8"/>
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1"/>
6
- <title>@tsparticles/plugin-poisson-disc [13 May 2024 at 00:11]</title>
6
+ <title>@tsparticles/plugin-poisson-disc [7 Oct 2024 at 10:36]</title>
7
7
  <link rel="shortcut icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAABrVBMVEUAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+O1foceMD///+J0/qK1Pr7/v8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a0Ndb1YGHFPEwoqAinoaykaID1o1pdPNu7XsnCKQ3R+hwWIIhGvORcJUBYXe3Xa3vq/mF/N9V13ugufMkfXn+KHsRD0B8AAAAASUVORK5CYII=" type="image/x-icon" />
8
8
 
9
9
  <script>
@@ -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.4.0
7
+ * v3.6.0-beta.0
8
8
  */
9
9
  /*
10
10
  * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see tsparticles.plugin.poisson.min.js.LICENSE.txt */
2
- !function(i,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],t);else{var s="object"==typeof exports?t(require("@tsparticles/engine")):t(i.window);for(var e in s)("object"==typeof exports?exports:i)[e]=s[e]}}(this,(i=>(()=>{var t={303:t=>{t.exports=i}},s={};function e(i){var o=s[i];if(void 0!==o)return o.exports;var n=s[i]={exports:{}};return t[i](n,n.exports,e),n.exports}e.d=(i,t)=>{for(var s in t)e.o(t,s)&&!e.o(i,s)&&Object.defineProperty(i,s,{enumerable:!0,get:t[s]})},e.o=(i,t)=>Object.prototype.hasOwnProperty.call(i,t),e.r=i=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(i,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(i,"__esModule",{value:!0})};var o={};return(()=>{e.r(o),e.d(o,{loadPoissonDiscPlugin:()=>h});class i{constructor(){this.enable=!1,this.dimensions=2,this.radius=0,this.retries=30,this.steps=0}load(i){i&&(void 0!==i.enable&&(this.enable=i.enable),void 0!==i.dimensions&&(this.dimensions=i.dimensions),void 0!==i.radius&&(this.radius=i.radius),void 0!==i.retries&&(this.retries=i.retries))}}var t=e(303);const s=2*Math.PI;class n{constructor(i,t,s,e,o){this.size={...i},this.radius=t,this.retries=s,this.dimensions=e,this.cellSize=Math.floor(this.radius/Math.sqrt(this.dimensions)),this.cols=Math.floor(this.size.width/this.cellSize),this.rows=Math.floor(this.size.height/this.cellSize),this.points=[],this.active=[],this.grid=[],this.firstPoint=o?{...o}:void 0,this.reset()}addPoint(i){const t={position:{...i},gridPosition:{x:Math.floor(i.x/this.cellSize),y:Math.floor(i.y/this.cellSize)}},s=this.points.length;this.points.push(t),this.grid[t.gridPosition.y][t.gridPosition.x]=s,this.active.push(s)}getRandom(i,s){return Math.floor((0,t.getRandom)()*(s-i))+i}initialiseGrid(){for(let i=0;i<=this.rows;i++){this.grid[i]=[];for(let t=0;t<=this.cols;t++)this.grid[i][t]=-1}}reset(){if(this.points=[],this.active=[],this.grid=[],this.initialiseGrid(),this.firstPoint)this.addPoint(this.firstPoint);else{const i=0;this.addPoint({x:this.getRandom(i,this.size.width),y:this.getRandom(i,this.size.height)})}}async run(){this.reset();for(;this.active.length>0;)await this.steps(1)}async steps(i){for(let t=0;t<i;t++)this.active.length<=0||await this._step()}_getNewPoint(i,e){const o=e*(s/this.retries),n=this.getRandom(this.radius,2*this.radius),r=Math.cos(o)*n,a=Math.sin(o)*n,h={x:Math.floor(i.position.x+r),y:Math.floor(i.position.y+a)},l=Math.floor(h.x/this.cellSize),c=Math.floor(h.y/this.cellSize);if(h.x>0&&h.x<this.size.width&&h.y>0&&h.y<this.size.height&&this.grid[c][l]<0){for(let i=-1;i<=1;i++)for(let s=-1;s<=1;s++){const e={x:l+s,y:c+i};if(e.x>=0&&e.y>=0&&e.x<this.cols&&e.y<this.rows&&(e.x!==l||e.y!==c)&&this.grid[e.y][e.x]>=0){const i=this.grid[e.y][e.x],s=this.points[i];if((0,t.getDistance)(h,s.position)<this.radius)return}}return h}}async _step(){const i=this.getRandom(0,this.active.length);return new Promise((t=>{let s=!1;for(let t=0;t<this.retries;t++){const e=this._getNewPoint(this.points[this.active[i]],t);if(e){s=!0,this.addPoint(e);break}}if(!s){const t=1;this.active.splice(i,t)}t()}))}}class r{constructor(i,t){this._container=i,this._engine=t,this._currentIndex=0}async init(){await this._initData()}particlePosition(i){const t=this._container.actualOptions.poisson;if(this.poissonDisc&&t?.enable&&!(this._currentIndex>=this.poissonDisc.points.length))return i??this.poissonDisc?.points[this._currentIndex++]?.position}resize(){const i=this._container,t=i.actualOptions.poisson;if(!t?.enable)return;this.redrawTimeout&&clearTimeout(this.redrawTimeout);this.redrawTimeout=window.setTimeout((()=>{(async()=>{await this._initData(),await i.particles.redraw()})()}),250)}stop(){delete this.poissonDisc}async _initData(){const i=this._container,s=i.actualOptions.poisson,e=i.actualOptions.particles,o=i.canvas.size,r=i.retina.pixelRatio;if(!s?.enable)return;this._currentIndex=0,this.poissonDisc=new n(o,s.radius?s.radius*r:Math.max((0,t.getRangeMax)(e.size.value)*r,Math.sqrt(o.width*o.height/e.number.value)),s.retries,s.dimensions);s.steps>0?await this.poissonDisc.steps(s.steps):await this.poissonDisc.run()}}class a{constructor(i){this.id="poisson",this._engine=i}getPlugin(i){return Promise.resolve(new r(i,this._engine))}loadOptions(t,s){if(!this.needsPlugin(t)&&!this.needsPlugin(s))return;let e=t.poisson;void 0===e?.load&&(t.poisson=e=new i),e.load(s?.poisson)}needsPlugin(i){return i?.poisson?.enable??!1}}async function h(i,t=!0){await i.addPlugin(new a(i),t)}})(),o})()));
2
+ !function(i,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],t);else{var s="object"==typeof exports?t(require("@tsparticles/engine")):t(i.window);for(var e in s)("object"==typeof exports?exports:i)[e]=s[e]}}(this,(i=>(()=>{var t={303:t=>{t.exports=i}},s={};function e(i){var o=s[i];if(void 0!==o)return o.exports;var n=s[i]={exports:{}};return t[i](n,n.exports,e),n.exports}e.d=(i,t)=>{for(var s in t)e.o(t,s)&&!e.o(i,s)&&Object.defineProperty(i,s,{enumerable:!0,get:t[s]})},e.o=(i,t)=>Object.prototype.hasOwnProperty.call(i,t),e.r=i=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(i,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(i,"__esModule",{value:!0})};var o={};e.r(o),e.d(o,{loadPoissonDiscPlugin:()=>d});class n{constructor(){this.enable=!1,this.dimensions=2,this.radius=0,this.retries=30,this.steps=0}load(i){i&&(void 0!==i.enable&&(this.enable=i.enable),void 0!==i.dimensions&&(this.dimensions=i.dimensions),void 0!==i.radius&&(this.radius=i.radius),void 0!==i.retries&&(this.retries=i.retries))}}var r=e(303);const a=2*Math.PI;class h{constructor(i,t,s,e,o){this.size={...i},this.radius=t,this.retries=s,this.dimensions=e,this.cellSize=Math.floor(this.radius/Math.sqrt(this.dimensions)),this.cols=Math.floor(this.size.width/this.cellSize),this.rows=Math.floor(this.size.height/this.cellSize),this.points=[],this.active=[],this.grid=[],this.firstPoint=o?{...o}:void 0,this.reset()}addPoint(i){const t={position:{...i},gridPosition:{x:Math.floor(i.x/this.cellSize),y:Math.floor(i.y/this.cellSize)}},s=this.points.length;this.points.push(t),this.grid[t.gridPosition.y][t.gridPosition.x]=s,this.active.push(s)}getRandom(i,t){return Math.floor((0,r.getRandom)()*(t-i))+i}initialiseGrid(){for(let i=0;i<=this.rows;i++){this.grid[i]=[];for(let t=0;t<=this.cols;t++)this.grid[i][t]=-1}}reset(){if(this.points=[],this.active=[],this.grid=[],this.initialiseGrid(),this.firstPoint)this.addPoint(this.firstPoint);else{const i=0;this.addPoint({x:this.getRandom(i,this.size.width),y:this.getRandom(i,this.size.height)})}}async run(){this.reset();for(;this.active.length>0;)await this.steps(1)}async steps(i){for(let t=0;t<i;t++)this.active.length<=0||await this._step()}_getNewPoint(i,t){const s=t*(a/this.retries),e=this.getRandom(this.radius,2*this.radius),o=Math.cos(s)*e,n=Math.sin(s)*e,h={x:Math.floor(i.position.x+o),y:Math.floor(i.position.y+n)},l=Math.floor(h.x/this.cellSize),c=Math.floor(h.y/this.cellSize);if(h.x>0&&h.x<this.size.width&&h.y>0&&h.y<this.size.height&&this.grid[c][l]<0){for(let i=-1;i<=1;i++)for(let t=-1;t<=1;t++){const s={x:l+t,y:c+i};if(s.x>=0&&s.y>=0&&s.x<this.cols&&s.y<this.rows&&(s.x!==l||s.y!==c)&&this.grid[s.y][s.x]>=0){const i=this.grid[s.y][s.x],t=this.points[i];if((0,r.getDistance)(h,t.position)<this.radius)return}}return h}}async _step(){const i=this.getRandom(0,this.active.length);return new Promise((t=>{let s=!1;for(let t=0;t<this.retries;t++){const e=this._getNewPoint(this.points[this.active[i]],t);if(e){s=!0,this.addPoint(e);break}}if(!s){const t=1;this.active.splice(i,t)}t()}))}}class l{constructor(i,t){this._container=i,this._engine=t,this._currentIndex=0}async init(){await this._initData()}particlePosition(i){const t=this._container.actualOptions.poisson;if(this.poissonDisc&&t?.enable&&!(this._currentIndex>=this.poissonDisc.points.length))return i??this.poissonDisc?.points[this._currentIndex++]?.position}resize(){const i=this._container,t=i.actualOptions.poisson;if(!t?.enable)return;this.redrawTimeout&&clearTimeout(this.redrawTimeout);this.redrawTimeout=window.setTimeout((()=>{(async()=>{await this._initData(),await i.particles.redraw()})()}),250)}stop(){delete this.poissonDisc}async _initData(){const i=this._container,t=i.actualOptions.poisson,s=i.actualOptions.particles,e=i.canvas.size,o=i.retina.pixelRatio;if(!t?.enable)return;this._currentIndex=0,this.poissonDisc=new h(e,t.radius?t.radius*o:Math.max((0,r.getRangeMax)(s.size.value)*o,Math.sqrt(e.width*e.height/s.number.value)),t.retries,t.dimensions);t.steps>0?await this.poissonDisc.steps(t.steps):await this.poissonDisc.run()}}class c{constructor(i){this.id="poisson",this._engine=i}getPlugin(i){return Promise.resolve(new l(i,this._engine))}loadOptions(i,t){if(!this.needsPlugin(i)&&!this.needsPlugin(t))return;let s=i.poisson;void 0===s?.load&&(i.poisson=s=new n),s.load(t?.poisson)}needsPlugin(i){return i?.poisson?.enable??!1}}async function d(i,t=!0){await i.addPlugin(new c(i),t)}return o})()));
@@ -1 +1 @@
1
- /*! tsParticles Poisson Disc Plugin v3.4.0 by Matteo Bruni */
1
+ /*! tsParticles Poisson Disc Plugin v3.6.0-beta.0 by Matteo Bruni */
package/umd/index.js CHANGED
@@ -9,10 +9,9 @@
9
9
  })(function (require, exports) {
10
10
  "use strict";
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.loadPoissonDiscPlugin = void 0;
12
+ exports.loadPoissonDiscPlugin = loadPoissonDiscPlugin;
13
13
  const PoissonDiscPlugin_js_1 = require("./PoissonDiscPlugin.js");
14
14
  async function loadPoissonDiscPlugin(engine, refresh = true) {
15
15
  await engine.addPlugin(new PoissonDiscPlugin_js_1.PoissonDiscPlugin(engine), refresh);
16
16
  }
17
- exports.loadPoissonDiscPlugin = loadPoissonDiscPlugin;
18
17
  });