@tsparticles/plugin-poisson-disc 3.1.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.
Files changed (45) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +74 -0
  3. package/browser/Interfaces/IPoissonPoint.js +1 -0
  4. package/browser/Options/Classes/Poisson.js +26 -0
  5. package/browser/Options/Interfaces/IPoisson.js +1 -0
  6. package/browser/PoissonDisc.js +138 -0
  7. package/browser/PoissonInstance.js +55 -0
  8. package/browser/index.js +27 -0
  9. package/browser/package.json +1 -0
  10. package/browser/types.js +1 -0
  11. package/cjs/Interfaces/IPoissonPoint.js +2 -0
  12. package/cjs/Options/Classes/Poisson.js +30 -0
  13. package/cjs/Options/Interfaces/IPoisson.js +2 -0
  14. package/cjs/PoissonDisc.js +142 -0
  15. package/cjs/PoissonInstance.js +59 -0
  16. package/cjs/index.js +31 -0
  17. package/cjs/package.json +1 -0
  18. package/cjs/types.js +2 -0
  19. package/esm/Interfaces/IPoissonPoint.js +1 -0
  20. package/esm/Options/Classes/Poisson.js +26 -0
  21. package/esm/Options/Interfaces/IPoisson.js +1 -0
  22. package/esm/PoissonDisc.js +138 -0
  23. package/esm/PoissonInstance.js +55 -0
  24. package/esm/index.js +27 -0
  25. package/esm/package.json +1 -0
  26. package/esm/types.js +1 -0
  27. package/package.json +93 -0
  28. package/report.html +39 -0
  29. package/tsparticles.plugin.poisson.js +366 -0
  30. package/tsparticles.plugin.poisson.min.js +2 -0
  31. package/tsparticles.plugin.poisson.min.js.LICENSE.txt +1 -0
  32. package/types/Interfaces/IPoissonPoint.d.ts +5 -0
  33. package/types/Options/Classes/Poisson.d.ts +11 -0
  34. package/types/Options/Interfaces/IPoisson.d.ts +7 -0
  35. package/types/PoissonDisc.d.ts +27 -0
  36. package/types/PoissonInstance.d.ts +16 -0
  37. package/types/index.d.ts +2 -0
  38. package/types/types.d.ts +12 -0
  39. package/umd/Interfaces/IPoissonPoint.js +12 -0
  40. package/umd/Options/Classes/Poisson.js +40 -0
  41. package/umd/Options/Interfaces/IPoisson.js +12 -0
  42. package/umd/PoissonDisc.js +152 -0
  43. package/umd/PoissonInstance.js +69 -0
  44. package/umd/index.js +41 -0
  45. package/umd/types.js +12 -0
@@ -0,0 +1,366 @@
1
+ /*!
2
+ * Author : Matteo Bruni
3
+ * MIT license: https://opensource.org/licenses/MIT
4
+ * Demo / Generator : https://particles.js.org/
5
+ * GitHub : https://www.github.com/matteobruni/tsparticles
6
+ * How to use? : Check the GitHub README
7
+ * v3.1.0
8
+ */
9
+ (function webpackUniversalModuleDefinition(root, factory) {
10
+ if(typeof exports === 'object' && typeof module === 'object')
11
+ module.exports = factory(require("@tsparticles/engine"));
12
+ else if(typeof define === 'function' && define.amd)
13
+ define(["@tsparticles/engine"], factory);
14
+ else {
15
+ var a = typeof exports === 'object' ? factory(require("@tsparticles/engine")) : factory(root["window"]);
16
+ for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
17
+ }
18
+ })(this, (__WEBPACK_EXTERNAL_MODULE__533__) => {
19
+ return /******/ (() => { // webpackBootstrap
20
+ /******/ "use strict";
21
+ /******/ var __webpack_modules__ = ({
22
+
23
+ /***/ 533:
24
+ /***/ ((module) => {
25
+
26
+ module.exports = __WEBPACK_EXTERNAL_MODULE__533__;
27
+
28
+ /***/ })
29
+
30
+ /******/ });
31
+ /************************************************************************/
32
+ /******/ // The module cache
33
+ /******/ var __webpack_module_cache__ = {};
34
+ /******/
35
+ /******/ // The require function
36
+ /******/ function __webpack_require__(moduleId) {
37
+ /******/ // Check if module is in cache
38
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
39
+ /******/ if (cachedModule !== undefined) {
40
+ /******/ return cachedModule.exports;
41
+ /******/ }
42
+ /******/ // Create a new module (and put it into the cache)
43
+ /******/ var module = __webpack_module_cache__[moduleId] = {
44
+ /******/ // no module.id needed
45
+ /******/ // no module.loaded needed
46
+ /******/ exports: {}
47
+ /******/ };
48
+ /******/
49
+ /******/ // Execute the module function
50
+ /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
51
+ /******/
52
+ /******/ // Return the exports of the module
53
+ /******/ return module.exports;
54
+ /******/ }
55
+ /******/
56
+ /************************************************************************/
57
+ /******/ /* webpack/runtime/define property getters */
58
+ /******/ (() => {
59
+ /******/ // define getter functions for harmony exports
60
+ /******/ __webpack_require__.d = (exports, definition) => {
61
+ /******/ for(var key in definition) {
62
+ /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
63
+ /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
64
+ /******/ }
65
+ /******/ }
66
+ /******/ };
67
+ /******/ })();
68
+ /******/
69
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
70
+ /******/ (() => {
71
+ /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
72
+ /******/ })();
73
+ /******/
74
+ /******/ /* webpack/runtime/make namespace object */
75
+ /******/ (() => {
76
+ /******/ // define __esModule on exports
77
+ /******/ __webpack_require__.r = (exports) => {
78
+ /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
79
+ /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
80
+ /******/ }
81
+ /******/ Object.defineProperty(exports, '__esModule', { value: true });
82
+ /******/ };
83
+ /******/ })();
84
+ /******/
85
+ /************************************************************************/
86
+ var __webpack_exports__ = {};
87
+ // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
88
+ (() => {
89
+ // ESM COMPAT FLAG
90
+ __webpack_require__.r(__webpack_exports__);
91
+
92
+ // EXPORTS
93
+ __webpack_require__.d(__webpack_exports__, {
94
+ loadPoissonDiscPlugin: () => (/* binding */ loadPoissonDiscPlugin)
95
+ });
96
+
97
+ ;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Poisson.js
98
+ class Poisson {
99
+ constructor() {
100
+ this.enable = false;
101
+ this.dimensions = 2;
102
+ this.radius = 0;
103
+ this.retries = 30;
104
+ this.steps = 0;
105
+ }
106
+ load(data) {
107
+ if (!data) {
108
+ return;
109
+ }
110
+ if (data.enable !== undefined) {
111
+ this.enable = data.enable;
112
+ }
113
+ if (data.dimensions !== undefined) {
114
+ this.dimensions = data.dimensions;
115
+ }
116
+ if (data.radius !== undefined) {
117
+ this.radius = data.radius;
118
+ }
119
+ if (data.retries !== undefined) {
120
+ this.retries = data.retries;
121
+ }
122
+ }
123
+ }
124
+ // EXTERNAL MODULE: external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"}
125
+ var engine_root_window_ = __webpack_require__(533);
126
+ ;// CONCATENATED MODULE: ./dist/browser/PoissonDisc.js
127
+
128
+ const PoissonDisc_double = 2,
129
+ doublePI = Math.PI * PoissonDisc_double;
130
+ class PoissonDisc {
131
+ constructor(size, radius, retries, dimensions, firstPoint) {
132
+ this.size = {
133
+ ...size
134
+ };
135
+ this.radius = radius;
136
+ this.retries = retries;
137
+ this.dimensions = dimensions;
138
+ this.cellSize = Math.floor(this.radius / Math.sqrt(this.dimensions));
139
+ this.cols = Math.floor(this.size.width / this.cellSize);
140
+ this.rows = Math.floor(this.size.height / this.cellSize);
141
+ this.points = [];
142
+ this.active = [];
143
+ this.grid = [];
144
+ this.firstPoint = firstPoint ? {
145
+ ...firstPoint
146
+ } : undefined;
147
+ this.reset();
148
+ }
149
+ addPoint(inputPoint) {
150
+ const point = {
151
+ position: {
152
+ ...inputPoint
153
+ },
154
+ gridPosition: {
155
+ x: Math.floor(inputPoint.x / this.cellSize),
156
+ y: Math.floor(inputPoint.y / this.cellSize)
157
+ }
158
+ },
159
+ pointIndex = this.points.length;
160
+ this.points.push(point);
161
+ this.grid[point.gridPosition.y][point.gridPosition.x] = pointIndex;
162
+ this.active.push(pointIndex);
163
+ }
164
+ getRandom(min, max) {
165
+ return Math.floor((0,engine_root_window_.getRandom)() * (max - min)) + min;
166
+ }
167
+ initialiseGrid() {
168
+ for (let y = 0; y <= this.rows; y++) {
169
+ this.grid[y] = [];
170
+ for (let x = 0; x <= this.cols; x++) {
171
+ this.grid[y][x] = -1;
172
+ }
173
+ }
174
+ }
175
+ reset() {
176
+ this.points = [];
177
+ this.active = [];
178
+ this.grid = [];
179
+ this.initialiseGrid();
180
+ if (this.firstPoint) {
181
+ this.addPoint(this.firstPoint);
182
+ } else {
183
+ const minCoordinate = 0;
184
+ this.addPoint({
185
+ x: this.getRandom(minCoordinate, this.size.width),
186
+ y: this.getRandom(minCoordinate, this.size.height)
187
+ });
188
+ }
189
+ }
190
+ async run() {
191
+ this.reset();
192
+ const minCount = 0,
193
+ step = 1;
194
+ while (this.active.length > minCount) {
195
+ await this.steps(step);
196
+ }
197
+ }
198
+ async steps(steps) {
199
+ const minCount = 0;
200
+ for (let i = 0; i < steps; i++) {
201
+ if (this.active.length <= minCount) {
202
+ continue;
203
+ }
204
+ await this._step();
205
+ }
206
+ }
207
+ _getNewPoint(currentPoint, tries) {
208
+ const minCoordinate = 0,
209
+ gridMinValue = 0,
210
+ maxNeighbourIndex = 1,
211
+ newAngle = tries * (doublePI / this.retries),
212
+ newDist = this.getRandom(this.radius, this.radius * PoissonDisc_double),
213
+ offset = {
214
+ x: Math.cos(newAngle) * newDist,
215
+ y: Math.sin(newAngle) * newDist
216
+ },
217
+ newPoint = {
218
+ x: Math.floor(currentPoint.position.x + offset.x),
219
+ y: Math.floor(currentPoint.position.y + offset.y)
220
+ },
221
+ newGridCoords = {
222
+ x: Math.floor(newPoint.x / this.cellSize),
223
+ y: Math.floor(newPoint.y / this.cellSize)
224
+ };
225
+ if (newPoint.x > minCoordinate && newPoint.x < this.size.width && newPoint.y > minCoordinate && newPoint.y < this.size.height) {
226
+ if (this.grid[newGridCoords.y][newGridCoords.x] < gridMinValue) {
227
+ for (let i = -1; i <= maxNeighbourIndex; i++) {
228
+ for (let j = -1; j <= maxNeighbourIndex; j++) {
229
+ const neighbourGrid = {
230
+ x: newGridCoords.x + j,
231
+ y: newGridCoords.y + i
232
+ };
233
+ if (neighbourGrid.x >= minCoordinate && neighbourGrid.y >= minCoordinate && neighbourGrid.x < this.cols && neighbourGrid.y < this.rows && (neighbourGrid.x !== newGridCoords.x || neighbourGrid.y !== newGridCoords.y)) {
234
+ if (this.grid[neighbourGrid.y][neighbourGrid.x] >= gridMinValue) {
235
+ const neighbourIndex = this.grid[neighbourGrid.y][neighbourGrid.x],
236
+ neighbour = this.points[neighbourIndex],
237
+ dist = (0,engine_root_window_.getDistance)(newPoint, neighbour.position);
238
+ if (dist < this.radius) {
239
+ return;
240
+ }
241
+ }
242
+ }
243
+ }
244
+ }
245
+ } else {
246
+ return;
247
+ }
248
+ } else {
249
+ return;
250
+ }
251
+ return newPoint;
252
+ }
253
+ async _step() {
254
+ const minCount = 0,
255
+ randomActive = this.getRandom(minCount, this.active.length);
256
+ return new Promise(resolve => {
257
+ let foundNewPoint = false;
258
+ for (let tries = 0; tries < this.retries; tries++) {
259
+ const newPoint = this._getNewPoint(this.points[this.active[randomActive]], tries);
260
+ if (newPoint) {
261
+ foundNewPoint = true;
262
+ this.addPoint(newPoint);
263
+ break;
264
+ }
265
+ }
266
+ if (!foundNewPoint) {
267
+ const deleteCount = 1;
268
+ this.active.splice(randomActive, deleteCount);
269
+ }
270
+ resolve();
271
+ });
272
+ }
273
+ }
274
+ ;// CONCATENATED MODULE: ./dist/browser/PoissonInstance.js
275
+
276
+
277
+ class PoissonInstance {
278
+ constructor(container, engine) {
279
+ this._container = container;
280
+ this._engine = engine;
281
+ this._currentIndex = 0;
282
+ }
283
+ async init() {
284
+ await this._initData();
285
+ }
286
+ particlePosition(position) {
287
+ const container = this._container,
288
+ options = container.actualOptions.poisson;
289
+ if (!this.poissonDisc || !(options?.enable ?? false) || this._currentIndex >= this.poissonDisc.points.length) {
290
+ return;
291
+ }
292
+ return position ?? this.poissonDisc?.points[this._currentIndex++]?.position;
293
+ }
294
+ resize() {
295
+ const container = this._container,
296
+ options = container.actualOptions.poisson;
297
+ if (!(options?.enable ?? false)) {
298
+ return;
299
+ }
300
+ if (this.redrawTimeout) {
301
+ clearTimeout(this.redrawTimeout);
302
+ }
303
+ const timeout = 250;
304
+ this.redrawTimeout = window.setTimeout(() => {
305
+ void (async () => {
306
+ await this._initData();
307
+ await container.particles.redraw();
308
+ })();
309
+ }, timeout);
310
+ }
311
+ stop() {
312
+ delete this.poissonDisc;
313
+ }
314
+ async _initData() {
315
+ const container = this._container,
316
+ poissonOptions = container.actualOptions.poisson,
317
+ particlesOptions = container.actualOptions.particles,
318
+ canvasSize = container.canvas.size,
319
+ pixelRatio = container.retina.pixelRatio;
320
+ if (!poissonOptions?.enable) {
321
+ return;
322
+ }
323
+ this._currentIndex = 0;
324
+ this.poissonDisc = new PoissonDisc(canvasSize, poissonOptions.radius ? poissonOptions.radius * pixelRatio : Math.max((0,engine_root_window_.getRangeMax)(particlesOptions.size.value) * pixelRatio, Math.sqrt(canvasSize.width * canvasSize.height / particlesOptions.number.value)), poissonOptions.retries, poissonOptions.dimensions);
325
+ const noSteps = 0;
326
+ if (poissonOptions.steps > noSteps) {
327
+ await this.poissonDisc.steps(poissonOptions.steps);
328
+ } else {
329
+ await this.poissonDisc.run();
330
+ }
331
+ }
332
+ }
333
+ ;// CONCATENATED MODULE: ./dist/browser/index.js
334
+
335
+
336
+ class PoissonDiscPlugin {
337
+ constructor(engine) {
338
+ this.id = "poisson";
339
+ this._engine = engine;
340
+ }
341
+ getPlugin(container) {
342
+ return new PoissonInstance(container, this._engine);
343
+ }
344
+ loadOptions(options, source) {
345
+ if (!this.needsPlugin(options) && !this.needsPlugin(source)) {
346
+ return;
347
+ }
348
+ let poissonOptions = options.poisson;
349
+ if (poissonOptions?.load === undefined) {
350
+ options.poisson = poissonOptions = new Poisson();
351
+ }
352
+ poissonOptions.load(source?.poisson);
353
+ }
354
+ needsPlugin(options) {
355
+ return options?.poisson?.enable ?? false;
356
+ }
357
+ }
358
+ async function loadPoissonDiscPlugin(engine, refresh = true) {
359
+ await engine.addPlugin(new PoissonDiscPlugin(engine), refresh);
360
+ }
361
+ })();
362
+
363
+ /******/ return __webpack_exports__;
364
+ /******/ })()
365
+ ;
366
+ });
@@ -0,0 +1,2 @@
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=>(()=>{"use strict";var t={533: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(533);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 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})()));
@@ -0,0 +1 @@
1
+ /*! tsParticles Poisson Disc Plugin v3.1.0 by Matteo Bruni */
@@ -0,0 +1,5 @@
1
+ import type { ICoordinates } from "@tsparticles/engine";
2
+ export interface IPoissonPoint {
3
+ gridPosition: ICoordinates;
4
+ position: ICoordinates;
5
+ }
@@ -0,0 +1,11 @@
1
+ import { type IOptionLoader, type RecursivePartial } from "@tsparticles/engine";
2
+ import type { IPoisson } from "../Interfaces/IPoisson.js";
3
+ export declare class Poisson implements IPoisson, IOptionLoader<IPoisson> {
4
+ dimensions: number;
5
+ enable: boolean;
6
+ radius: number;
7
+ retries: number;
8
+ steps: number;
9
+ constructor();
10
+ load(data?: RecursivePartial<IPoisson>): void;
11
+ }
@@ -0,0 +1,7 @@
1
+ export interface IPoisson {
2
+ dimensions: number;
3
+ enable: boolean;
4
+ radius: number;
5
+ retries: number;
6
+ steps: number;
7
+ }
@@ -0,0 +1,27 @@
1
+ import { type ICoordinates, type IDimension } from "@tsparticles/engine";
2
+ import type { IPoissonPoint } from "./Interfaces/IPoissonPoint.js";
3
+ export declare class PoissonDisc {
4
+ active: number[];
5
+ cellSize: number;
6
+ cols: number;
7
+ dimensions: number;
8
+ firstPoint: {
9
+ x: number;
10
+ y: number;
11
+ } | undefined;
12
+ grid: number[][];
13
+ points: IPoissonPoint[];
14
+ radius: number;
15
+ retries: number;
16
+ rows: number;
17
+ size: IDimension;
18
+ constructor(size: IDimension, radius: number, retries: number, dimensions: number, firstPoint?: ICoordinates);
19
+ addPoint(inputPoint: ICoordinates): void;
20
+ getRandom(min: number, max: number): number;
21
+ initialiseGrid(): void;
22
+ reset(): void;
23
+ run(): Promise<void>;
24
+ steps(steps: number): Promise<void>;
25
+ private _getNewPoint;
26
+ private _step;
27
+ }
@@ -0,0 +1,16 @@
1
+ import { type Engine, type IContainerPlugin, type ICoordinates } from "@tsparticles/engine";
2
+ import type { PoissonContainer } from "./types.js";
3
+ import { PoissonDisc } from "./PoissonDisc.js";
4
+ export declare class PoissonInstance implements IContainerPlugin {
5
+ poissonDisc?: PoissonDisc;
6
+ redrawTimeout?: number;
7
+ private readonly _container;
8
+ private _currentIndex;
9
+ private readonly _engine;
10
+ constructor(container: PoissonContainer, engine: Engine);
11
+ init(): Promise<void>;
12
+ particlePosition(position?: ICoordinates): ICoordinates | undefined;
13
+ resize(): void;
14
+ stop(): void;
15
+ private _initData;
16
+ }
@@ -0,0 +1,2 @@
1
+ import { type Engine } from "@tsparticles/engine";
2
+ export declare function loadPoissonDiscPlugin(engine: Engine, refresh?: boolean): Promise<void>;
@@ -0,0 +1,12 @@
1
+ import type { Container, IOptions, Options } from "@tsparticles/engine";
2
+ import type { IPoisson } from "./Options/Interfaces/IPoisson.js";
3
+ import type { Poisson } from "./Options/Classes/Poisson.js";
4
+ export type IPoissonOptions = IOptions & {
5
+ poisson: IPoisson;
6
+ };
7
+ export type PoissonOptions = Options & {
8
+ poisson?: Poisson;
9
+ };
10
+ export type PoissonContainer = Container & {
11
+ actualOptions: PoissonOptions;
12
+ };
@@ -0,0 +1,12 @@
1
+ (function (factory) {
2
+ if (typeof module === "object" && typeof module.exports === "object") {
3
+ var v = factory(require, exports);
4
+ if (v !== undefined) module.exports = v;
5
+ }
6
+ else if (typeof define === "function" && define.amd) {
7
+ define(["require", "exports"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ });
@@ -0,0 +1,40 @@
1
+ (function (factory) {
2
+ if (typeof module === "object" && typeof module.exports === "object") {
3
+ var v = factory(require, exports);
4
+ if (v !== undefined) module.exports = v;
5
+ }
6
+ else if (typeof define === "function" && define.amd) {
7
+ define(["require", "exports"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.Poisson = void 0;
13
+ class Poisson {
14
+ constructor() {
15
+ this.enable = false;
16
+ this.dimensions = 2;
17
+ this.radius = 0;
18
+ this.retries = 30;
19
+ this.steps = 0;
20
+ }
21
+ load(data) {
22
+ if (!data) {
23
+ return;
24
+ }
25
+ if (data.enable !== undefined) {
26
+ this.enable = data.enable;
27
+ }
28
+ if (data.dimensions !== undefined) {
29
+ this.dimensions = data.dimensions;
30
+ }
31
+ if (data.radius !== undefined) {
32
+ this.radius = data.radius;
33
+ }
34
+ if (data.retries !== undefined) {
35
+ this.retries = data.retries;
36
+ }
37
+ }
38
+ }
39
+ exports.Poisson = Poisson;
40
+ });
@@ -0,0 +1,12 @@
1
+ (function (factory) {
2
+ if (typeof module === "object" && typeof module.exports === "object") {
3
+ var v = factory(require, exports);
4
+ if (v !== undefined) module.exports = v;
5
+ }
6
+ else if (typeof define === "function" && define.amd) {
7
+ define(["require", "exports"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ });