@tsparticles/plugin-poisson-disc 3.6.0-beta.0 → 3.6.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.
@@ -1,3 +1,4 @@
1
+ import { isNull } from "@tsparticles/engine";
1
2
  export class Poisson {
2
3
  constructor() {
3
4
  this.enable = false;
@@ -7,7 +8,7 @@ export class Poisson {
7
8
  this.steps = 0;
8
9
  }
9
10
  load(data) {
10
- if (!data) {
11
+ if (isNull(data)) {
11
12
  return;
12
13
  }
13
14
  if (data.enable !== undefined) {
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Poisson = void 0;
4
+ const engine_1 = require("@tsparticles/engine");
4
5
  class Poisson {
5
6
  constructor() {
6
7
  this.enable = false;
@@ -10,7 +11,7 @@ class Poisson {
10
11
  this.steps = 0;
11
12
  }
12
13
  load(data) {
13
- if (!data) {
14
+ if ((0, engine_1.isNull)(data)) {
14
15
  return;
15
16
  }
16
17
  if (data.enable !== undefined) {
@@ -1,3 +1,4 @@
1
+ import { isNull } from "@tsparticles/engine";
1
2
  export class Poisson {
2
3
  constructor() {
3
4
  this.enable = false;
@@ -7,7 +8,7 @@ export class Poisson {
7
8
  this.steps = 0;
8
9
  }
9
10
  load(data) {
10
- if (!data) {
11
+ if (isNull(data)) {
11
12
  return;
12
13
  }
13
14
  if (data.enable !== undefined) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/plugin-poisson-disc",
3
- "version": "3.6.0-beta.0",
3
+ "version": "3.6.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.6.0-beta.0"
88
+ "@tsparticles/engine": "^3.6.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 [7 Oct 2024 at 10:36]</title>
6
+ <title>@tsparticles/plugin-poisson-disc [18 Nov 2024 at 23:56]</title>
7
7
  <link rel="shortcut icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAABrVBMVEUAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+O1foceMD///+J0/qK1Pr7/v8Xdr/9///W8P4UdL7L7P0Scr2r4Pyj3vwad8D5/f/2/f+55f3E6f34+/2H0/ojfMKpzOd0rNgQcb3F3O/j9f7c8v6g3Pz0/P/w+v/q+P7n9v6T1/uQ1vuE0vqLut/y+v+Z2fvt+f+15Pzv9fuc2/vR7v2V2Pvd6/bg9P7I6/285/2y4/yp3/zp8vk8i8kqgMT7/P31+fyv4vxGkcz6/P6/6P3j7vfS5PNnpNUxhcbO7f7F6v3O4vHK3/DA2u631Ouy0eqXweKJud5wqthfoNMMbLvY8f73+v2dxeR8sNtTmdDx9/zX6PSjyeaCtd1YnNGX2PuQveCGt95Nls42h8dLlM3F4vBtAAAAM3RSTlMAAyOx0/sKBvik8opWGBMOAe3l1snDm2E9LSb06eHcu5JpHbarfHZCN9CBb08zzkdNS0kYaptYAAAFV0lEQVRYw92X51/aYBDHHS2O2qqttVbrqNq9m+TJIAYIShBkWwqIiCgoWvfeq7Z2/s29hyQNyUcR7LveGwVyXy6XH8/9rqxglLfUPLxVduUor3h0rfp2TYvpivk37929TkG037hffoX0+peVtZQc1589rigVUdXS/ABSAyEmGIO/1XfvldSK8vs3OqB6u3m0nxmIrvgB0dj7rr7Y9IbuF68hnfFaiHA/sxqm0wciIG43P60qKv9WXWc1RXGh/mFESFABTSBi0sNAKzqet17eCtOb3kZIDwxEEU0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HHwVboBHGLiX6Zcjp1f2wu4tvzZKo0ecPnDtQYDQvJXaBeNzce45Fp28ZQLrEZVuFqgBwOalArKXnW1UzlnSusQKJqKYNuz4tOnI6sZG4zanpemv+7ySU2jbA9h6uhcgpfy6G2PahirDZ6zvq6zDduMVFTKvzw8wgyEdelwY9in3XkEPs3osJuwRQ4qTkfzifndg9Gfc4pdsu82+tTnHZTBa2EAMrqr2t43pguc8tNm7JQVQ2S0ukj2d22dhXYP0/veWtwKrCkNoNimAN5+Xr/oLrxswKbVJjteWrX7eR63o4j9q0GxnaBdWgGA5VStpanIjQmEhV0/nVt5VOFUvix6awJhPcAaTEShgrG+iGyvb5a0Ndb1YGHFPEwoqAinoaykaID1o1pdPNu7XsnCKQ3R+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.6.0-beta.0
7
+ * v3.6.0
8
8
  */
9
9
  /*
10
10
  * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
@@ -34,7 +34,7 @@ return /******/ (() => { // webpackBootstrap
34
34
  \*************************************************/
35
35
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
36
36
 
37
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Poisson: () => (/* binding */ Poisson)\n/* harmony export */ });\nclass Poisson {\n constructor() {\n this.enable = false;\n this.dimensions = 2;\n this.radius = 0;\n this.retries = 30;\n this.steps = 0;\n }\n load(data) {\n if (!data) {\n return;\n }\n if (data.enable !== undefined) {\n this.enable = data.enable;\n }\n if (data.dimensions !== undefined) {\n this.dimensions = data.dimensions;\n }\n if (data.radius !== undefined) {\n this.radius = data.radius;\n }\n if (data.retries !== undefined) {\n this.retries = data.retries;\n }\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-poisson-disc/./dist/browser/Options/Classes/Poisson.js?");
37
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Poisson: () => (/* binding */ Poisson)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\n\nclass Poisson {\n constructor() {\n this.enable = false;\n this.dimensions = 2;\n this.radius = 0;\n this.retries = 30;\n this.steps = 0;\n }\n load(data) {\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isNull)(data)) {\n return;\n }\n if (data.enable !== undefined) {\n this.enable = data.enable;\n }\n if (data.dimensions !== undefined) {\n this.dimensions = data.dimensions;\n }\n if (data.radius !== undefined) {\n this.radius = data.radius;\n }\n if (data.retries !== undefined) {\n this.retries = data.retries;\n }\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-poisson-disc/./dist/browser/Options/Classes/Poisson.js?");
38
38
 
39
39
  /***/ }),
40
40
 
@@ -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={};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})()));
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});var n=e(303);class r{constructor(){this.enable=!1,this.dimensions=2,this.radius=0,this.retries=30,this.steps=0}load(i){(0,n.isNull)(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))}}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,n.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,r=Math.sin(s)*e,h={x:Math.floor(i.position.x+o),y:Math.floor(i.position.y+r)},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,n.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,n.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 r),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.6.0-beta.0 by Matteo Bruni */
1
+ /*! tsParticles Poisson Disc Plugin v3.6.0 by Matteo Bruni */
@@ -4,12 +4,13 @@
4
4
  if (v !== undefined) module.exports = v;
5
5
  }
6
6
  else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports"], factory);
7
+ define(["require", "exports", "@tsparticles/engine"], factory);
8
8
  }
9
9
  })(function (require, exports) {
10
10
  "use strict";
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.Poisson = void 0;
13
+ const engine_1 = require("@tsparticles/engine");
13
14
  class Poisson {
14
15
  constructor() {
15
16
  this.enable = false;
@@ -19,7 +20,7 @@
19
20
  this.steps = 0;
20
21
  }
21
22
  load(data) {
22
- if (!data) {
23
+ if ((0, engine_1.isNull)(data)) {
23
24
  return;
24
25
  }
25
26
  if (data.enable !== undefined) {