@tsparticles/plugin-emitters-shape-polygon 3.9.1 → 4.0.0-alpha.1

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.
@@ -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.9.1
7
+ * v4.0.0-alpha.1
8
8
  */
9
9
  /*
10
10
  * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
@@ -28,75 +28,35 @@ return /******/ (() => { // webpackBootstrap
28
28
  /******/ "use strict";
29
29
  /******/ var __webpack_modules__ = ({
30
30
 
31
- /***/ "./dist/browser/EmittersPolygonShape.js":
32
- /*!**********************************************!*\
33
- !*** ./dist/browser/EmittersPolygonShape.js ***!
34
- \**********************************************/
35
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
36
-
37
- eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ EmittersPolygonShape: () => (/* binding */ EmittersPolygonShape)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_plugin_emitters__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/plugin-emitters */ \"@tsparticles/plugin-emitters\");\n/* harmony import */ var _tsparticles_plugin_emitters__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_plugin_emitters__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./utils.js */ \"./dist/browser/utils.js\");\n\n\n\nconst half = 0.5;\nclass EmittersPolygonShape extends _tsparticles_plugin_emitters__WEBPACK_IMPORTED_MODULE_0__.EmitterShapeBase {\n constructor(position, size, fill, options) {\n super(position, size, fill, options);\n this.sides = options.sides;\n this.angle = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.degToRad)(options.angle);\n this.polygon = (0,_utils_js__WEBPACK_IMPORTED_MODULE_2__.generateRandomPolygon)(position, this.sides, size.width * half, this.angle);\n }\n async init() {}\n randomPosition() {\n const fill = this.fill,\n polygon = this.polygon,\n res = fill ? (0,_utils_js__WEBPACK_IMPORTED_MODULE_2__.generateRandomPointWithinPolygon)(polygon) : (0,_utils_js__WEBPACK_IMPORTED_MODULE_2__.generateRandomPointOnPolygonPerimeter)(polygon);\n return res ? {\n position: res\n } : null;\n }\n resize(position, size) {\n super.resize(position, size);\n this.polygon = (0,_utils_js__WEBPACK_IMPORTED_MODULE_2__.generateRandomPolygon)(position, this.sides, size.width * half, this.angle);\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-emitters-shape-polygon/./dist/browser/EmittersPolygonShape.js?\n}");
38
-
39
- /***/ }),
40
-
41
- /***/ "./dist/browser/EmittersPolygonShapeGenerator.js":
42
- /*!*******************************************************!*\
43
- !*** ./dist/browser/EmittersPolygonShapeGenerator.js ***!
44
- \*******************************************************/
45
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
46
-
47
- eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ EmittersPolygonShapeGenerator: () => (/* binding */ EmittersPolygonShapeGenerator)\n/* harmony export */ });\n/* harmony import */ var _EmittersPolygonShape_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./EmittersPolygonShape.js */ \"./dist/browser/EmittersPolygonShape.js\");\n/* harmony import */ var _Options_Classes_EmittersPolygonShapeOptions_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Options/Classes/EmittersPolygonShapeOptions.js */ \"./dist/browser/Options/Classes/EmittersPolygonShapeOptions.js\");\n\n\nclass EmittersPolygonShapeGenerator {\n generate(position, size, fill, options) {\n const shapeOptions = new _Options_Classes_EmittersPolygonShapeOptions_js__WEBPACK_IMPORTED_MODULE_1__.EmittersPolygonShapeOptions();\n shapeOptions.load(options);\n return new _EmittersPolygonShape_js__WEBPACK_IMPORTED_MODULE_0__.EmittersPolygonShape(position, size, fill, shapeOptions);\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-emitters-shape-polygon/./dist/browser/EmittersPolygonShapeGenerator.js?\n}");
48
-
49
- /***/ }),
50
-
51
- /***/ "./dist/browser/Options/Classes/EmittersPolygonShapeOptions.js":
52
- /*!*********************************************************************!*\
53
- !*** ./dist/browser/Options/Classes/EmittersPolygonShapeOptions.js ***!
54
- \*********************************************************************/
55
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
56
-
57
- eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ EmittersPolygonShapeOptions: () => (/* binding */ EmittersPolygonShapeOptions)\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 EmittersPolygonShapeOptions {\n constructor() {\n this.angle = 0;\n this.sides = 5;\n }\n load(data) {\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isNull)(data)) {\n return;\n }\n if (data.angle !== undefined) {\n this.angle = data.angle;\n }\n if (data.sides !== undefined) {\n this.sides = data.sides;\n }\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-emitters-shape-polygon/./dist/browser/Options/Classes/EmittersPolygonShapeOptions.js?\n}");
58
-
59
- /***/ }),
60
-
61
- /***/ "./dist/browser/index.js":
31
+ /***/ "./dist/browser/index.js"
62
32
  /*!*******************************!*\
63
33
  !*** ./dist/browser/index.js ***!
64
34
  \*******************************/
65
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
66
-
67
- eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadEmittersShapePolygon: () => (/* binding */ loadEmittersShapePolygon)\n/* harmony export */ });\n/* harmony import */ var _EmittersPolygonShapeGenerator_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./EmittersPolygonShapeGenerator.js */ \"./dist/browser/EmittersPolygonShapeGenerator.js\");\n\nasync function loadEmittersShapePolygon(engine, refresh = true) {\n const emittersEngine = engine;\n emittersEngine.checkVersion(\"3.9.1\");\n emittersEngine.addEmitterShapeGenerator?.(\"polygon\", new _EmittersPolygonShapeGenerator_js__WEBPACK_IMPORTED_MODULE_0__.EmittersPolygonShapeGenerator());\n await emittersEngine.refresh(refresh);\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-emitters-shape-polygon/./dist/browser/index.js?\n}");
35
+ (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
68
36
 
69
- /***/ }),
37
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadEmittersShapePolygon: () => (/* binding */ loadEmittersShapePolygon)\n/* harmony export */ });\nfunction loadEmittersShapePolygon(engine) {\n engine.checkVersion(\"4.0.0-alpha.1\");\n engine.register(async emittersEngine => {\n const {\n EmittersPolygonShapeGenerator\n } = await __webpack_require__.e(/*! import() */ \"dist_browser_EmittersPolygonShapeGenerator_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./EmittersPolygonShapeGenerator.js */ \"./dist/browser/EmittersPolygonShapeGenerator.js\"));\n emittersEngine.addEmitterShapeGenerator?.(\"polygon\", new EmittersPolygonShapeGenerator());\n });\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-emitters-shape-polygon/./dist/browser/index.js?\n}");
70
38
 
71
- /***/ "./dist/browser/utils.js":
72
- /*!*******************************!*\
73
- !*** ./dist/browser/utils.js ***!
74
- \*******************************/
75
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
39
+ /***/ },
76
40
 
77
- eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ generateRandomPointOnPolygonPerimeter: () => (/* binding */ generateRandomPointOnPolygonPerimeter),\n/* harmony export */ generateRandomPointWithinPolygon: () => (/* binding */ generateRandomPointWithinPolygon),\n/* harmony export */ generateRandomPolygon: () => (/* binding */ generateRandomPolygon),\n/* harmony export */ isPointInPolygon: () => (/* binding */ isPointInPolygon)\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\nconst double = 2,\n doublePI = Math.PI * double,\n defaultRotation = 0,\n maxAttempts = 100;\nfunction generateRandomPolygon(position, sides, radius, rotationAngle = defaultRotation) {\n const polygon = [],\n angle = doublePI / sides;\n for (let i = 0; i < sides; i++) {\n const currentAngle = angle * i + rotationAngle;\n polygon.push({\n x: position.x + radius * Math.cos(currentAngle),\n y: position.y + radius * Math.sin(currentAngle)\n });\n }\n return polygon;\n}\nfunction generateRandomPointWithinPolygon(polygon) {\n const firstIndex = 0,\n firstPoint = polygon[firstIndex],\n min = {\n ...firstPoint\n },\n max = {\n ...firstPoint\n };\n for (const point of polygon) {\n if (point.x < min.x) {\n min.x = point.x;\n }\n if (point.x > max.x) {\n max.x = point.x;\n }\n if (point.y < min.y) {\n min.y = point.y;\n }\n if (point.y > max.y) {\n max.y = point.y;\n }\n }\n let randomPoint = null;\n for (let attempts = 0; attempts < maxAttempts; attempts++) {\n const tmpPoint = {\n x: min.x + (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)() * (max.x - min.x),\n y: min.y + (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)() * (max.y - min.y)\n };\n if (isPointInPolygon(tmpPoint, polygon)) {\n randomPoint = tmpPoint;\n break;\n }\n }\n return randomPoint;\n}\nfunction generateRandomPointOnPolygonPerimeter(polygon) {\n const sideIndex = Math.floor((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)() * polygon.length),\n startPoint = polygon[sideIndex],\n offset = 1,\n endPoint = polygon[(sideIndex + offset) % polygon.length],\n t = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)();\n return {\n x: startPoint.x + (endPoint.x - startPoint.x) * t,\n y: startPoint.y + (endPoint.y - startPoint.y) * t\n };\n}\nfunction isPointInPolygon(point, polygon) {\n let inside = false;\n const offset = 1;\n for (let i = 0, j = polygon.length - offset; i < polygon.length; j = i++) {\n const pi = polygon[i],\n pj = polygon[j];\n const intersect = pi.y > point.y !== pj.y > point.y && point.x < (pj.x - pi.x) * (point.y - pi.y) / (pj.y - pi.y) + pi.x;\n if (intersect) {\n inside = !inside;\n }\n }\n return inside;\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-emitters-shape-polygon/./dist/browser/utils.js?\n}");
78
-
79
- /***/ }),
80
-
81
- /***/ "@tsparticles/engine":
41
+ /***/ "@tsparticles/engine"
82
42
  /*!*********************************************************************************************************************************!*\
83
43
  !*** external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"} ***!
84
44
  \*********************************************************************************************************************************/
85
- /***/ ((module) => {
45
+ (module) {
86
46
 
87
47
  module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
88
48
 
89
- /***/ }),
49
+ /***/ },
90
50
 
91
- /***/ "@tsparticles/plugin-emitters":
51
+ /***/ "@tsparticles/plugin-emitters"
92
52
  /*!************************************************************************************************************************************************************!*\
93
53
  !*** external {"commonjs":"@tsparticles/plugin-emitters","commonjs2":"@tsparticles/plugin-emitters","amd":"@tsparticles/plugin-emitters","root":"window"} ***!
94
54
  \************************************************************************************************************************************************************/
95
- /***/ ((module) => {
55
+ (module) {
96
56
 
97
57
  module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_plugin_emitters__;
98
58
 
99
- /***/ })
59
+ /***/ }
100
60
 
101
61
  /******/ });
102
62
  /************************************************************************/
@@ -110,6 +70,12 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_plugin_emitters__;
110
70
  /******/ if (cachedModule !== undefined) {
111
71
  /******/ return cachedModule.exports;
112
72
  /******/ }
73
+ /******/ // Check if module exists (development only)
74
+ /******/ if (__webpack_modules__[moduleId] === undefined) {
75
+ /******/ var e = new Error("Cannot find module '" + moduleId + "'");
76
+ /******/ e.code = 'MODULE_NOT_FOUND';
77
+ /******/ throw e;
78
+ /******/ }
113
79
  /******/ // Create a new module (and put it into the cache)
114
80
  /******/ var module = __webpack_module_cache__[moduleId] = {
115
81
  /******/ // no module.id needed
@@ -124,19 +90,10 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_plugin_emitters__;
124
90
  /******/ return module.exports;
125
91
  /******/ }
126
92
  /******/
127
- /************************************************************************/
128
- /******/ /* webpack/runtime/compat get default export */
129
- /******/ (() => {
130
- /******/ // getDefaultExport function for compatibility with non-harmony modules
131
- /******/ __webpack_require__.n = (module) => {
132
- /******/ var getter = module && module.__esModule ?
133
- /******/ () => (module['default']) :
134
- /******/ () => (module);
135
- /******/ __webpack_require__.d(getter, { a: getter });
136
- /******/ return getter;
137
- /******/ };
138
- /******/ })();
93
+ /******/ // expose the modules object (__webpack_modules__)
94
+ /******/ __webpack_require__.m = __webpack_modules__;
139
95
  /******/
96
+ /************************************************************************/
140
97
  /******/ /* webpack/runtime/define property getters */
141
98
  /******/ (() => {
142
99
  /******/ // define getter functions for harmony exports
@@ -149,11 +106,90 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_plugin_emitters__;
149
106
  /******/ };
150
107
  /******/ })();
151
108
  /******/
109
+ /******/ /* webpack/runtime/ensure chunk */
110
+ /******/ (() => {
111
+ /******/ __webpack_require__.f = {};
112
+ /******/ // This file contains only the entry chunk.
113
+ /******/ // The chunk loading function for additional chunks
114
+ /******/ __webpack_require__.e = (chunkId) => {
115
+ /******/ return Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key) => {
116
+ /******/ __webpack_require__.f[key](chunkId, promises);
117
+ /******/ return promises;
118
+ /******/ }, []));
119
+ /******/ };
120
+ /******/ })();
121
+ /******/
122
+ /******/ /* webpack/runtime/get javascript chunk filename */
123
+ /******/ (() => {
124
+ /******/ // This function allow to reference async chunks
125
+ /******/ __webpack_require__.u = (chunkId) => {
126
+ /******/ // return url for filenames based on template
127
+ /******/ return "" + chunkId + ".js";
128
+ /******/ };
129
+ /******/ })();
130
+ /******/
131
+ /******/ /* webpack/runtime/global */
132
+ /******/ (() => {
133
+ /******/ __webpack_require__.g = (function() {
134
+ /******/ if (typeof globalThis === 'object') return globalThis;
135
+ /******/ try {
136
+ /******/ return this || new Function('return this')();
137
+ /******/ } catch (e) {
138
+ /******/ if (typeof window === 'object') return window;
139
+ /******/ }
140
+ /******/ })();
141
+ /******/ })();
142
+ /******/
152
143
  /******/ /* webpack/runtime/hasOwnProperty shorthand */
153
144
  /******/ (() => {
154
145
  /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
155
146
  /******/ })();
156
147
  /******/
148
+ /******/ /* webpack/runtime/load script */
149
+ /******/ (() => {
150
+ /******/ var inProgress = {};
151
+ /******/ var dataWebpackPrefix = "@tsparticles/plugin-emitters-shape-polygon:";
152
+ /******/ // loadScript function to load a script via script tag
153
+ /******/ __webpack_require__.l = (url, done, key, chunkId) => {
154
+ /******/ if(inProgress[url]) { inProgress[url].push(done); return; }
155
+ /******/ var script, needAttach;
156
+ /******/ if(key !== undefined) {
157
+ /******/ var scripts = document.getElementsByTagName("script");
158
+ /******/ for(var i = 0; i < scripts.length; i++) {
159
+ /******/ var s = scripts[i];
160
+ /******/ if(s.getAttribute("src") == url || s.getAttribute("data-webpack") == dataWebpackPrefix + key) { script = s; break; }
161
+ /******/ }
162
+ /******/ }
163
+ /******/ if(!script) {
164
+ /******/ needAttach = true;
165
+ /******/ script = document.createElement('script');
166
+ /******/
167
+ /******/ script.charset = 'utf-8';
168
+ /******/ if (__webpack_require__.nc) {
169
+ /******/ script.setAttribute("nonce", __webpack_require__.nc);
170
+ /******/ }
171
+ /******/ script.setAttribute("data-webpack", dataWebpackPrefix + key);
172
+ /******/
173
+ /******/ script.src = url;
174
+ /******/ }
175
+ /******/ inProgress[url] = [done];
176
+ /******/ var onScriptComplete = (prev, event) => {
177
+ /******/ // avoid mem leaks in IE.
178
+ /******/ script.onerror = script.onload = null;
179
+ /******/ clearTimeout(timeout);
180
+ /******/ var doneFns = inProgress[url];
181
+ /******/ delete inProgress[url];
182
+ /******/ script.parentNode && script.parentNode.removeChild(script);
183
+ /******/ doneFns && doneFns.forEach((fn) => (fn(event)));
184
+ /******/ if(prev) return prev(event);
185
+ /******/ }
186
+ /******/ var timeout = setTimeout(onScriptComplete.bind(null, undefined, { type: 'timeout', target: script }), 120000);
187
+ /******/ script.onerror = onScriptComplete.bind(null, script.onerror);
188
+ /******/ script.onload = onScriptComplete.bind(null, script.onload);
189
+ /******/ needAttach && document.head.appendChild(script);
190
+ /******/ };
191
+ /******/ })();
192
+ /******/
157
193
  /******/ /* webpack/runtime/make namespace object */
158
194
  /******/ (() => {
159
195
  /******/ // define __esModule on exports
@@ -165,6 +201,119 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_plugin_emitters__;
165
201
  /******/ };
166
202
  /******/ })();
167
203
  /******/
204
+ /******/ /* webpack/runtime/publicPath */
205
+ /******/ (() => {
206
+ /******/ var scriptUrl;
207
+ /******/ if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + "";
208
+ /******/ var document = __webpack_require__.g.document;
209
+ /******/ if (!scriptUrl && document) {
210
+ /******/ if (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT')
211
+ /******/ scriptUrl = document.currentScript.src;
212
+ /******/ if (!scriptUrl) {
213
+ /******/ var scripts = document.getElementsByTagName("script");
214
+ /******/ if(scripts.length) {
215
+ /******/ var i = scripts.length - 1;
216
+ /******/ while (i > -1 && (!scriptUrl || !/^http(s?):/.test(scriptUrl))) scriptUrl = scripts[i--].src;
217
+ /******/ }
218
+ /******/ }
219
+ /******/ }
220
+ /******/ // When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration
221
+ /******/ // or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.
222
+ /******/ if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser");
223
+ /******/ scriptUrl = scriptUrl.replace(/^blob:/, "").replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/");
224
+ /******/ __webpack_require__.p = scriptUrl;
225
+ /******/ })();
226
+ /******/
227
+ /******/ /* webpack/runtime/jsonp chunk loading */
228
+ /******/ (() => {
229
+ /******/ // no baseURI
230
+ /******/
231
+ /******/ // object to store loaded and loading chunks
232
+ /******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
233
+ /******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded
234
+ /******/ var installedChunks = {
235
+ /******/ "tsparticles.plugin.emitters.shape.polygon": 0
236
+ /******/ };
237
+ /******/
238
+ /******/ __webpack_require__.f.j = (chunkId, promises) => {
239
+ /******/ // JSONP chunk loading for javascript
240
+ /******/ var installedChunkData = __webpack_require__.o(installedChunks, chunkId) ? installedChunks[chunkId] : undefined;
241
+ /******/ if(installedChunkData !== 0) { // 0 means "already installed".
242
+ /******/
243
+ /******/ // a Promise means "currently loading".
244
+ /******/ if(installedChunkData) {
245
+ /******/ promises.push(installedChunkData[2]);
246
+ /******/ } else {
247
+ /******/ if(true) { // all chunks have JS
248
+ /******/ // setup Promise in chunk cache
249
+ /******/ var promise = new Promise((resolve, reject) => (installedChunkData = installedChunks[chunkId] = [resolve, reject]));
250
+ /******/ promises.push(installedChunkData[2] = promise);
251
+ /******/
252
+ /******/ // start chunk loading
253
+ /******/ var url = __webpack_require__.p + __webpack_require__.u(chunkId);
254
+ /******/ // create error before stack unwound to get useful stacktrace later
255
+ /******/ var error = new Error();
256
+ /******/ var loadingEnded = (event) => {
257
+ /******/ if(__webpack_require__.o(installedChunks, chunkId)) {
258
+ /******/ installedChunkData = installedChunks[chunkId];
259
+ /******/ if(installedChunkData !== 0) installedChunks[chunkId] = undefined;
260
+ /******/ if(installedChunkData) {
261
+ /******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type);
262
+ /******/ var realSrc = event && event.target && event.target.src;
263
+ /******/ error.message = 'Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')';
264
+ /******/ error.name = 'ChunkLoadError';
265
+ /******/ error.type = errorType;
266
+ /******/ error.request = realSrc;
267
+ /******/ installedChunkData[1](error);
268
+ /******/ }
269
+ /******/ }
270
+ /******/ };
271
+ /******/ __webpack_require__.l(url, loadingEnded, "chunk-" + chunkId, chunkId);
272
+ /******/ }
273
+ /******/ }
274
+ /******/ }
275
+ /******/ };
276
+ /******/
277
+ /******/ // no prefetching
278
+ /******/
279
+ /******/ // no preloaded
280
+ /******/
281
+ /******/ // no HMR
282
+ /******/
283
+ /******/ // no HMR manifest
284
+ /******/
285
+ /******/ // no on chunks loaded
286
+ /******/
287
+ /******/ // install a JSONP callback for chunk loading
288
+ /******/ var webpackJsonpCallback = (parentChunkLoadingFunction, data) => {
289
+ /******/ var [chunkIds, moreModules, runtime] = data;
290
+ /******/ // add "moreModules" to the modules object,
291
+ /******/ // then flag all "chunkIds" as loaded and fire callback
292
+ /******/ var moduleId, chunkId, i = 0;
293
+ /******/ if(chunkIds.some((id) => (installedChunks[id] !== 0))) {
294
+ /******/ for(moduleId in moreModules) {
295
+ /******/ if(__webpack_require__.o(moreModules, moduleId)) {
296
+ /******/ __webpack_require__.m[moduleId] = moreModules[moduleId];
297
+ /******/ }
298
+ /******/ }
299
+ /******/ if(runtime) var result = runtime(__webpack_require__);
300
+ /******/ }
301
+ /******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data);
302
+ /******/ for(;i < chunkIds.length; i++) {
303
+ /******/ chunkId = chunkIds[i];
304
+ /******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {
305
+ /******/ installedChunks[chunkId][0]();
306
+ /******/ }
307
+ /******/ installedChunks[chunkId] = 0;
308
+ /******/ }
309
+ /******/
310
+ /******/ }
311
+ /******/
312
+ /******/ var chunkLoadingGlobal = this["webpackChunk_tsparticles_plugin_emitters_shape_polygon"] = this["webpackChunk_tsparticles_plugin_emitters_shape_polygon"] || [];
313
+ /******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));
314
+ /******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));
315
+ /******/ })();
316
+ /******/
168
317
  /************************************************************************/
169
318
  /******/
170
319
  /******/ // startup
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see tsparticles.plugin.emitters.shape.polygon.min.js.LICENSE.txt */
2
- !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/plugin-emitters"),require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/plugin-emitters","@tsparticles/engine"],t);else{var o="object"==typeof exports?t(require("@tsparticles/plugin-emitters"),require("@tsparticles/engine")):t(e.window,e.window);for(var n in o)("object"==typeof exports?exports:e)[n]=o[n]}}(this,((e,t)=>(()=>{var o={303:e=>{e.exports=t},526:t=>{t.exports=e}},n={};function s(e){var t=n[e];if(void 0!==t)return t.exports;var r=n[e]={exports:{}};return o[e](r,r.exports,s),r.exports}s.d=(e,t)=>{for(var o in t)s.o(t,o)&&!s.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),s.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};s.r(r),s.d(r,{loadEmittersShapePolygon:()=>f});var i=s(526),l=s(303);const a=2*Math.PI;function y(e,t,o,n=0){const s=[],r=a/t;for(let i=0;i<t;i++){const t=r*i+n;s.push({x:e.x+o*Math.cos(t),y:e.y+o*Math.sin(t)})}return s}function c(e,t){let o=!1;for(let n=0,s=t.length-1;n<t.length;s=n++){const r=t[n],i=t[s];r.y>e.y!=i.y>e.y&&e.x<(i.x-r.x)*(e.y-r.y)/(i.y-r.y)+r.x&&(o=!o)}return o}class d extends i.EmitterShapeBase{constructor(e,t,o,n){super(e,t,o,n),this.sides=n.sides,this.angle=(0,l.degToRad)(n.angle),this.polygon=y(e,this.sides,.5*t.width,this.angle)}async init(){}randomPosition(){const e=this.fill,t=this.polygon,o=e?function(e){const t=e[0],o={...t},n={...t};for(const t of e)t.x<o.x&&(o.x=t.x),t.x>n.x&&(n.x=t.x),t.y<o.y&&(o.y=t.y),t.y>n.y&&(n.y=t.y);let s=null;for(let t=0;t<100;t++){const t={x:o.x+(0,l.getRandom)()*(n.x-o.x),y:o.y+(0,l.getRandom)()*(n.y-o.y)};if(c(t,e)){s=t;break}}return s}(t):function(e){const t=Math.floor((0,l.getRandom)()*e.length),o=e[t],n=e[(t+1)%e.length],s=(0,l.getRandom)();return{x:o.x+(n.x-o.x)*s,y:o.y+(n.y-o.y)*s}}(t);return o?{position:o}:null}resize(e,t){super.resize(e,t),this.polygon=y(e,this.sides,.5*t.width,this.angle)}}class p{constructor(){this.angle=0,this.sides=5}load(e){(0,l.isNull)(e)||(void 0!==e.angle&&(this.angle=e.angle),void 0!==e.sides&&(this.sides=e.sides))}}class u{generate(e,t,o,n){const s=new p;return s.load(n),new d(e,t,o,s)}}async function f(e,t=!0){const o=e;o.checkVersion("3.9.1"),o.addEmitterShapeGenerator?.("polygon",new u),await o.refresh(t)}return r})()));
2
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/plugin-emitters"),require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/plugin-emitters","@tsparticles/engine"],t);else{var r="object"==typeof exports?t(require("@tsparticles/plugin-emitters"),require("@tsparticles/engine")):t(e.window,e.window);for(var o in r)("object"==typeof exports?exports:e)[o]=r[o]}}(this,((e,t)=>(()=>{var r,o,i={303(e){e.exports=t},526(t){t.exports=e}},n={};function a(e){var t=n[e];if(void 0!==t)return t.exports;var r=n[e]={exports:{}};return i[e](r,r.exports,a),r.exports}a.m=i,a.d=(e,t)=>{for(var r in t)a.o(t,r)&&!a.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},a.f={},a.e=e=>Promise.all(Object.keys(a.f).reduce(((t,r)=>(a.f[r](e,t),t)),[])),a.u=e=>e+".min.js",a.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r={},o="@tsparticles/plugin-emitters-shape-polygon:",a.l=(e,t,i,n)=>{if(r[e])r[e].push(t);else{var s,p;if(void 0!==i)for(var l=document.getElementsByTagName("script"),c=0;c<l.length;c++){var u=l[c];if(u.getAttribute("src")==e||u.getAttribute("data-webpack")==o+i){s=u;break}}s||(p=!0,(s=document.createElement("script")).charset="utf-8",a.nc&&s.setAttribute("nonce",a.nc),s.setAttribute("data-webpack",o+i),s.src=e),r[e]=[t];var d=(t,o)=>{s.onerror=s.onload=null,clearTimeout(f);var i=r[e];if(delete r[e],s.parentNode&&s.parentNode.removeChild(s),i&&i.forEach((e=>e(o))),t)return t(o)},f=setTimeout(d.bind(null,void 0,{type:"timeout",target:s}),12e4);s.onerror=d.bind(null,s.onerror),s.onload=d.bind(null,s.onload),p&&document.head.appendChild(s)}},a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;a.g.importScripts&&(e=a.g.location+"");var t=a.g.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName("script");if(r.length)for(var o=r.length-1;o>-1&&(!e||!/^http(s?):/.test(e));)e=r[o--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),a.p=e})(),(()=>{var e={232:0};a.f.j=(t,r)=>{var o=a.o(e,t)?e[t]:void 0;if(0!==o)if(o)r.push(o[2]);else{var i=new Promise(((r,i)=>o=e[t]=[r,i]));r.push(o[2]=i);var n=a.p+a.u(t),s=new Error;a.l(n,(r=>{if(a.o(e,t)&&(0!==(o=e[t])&&(e[t]=void 0),o)){var i=r&&("load"===r.type?"missing":r.type),n=r&&r.target&&r.target.src;s.message="Loading chunk "+t+" failed.\n("+i+": "+n+")",s.name="ChunkLoadError",s.type=i,s.request=n,o[1](s)}}),"chunk-"+t,t)}};var t=(t,r)=>{var o,i,[n,s,p]=r,l=0;if(n.some((t=>0!==e[t]))){for(o in s)a.o(s,o)&&(a.m[o]=s[o]);if(p)p(a)}for(t&&t(r);l<n.length;l++)i=n[l],a.o(e,i)&&e[i]&&e[i][0](),e[i]=0},r=this.webpackChunk_tsparticles_plugin_emitters_shape_polygon=this.webpackChunk_tsparticles_plugin_emitters_shape_polygon||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))})();var s={};function p(e){e.checkVersion("4.0.0-alpha.1"),e.register((async e=>{const{EmittersPolygonShapeGenerator:t}=await a.e(595).then(a.bind(a,595));e.addEmitterShapeGenerator?.("polygon",new t)}))}return a.r(s),a.d(s,{loadEmittersShapePolygon:()=>p}),s})()));
@@ -1 +1 @@
1
- /*! tsParticles Emitters Shape Polygon Plugin v3.9.1 by Matteo Bruni */
1
+ /*! tsParticles Emitters Shape Polygon Plugin v4.0.0-alpha.1 by Matteo Bruni */
@@ -4,5 +4,5 @@ export declare class EmittersPolygonShapeOptions implements IEmittersPolygonShap
4
4
  angle: number;
5
5
  sides: number;
6
6
  constructor();
7
- load(data?: RecursivePartial<IEmittersPolygonShapeOptions> | undefined): void;
7
+ load(data?: RecursivePartial<IEmittersPolygonShapeOptions>): void;
8
8
  }
package/types/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { type Engine } from "@tsparticles/engine";
2
- export declare function loadEmittersShapePolygon(engine: Engine, refresh?: boolean): Promise<void>;
1
+ import type { Engine } from "@tsparticles/engine";
2
+ export declare function loadEmittersShapePolygon(engine: Engine): void;
package/types/utils.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { type ICoordinates } from "@tsparticles/engine";
2
2
  export declare function generateRandomPolygon(position: ICoordinates, sides: number, radius: number, rotationAngle?: number): ICoordinates[];
3
3
  export declare function generateRandomPointWithinPolygon(polygon: ICoordinates[]): ICoordinates | null;
4
- export declare function generateRandomPointOnPolygonPerimeter(polygon: ICoordinates[]): ICoordinates;
4
+ export declare function generateRandomPointOnPolygonPerimeter(polygon: ICoordinates[]): ICoordinates | undefined;
5
5
  export declare function isPointInPolygon(point: ICoordinates, polygon: ICoordinates[]): boolean;
package/umd/index.js CHANGED
@@ -1,20 +1,54 @@
1
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
2
+ if (k2 === undefined) k2 = k;
3
+ var desc = Object.getOwnPropertyDescriptor(m, k);
4
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
5
+ desc = { enumerable: true, get: function() { return m[k]; } };
6
+ }
7
+ Object.defineProperty(o, k2, desc);
8
+ }) : (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ o[k2] = m[k];
11
+ }));
12
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
13
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
14
+ }) : function(o, v) {
15
+ o["default"] = v;
16
+ });
17
+ var __importStar = (this && this.__importStar) || (function () {
18
+ var ownKeys = function(o) {
19
+ ownKeys = Object.getOwnPropertyNames || function (o) {
20
+ var ar = [];
21
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
22
+ return ar;
23
+ };
24
+ return ownKeys(o);
25
+ };
26
+ return function (mod) {
27
+ if (mod && mod.__esModule) return mod;
28
+ var result = {};
29
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
30
+ __setModuleDefault(result, mod);
31
+ return result;
32
+ };
33
+ })();
1
34
  (function (factory) {
2
35
  if (typeof module === "object" && typeof module.exports === "object") {
3
36
  var v = factory(require, exports);
4
37
  if (v !== undefined) module.exports = v;
5
38
  }
6
39
  else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "./EmittersPolygonShapeGenerator.js"], factory);
40
+ define(["require", "exports"], factory);
8
41
  }
9
42
  })(function (require, exports) {
10
43
  "use strict";
44
+ var __syncRequire = typeof module === "object" && typeof module.exports === "object";
11
45
  Object.defineProperty(exports, "__esModule", { value: true });
12
46
  exports.loadEmittersShapePolygon = loadEmittersShapePolygon;
13
- const EmittersPolygonShapeGenerator_js_1 = require("./EmittersPolygonShapeGenerator.js");
14
- async function loadEmittersShapePolygon(engine, refresh = true) {
15
- const emittersEngine = engine;
16
- emittersEngine.checkVersion("3.9.1");
17
- emittersEngine.addEmitterShapeGenerator?.("polygon", new EmittersPolygonShapeGenerator_js_1.EmittersPolygonShapeGenerator());
18
- await emittersEngine.refresh(refresh);
47
+ function loadEmittersShapePolygon(engine) {
48
+ engine.checkVersion("4.0.0-alpha.1");
49
+ engine.register(async (emittersEngine) => {
50
+ const { EmittersPolygonShapeGenerator } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./EmittersPolygonShapeGenerator.js"))) : new Promise((resolve_1, reject_1) => { require(["./EmittersPolygonShapeGenerator.js"], resolve_1, reject_1); }).then(__importStar));
51
+ emittersEngine.addEmitterShapeGenerator?.("polygon", new EmittersPolygonShapeGenerator());
52
+ });
19
53
  }
20
54
  });
package/umd/utils.js CHANGED
@@ -27,7 +27,11 @@
27
27
  return polygon;
28
28
  }
29
29
  function generateRandomPointWithinPolygon(polygon) {
30
- const firstIndex = 0, firstPoint = polygon[firstIndex], min = { ...firstPoint }, max = { ...firstPoint };
30
+ const firstIndex = 0, firstPoint = polygon[firstIndex];
31
+ if (!firstPoint) {
32
+ return null;
33
+ }
34
+ const min = { ...firstPoint }, max = { ...firstPoint };
31
35
  for (const point of polygon) {
32
36
  if (point.x < min.x) {
33
37
  min.x = point.x;
@@ -56,7 +60,15 @@
56
60
  return randomPoint;
57
61
  }
58
62
  function generateRandomPointOnPolygonPerimeter(polygon) {
59
- const sideIndex = Math.floor((0, engine_1.getRandom)() * polygon.length), startPoint = polygon[sideIndex], offset = 1, endPoint = polygon[(sideIndex + offset) % polygon.length], t = (0, engine_1.getRandom)();
63
+ const sideIndex = Math.floor((0, engine_1.getRandom)() * polygon.length), startPoint = polygon[sideIndex];
64
+ if (!startPoint) {
65
+ return;
66
+ }
67
+ const offset = 1, endPoint = polygon[(sideIndex + offset) % polygon.length];
68
+ if (!endPoint) {
69
+ return;
70
+ }
71
+ const t = (0, engine_1.getRandom)();
60
72
  return { x: startPoint.x + (endPoint.x - startPoint.x) * t, y: startPoint.y + (endPoint.y - startPoint.y) * t };
61
73
  }
62
74
  function isPointInPolygon(point, polygon) {
@@ -64,6 +76,9 @@
64
76
  const offset = 1;
65
77
  for (let i = 0, j = polygon.length - offset; i < polygon.length; j = i++) {
66
78
  const pi = polygon[i], pj = polygon[j];
79
+ if (!pi || !pj) {
80
+ continue;
81
+ }
67
82
  const intersect = pi.y > point.y !== pj.y > point.y && point.x < ((pj.x - pi.x) * (point.y - pi.y)) / (pj.y - pi.y) + pi.x;
68
83
  if (intersect) {
69
84
  inside = !inside;