@tsparticles/plugin-emitters-shape-canvas 3.0.3 → 3.2.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/720.min.js +2 -0
- package/720.min.js.LICENSE.txt +1 -0
- package/browser/EmittersCanvasShape.js +12 -12
- package/browser/Options/Classes/EmittersCanvasShapeOptions.js +2 -1
- package/browser/index.js +2 -4
- package/browser/utils.js +20 -10
- package/cjs/EmittersCanvasShape.js +12 -12
- package/cjs/Options/Classes/EmittersCanvasShapeOptions.js +2 -1
- package/cjs/index.js +25 -4
- package/cjs/utils.js +20 -10
- package/dist_browser_EmittersCanvasShapeGenerator_js.js +100 -0
- package/esm/EmittersCanvasShape.js +12 -12
- package/esm/Options/Classes/EmittersCanvasShapeOptions.js +2 -1
- package/esm/index.js +2 -4
- package/esm/utils.js +20 -10
- package/package.json +3 -3
- package/report.html +3 -3
- package/tsparticles.plugin.emitters.shape.canvas.js +246 -362
- package/tsparticles.plugin.emitters.shape.canvas.min.js +1 -1
- package/tsparticles.plugin.emitters.shape.canvas.min.js.LICENSE.txt +1 -1
- package/types/types.d.ts +4 -4
- package/types/utils.d.ts +1 -1
- package/umd/EmittersCanvasShape.js +12 -12
- package/umd/Options/Classes/EmittersCanvasShapeOptions.js +2 -1
- package/umd/index.js +27 -5
- package/umd/utils.js +20 -10
|
@@ -4,7 +4,15 @@
|
|
|
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.0
|
|
7
|
+
* v3.2.0
|
|
8
|
+
*/
|
|
9
|
+
/*
|
|
10
|
+
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
11
|
+
* This devtool is neither made for production nor for readable output files.
|
|
12
|
+
* It uses "eval()" calls to create a separate source file in the browser devtools.
|
|
13
|
+
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
|
|
14
|
+
* or disable the default devtool with "devtool: false".
|
|
15
|
+
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
|
|
8
16
|
*/
|
|
9
17
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
10
18
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
@@ -15,22 +23,38 @@
|
|
|
15
23
|
var a = typeof exports === 'object' ? factory(require("@tsparticles/plugin-emitters"), require("@tsparticles/engine")) : factory(root["window"], root["window"]);
|
|
16
24
|
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
|
|
17
25
|
}
|
|
18
|
-
})(this, (
|
|
26
|
+
})(this, (__WEBPACK_EXTERNAL_MODULE__tsparticles_plugin_emitters__, __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__) => {
|
|
19
27
|
return /******/ (() => { // webpackBootstrap
|
|
20
28
|
/******/ "use strict";
|
|
21
29
|
/******/ var __webpack_modules__ = ({
|
|
22
30
|
|
|
23
|
-
/***/
|
|
31
|
+
/***/ "./dist/browser/index.js":
|
|
32
|
+
/*!*******************************!*\
|
|
33
|
+
!*** ./dist/browser/index.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 */ loadEmittersShapeCanvas: () => (/* binding */ loadEmittersShapeCanvas)\n/* harmony export */ });\nasync function loadEmittersShapeCanvas(engine, refresh = true) {\n const emittersEngine = engine,\n {\n EmittersCanvasShapeGenerator\n } = await __webpack_require__.e(/*! import() */ \"dist_browser_EmittersCanvasShapeGenerator_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./EmittersCanvasShapeGenerator.js */ \"./dist/browser/EmittersCanvasShapeGenerator.js\"));\n emittersEngine.addEmitterShapeGenerator?.(\"canvas\", new EmittersCanvasShapeGenerator());\n await emittersEngine.refresh(refresh);\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-emitters-shape-canvas/./dist/browser/index.js?");
|
|
38
|
+
|
|
39
|
+
/***/ }),
|
|
40
|
+
|
|
41
|
+
/***/ "@tsparticles/engine":
|
|
42
|
+
/*!*********************************************************************************************************************************!*\
|
|
43
|
+
!*** external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"} ***!
|
|
44
|
+
\*********************************************************************************************************************************/
|
|
24
45
|
/***/ ((module) => {
|
|
25
46
|
|
|
26
|
-
module.exports =
|
|
47
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
|
|
27
48
|
|
|
28
49
|
/***/ }),
|
|
29
50
|
|
|
30
|
-
/***/
|
|
51
|
+
/***/ "@tsparticles/plugin-emitters":
|
|
52
|
+
/*!************************************************************************************************************************************************************!*\
|
|
53
|
+
!*** external {"commonjs":"@tsparticles/plugin-emitters","commonjs2":"@tsparticles/plugin-emitters","amd":"@tsparticles/plugin-emitters","root":"window"} ***!
|
|
54
|
+
\************************************************************************************************************************************************************/
|
|
31
55
|
/***/ ((module) => {
|
|
32
56
|
|
|
33
|
-
module.exports =
|
|
57
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_plugin_emitters__;
|
|
34
58
|
|
|
35
59
|
/***/ })
|
|
36
60
|
|
|
@@ -60,7 +84,22 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__68__;
|
|
|
60
84
|
/******/ return module.exports;
|
|
61
85
|
/******/ }
|
|
62
86
|
/******/
|
|
87
|
+
/******/ // expose the modules object (__webpack_modules__)
|
|
88
|
+
/******/ __webpack_require__.m = __webpack_modules__;
|
|
89
|
+
/******/
|
|
63
90
|
/************************************************************************/
|
|
91
|
+
/******/ /* webpack/runtime/compat get default export */
|
|
92
|
+
/******/ (() => {
|
|
93
|
+
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
94
|
+
/******/ __webpack_require__.n = (module) => {
|
|
95
|
+
/******/ var getter = module && module.__esModule ?
|
|
96
|
+
/******/ () => (module['default']) :
|
|
97
|
+
/******/ () => (module);
|
|
98
|
+
/******/ __webpack_require__.d(getter, { a: getter });
|
|
99
|
+
/******/ return getter;
|
|
100
|
+
/******/ };
|
|
101
|
+
/******/ })();
|
|
102
|
+
/******/
|
|
64
103
|
/******/ /* webpack/runtime/define property getters */
|
|
65
104
|
/******/ (() => {
|
|
66
105
|
/******/ // define getter functions for harmony exports
|
|
@@ -73,11 +112,91 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__68__;
|
|
|
73
112
|
/******/ };
|
|
74
113
|
/******/ })();
|
|
75
114
|
/******/
|
|
115
|
+
/******/ /* webpack/runtime/ensure chunk */
|
|
116
|
+
/******/ (() => {
|
|
117
|
+
/******/ __webpack_require__.f = {};
|
|
118
|
+
/******/ // This file contains only the entry chunk.
|
|
119
|
+
/******/ // The chunk loading function for additional chunks
|
|
120
|
+
/******/ __webpack_require__.e = (chunkId) => {
|
|
121
|
+
/******/ return Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key) => {
|
|
122
|
+
/******/ __webpack_require__.f[key](chunkId, promises);
|
|
123
|
+
/******/ return promises;
|
|
124
|
+
/******/ }, []));
|
|
125
|
+
/******/ };
|
|
126
|
+
/******/ })();
|
|
127
|
+
/******/
|
|
128
|
+
/******/ /* webpack/runtime/get javascript chunk filename */
|
|
129
|
+
/******/ (() => {
|
|
130
|
+
/******/ // This function allow to reference async chunks
|
|
131
|
+
/******/ __webpack_require__.u = (chunkId) => {
|
|
132
|
+
/******/ // return url for filenames based on template
|
|
133
|
+
/******/ return "" + chunkId + ".js";
|
|
134
|
+
/******/ };
|
|
135
|
+
/******/ })();
|
|
136
|
+
/******/
|
|
137
|
+
/******/ /* webpack/runtime/global */
|
|
138
|
+
/******/ (() => {
|
|
139
|
+
/******/ __webpack_require__.g = (function() {
|
|
140
|
+
/******/ if (typeof globalThis === 'object') return globalThis;
|
|
141
|
+
/******/ try {
|
|
142
|
+
/******/ return this || new Function('return this')();
|
|
143
|
+
/******/ } catch (e) {
|
|
144
|
+
/******/ if (typeof window === 'object') return window;
|
|
145
|
+
/******/ }
|
|
146
|
+
/******/ })();
|
|
147
|
+
/******/ })();
|
|
148
|
+
/******/
|
|
76
149
|
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
77
150
|
/******/ (() => {
|
|
78
151
|
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
79
152
|
/******/ })();
|
|
80
153
|
/******/
|
|
154
|
+
/******/ /* webpack/runtime/load script */
|
|
155
|
+
/******/ (() => {
|
|
156
|
+
/******/ var inProgress = {};
|
|
157
|
+
/******/ var dataWebpackPrefix = "@tsparticles/plugin-emitters-shape-canvas:";
|
|
158
|
+
/******/ // loadScript function to load a script via script tag
|
|
159
|
+
/******/ __webpack_require__.l = (url, done, key, chunkId) => {
|
|
160
|
+
/******/ if(inProgress[url]) { inProgress[url].push(done); return; }
|
|
161
|
+
/******/ var script, needAttach;
|
|
162
|
+
/******/ if(key !== undefined) {
|
|
163
|
+
/******/ var scripts = document.getElementsByTagName("script");
|
|
164
|
+
/******/ for(var i = 0; i < scripts.length; i++) {
|
|
165
|
+
/******/ var s = scripts[i];
|
|
166
|
+
/******/ if(s.getAttribute("src") == url || s.getAttribute("data-webpack") == dataWebpackPrefix + key) { script = s; break; }
|
|
167
|
+
/******/ }
|
|
168
|
+
/******/ }
|
|
169
|
+
/******/ if(!script) {
|
|
170
|
+
/******/ needAttach = true;
|
|
171
|
+
/******/ script = document.createElement('script');
|
|
172
|
+
/******/
|
|
173
|
+
/******/ script.charset = 'utf-8';
|
|
174
|
+
/******/ script.timeout = 120;
|
|
175
|
+
/******/ if (__webpack_require__.nc) {
|
|
176
|
+
/******/ script.setAttribute("nonce", __webpack_require__.nc);
|
|
177
|
+
/******/ }
|
|
178
|
+
/******/ script.setAttribute("data-webpack", dataWebpackPrefix + key);
|
|
179
|
+
/******/
|
|
180
|
+
/******/ script.src = url;
|
|
181
|
+
/******/ }
|
|
182
|
+
/******/ inProgress[url] = [done];
|
|
183
|
+
/******/ var onScriptComplete = (prev, event) => {
|
|
184
|
+
/******/ // avoid mem leaks in IE.
|
|
185
|
+
/******/ script.onerror = script.onload = null;
|
|
186
|
+
/******/ clearTimeout(timeout);
|
|
187
|
+
/******/ var doneFns = inProgress[url];
|
|
188
|
+
/******/ delete inProgress[url];
|
|
189
|
+
/******/ script.parentNode && script.parentNode.removeChild(script);
|
|
190
|
+
/******/ doneFns && doneFns.forEach((fn) => (fn(event)));
|
|
191
|
+
/******/ if(prev) return prev(event);
|
|
192
|
+
/******/ }
|
|
193
|
+
/******/ var timeout = setTimeout(onScriptComplete.bind(null, undefined, { type: 'timeout', target: script }), 120000);
|
|
194
|
+
/******/ script.onerror = onScriptComplete.bind(null, script.onerror);
|
|
195
|
+
/******/ script.onload = onScriptComplete.bind(null, script.onload);
|
|
196
|
+
/******/ needAttach && document.head.appendChild(script);
|
|
197
|
+
/******/ };
|
|
198
|
+
/******/ })();
|
|
199
|
+
/******/
|
|
81
200
|
/******/ /* webpack/runtime/make namespace object */
|
|
82
201
|
/******/ (() => {
|
|
83
202
|
/******/ // define __esModule on exports
|
|
@@ -89,363 +208,128 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__68__;
|
|
|
89
208
|
/******/ };
|
|
90
209
|
/******/ })();
|
|
91
210
|
/******/
|
|
211
|
+
/******/ /* webpack/runtime/publicPath */
|
|
212
|
+
/******/ (() => {
|
|
213
|
+
/******/ var scriptUrl;
|
|
214
|
+
/******/ if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + "";
|
|
215
|
+
/******/ var document = __webpack_require__.g.document;
|
|
216
|
+
/******/ if (!scriptUrl && document) {
|
|
217
|
+
/******/ if (document.currentScript)
|
|
218
|
+
/******/ scriptUrl = document.currentScript.src;
|
|
219
|
+
/******/ if (!scriptUrl) {
|
|
220
|
+
/******/ var scripts = document.getElementsByTagName("script");
|
|
221
|
+
/******/ if(scripts.length) {
|
|
222
|
+
/******/ var i = scripts.length - 1;
|
|
223
|
+
/******/ while (i > -1 && !scriptUrl) scriptUrl = scripts[i--].src;
|
|
224
|
+
/******/ }
|
|
225
|
+
/******/ }
|
|
226
|
+
/******/ }
|
|
227
|
+
/******/ // When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration
|
|
228
|
+
/******/ // or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.
|
|
229
|
+
/******/ if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser");
|
|
230
|
+
/******/ scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/");
|
|
231
|
+
/******/ __webpack_require__.p = scriptUrl;
|
|
232
|
+
/******/ })();
|
|
233
|
+
/******/
|
|
234
|
+
/******/ /* webpack/runtime/jsonp chunk loading */
|
|
235
|
+
/******/ (() => {
|
|
236
|
+
/******/ // no baseURI
|
|
237
|
+
/******/
|
|
238
|
+
/******/ // object to store loaded and loading chunks
|
|
239
|
+
/******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
|
|
240
|
+
/******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded
|
|
241
|
+
/******/ var installedChunks = {
|
|
242
|
+
/******/ "tsparticles.plugin.emitters.shape.canvas": 0
|
|
243
|
+
/******/ };
|
|
244
|
+
/******/
|
|
245
|
+
/******/ __webpack_require__.f.j = (chunkId, promises) => {
|
|
246
|
+
/******/ // JSONP chunk loading for javascript
|
|
247
|
+
/******/ var installedChunkData = __webpack_require__.o(installedChunks, chunkId) ? installedChunks[chunkId] : undefined;
|
|
248
|
+
/******/ if(installedChunkData !== 0) { // 0 means "already installed".
|
|
249
|
+
/******/
|
|
250
|
+
/******/ // a Promise means "currently loading".
|
|
251
|
+
/******/ if(installedChunkData) {
|
|
252
|
+
/******/ promises.push(installedChunkData[2]);
|
|
253
|
+
/******/ } else {
|
|
254
|
+
/******/ if(true) { // all chunks have JS
|
|
255
|
+
/******/ // setup Promise in chunk cache
|
|
256
|
+
/******/ var promise = new Promise((resolve, reject) => (installedChunkData = installedChunks[chunkId] = [resolve, reject]));
|
|
257
|
+
/******/ promises.push(installedChunkData[2] = promise);
|
|
258
|
+
/******/
|
|
259
|
+
/******/ // start chunk loading
|
|
260
|
+
/******/ var url = __webpack_require__.p + __webpack_require__.u(chunkId);
|
|
261
|
+
/******/ // create error before stack unwound to get useful stacktrace later
|
|
262
|
+
/******/ var error = new Error();
|
|
263
|
+
/******/ var loadingEnded = (event) => {
|
|
264
|
+
/******/ if(__webpack_require__.o(installedChunks, chunkId)) {
|
|
265
|
+
/******/ installedChunkData = installedChunks[chunkId];
|
|
266
|
+
/******/ if(installedChunkData !== 0) installedChunks[chunkId] = undefined;
|
|
267
|
+
/******/ if(installedChunkData) {
|
|
268
|
+
/******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type);
|
|
269
|
+
/******/ var realSrc = event && event.target && event.target.src;
|
|
270
|
+
/******/ error.message = 'Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')';
|
|
271
|
+
/******/ error.name = 'ChunkLoadError';
|
|
272
|
+
/******/ error.type = errorType;
|
|
273
|
+
/******/ error.request = realSrc;
|
|
274
|
+
/******/ installedChunkData[1](error);
|
|
275
|
+
/******/ }
|
|
276
|
+
/******/ }
|
|
277
|
+
/******/ };
|
|
278
|
+
/******/ __webpack_require__.l(url, loadingEnded, "chunk-" + chunkId, chunkId);
|
|
279
|
+
/******/ }
|
|
280
|
+
/******/ }
|
|
281
|
+
/******/ }
|
|
282
|
+
/******/ };
|
|
283
|
+
/******/
|
|
284
|
+
/******/ // no prefetching
|
|
285
|
+
/******/
|
|
286
|
+
/******/ // no preloaded
|
|
287
|
+
/******/
|
|
288
|
+
/******/ // no HMR
|
|
289
|
+
/******/
|
|
290
|
+
/******/ // no HMR manifest
|
|
291
|
+
/******/
|
|
292
|
+
/******/ // no on chunks loaded
|
|
293
|
+
/******/
|
|
294
|
+
/******/ // install a JSONP callback for chunk loading
|
|
295
|
+
/******/ var webpackJsonpCallback = (parentChunkLoadingFunction, data) => {
|
|
296
|
+
/******/ var chunkIds = data[0];
|
|
297
|
+
/******/ var moreModules = data[1];
|
|
298
|
+
/******/ var runtime = data[2];
|
|
299
|
+
/******/ // add "moreModules" to the modules object,
|
|
300
|
+
/******/ // then flag all "chunkIds" as loaded and fire callback
|
|
301
|
+
/******/ var moduleId, chunkId, i = 0;
|
|
302
|
+
/******/ if(chunkIds.some((id) => (installedChunks[id] !== 0))) {
|
|
303
|
+
/******/ for(moduleId in moreModules) {
|
|
304
|
+
/******/ if(__webpack_require__.o(moreModules, moduleId)) {
|
|
305
|
+
/******/ __webpack_require__.m[moduleId] = moreModules[moduleId];
|
|
306
|
+
/******/ }
|
|
307
|
+
/******/ }
|
|
308
|
+
/******/ if(runtime) var result = runtime(__webpack_require__);
|
|
309
|
+
/******/ }
|
|
310
|
+
/******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data);
|
|
311
|
+
/******/ for(;i < chunkIds.length; i++) {
|
|
312
|
+
/******/ chunkId = chunkIds[i];
|
|
313
|
+
/******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {
|
|
314
|
+
/******/ installedChunks[chunkId][0]();
|
|
315
|
+
/******/ }
|
|
316
|
+
/******/ installedChunks[chunkId] = 0;
|
|
317
|
+
/******/ }
|
|
318
|
+
/******/
|
|
319
|
+
/******/ }
|
|
320
|
+
/******/
|
|
321
|
+
/******/ var chunkLoadingGlobal = this["webpackChunk_tsparticles_plugin_emitters_shape_canvas"] = this["webpackChunk_tsparticles_plugin_emitters_shape_canvas"] || [];
|
|
322
|
+
/******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));
|
|
323
|
+
/******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));
|
|
324
|
+
/******/ })();
|
|
325
|
+
/******/
|
|
92
326
|
/************************************************************************/
|
|
93
|
-
|
|
94
|
-
//
|
|
95
|
-
|
|
96
|
-
//
|
|
97
|
-
__webpack_require__.
|
|
98
|
-
|
|
99
|
-
// EXPORTS
|
|
100
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
101
|
-
loadEmittersShapeCanvas: () => (/* binding */ loadEmittersShapeCanvas)
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
// EXTERNAL MODULE: external {"commonjs":"@tsparticles/plugin-emitters","commonjs2":"@tsparticles/plugin-emitters","amd":"@tsparticles/plugin-emitters","root":"window"}
|
|
105
|
-
var plugin_emitters_root_window_ = __webpack_require__(68);
|
|
106
|
-
// EXTERNAL MODULE: external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"}
|
|
107
|
-
var engine_root_window_ = __webpack_require__(533);
|
|
108
|
-
;// CONCATENATED MODULE: ./dist/browser/utils.js
|
|
109
|
-
|
|
110
|
-
function getCanvasImageData(ctx, size, offset, clear = true) {
|
|
111
|
-
const imageData = ctx.getImageData(0, 0, size.width, size.height).data;
|
|
112
|
-
if (clear) {
|
|
113
|
-
ctx.clearRect(0, 0, size.width, size.height);
|
|
114
|
-
}
|
|
115
|
-
const pixels = [];
|
|
116
|
-
for (let i = 0; i < imageData.length; i += offset) {
|
|
117
|
-
const idx = i / offset,
|
|
118
|
-
pos = {
|
|
119
|
-
x: idx % size.width,
|
|
120
|
-
y: Math.floor(idx / size.width)
|
|
121
|
-
};
|
|
122
|
-
if (!pixels[pos.y]) {
|
|
123
|
-
pixels[pos.y] = [];
|
|
124
|
-
}
|
|
125
|
-
pixels[pos.y][pos.x] = {
|
|
126
|
-
r: imageData[i],
|
|
127
|
-
g: imageData[i + 1],
|
|
128
|
-
b: imageData[i + 2],
|
|
129
|
-
a: imageData[i + 3] / 255
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
return {
|
|
133
|
-
pixels,
|
|
134
|
-
width: Math.min(...pixels.map(row => row.length)),
|
|
135
|
-
height: pixels.length
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
function getImageData(src, offset) {
|
|
139
|
-
const image = new Image();
|
|
140
|
-
image.crossOrigin = "Anonymous";
|
|
141
|
-
const p = new Promise((resolve, reject) => {
|
|
142
|
-
image.onerror = reject;
|
|
143
|
-
image.onload = () => {
|
|
144
|
-
const canvas = document.createElement("canvas");
|
|
145
|
-
canvas.width = image.width;
|
|
146
|
-
canvas.height = image.height;
|
|
147
|
-
const context = canvas.getContext("2d");
|
|
148
|
-
if (!context) {
|
|
149
|
-
return reject(new Error(`${engine_root_window_.errorPrefix} Could not get canvas context`));
|
|
150
|
-
}
|
|
151
|
-
context.drawImage(image, 0, 0, image.width, image.height, 0, 0, canvas.width, canvas.height);
|
|
152
|
-
resolve(getCanvasImageData(context, canvas, offset));
|
|
153
|
-
};
|
|
154
|
-
});
|
|
155
|
-
image.src = src;
|
|
156
|
-
return p;
|
|
157
|
-
}
|
|
158
|
-
function getTextData(textOptions, offset, fill) {
|
|
159
|
-
const canvas = document.createElement("canvas"),
|
|
160
|
-
context = canvas.getContext("2d"),
|
|
161
|
-
{
|
|
162
|
-
font,
|
|
163
|
-
text,
|
|
164
|
-
lines: linesOptions,
|
|
165
|
-
color
|
|
166
|
-
} = textOptions;
|
|
167
|
-
if (!text || !context) {
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
const lines = text.split(linesOptions.separator),
|
|
171
|
-
fontSize = (0,engine_root_window_.isNumber)(font.size) ? `${font.size}px` : font.size,
|
|
172
|
-
linesData = [];
|
|
173
|
-
let maxWidth = 0,
|
|
174
|
-
totalHeight = 0;
|
|
175
|
-
for (const line of lines) {
|
|
176
|
-
context.font = `${font.style || ""} ${font.variant || ""} ${font.weight || ""} ${fontSize} ${font.family}`;
|
|
177
|
-
const measure = context.measureText(line),
|
|
178
|
-
lineData = {
|
|
179
|
-
measure,
|
|
180
|
-
text: line,
|
|
181
|
-
height: measure.actualBoundingBoxAscent + measure.actualBoundingBoxDescent,
|
|
182
|
-
width: measure.width
|
|
183
|
-
};
|
|
184
|
-
maxWidth = Math.max(maxWidth || 0, lineData.width);
|
|
185
|
-
totalHeight += lineData.height + linesOptions.spacing;
|
|
186
|
-
linesData.push(lineData);
|
|
187
|
-
}
|
|
188
|
-
canvas.width = maxWidth;
|
|
189
|
-
canvas.height = totalHeight;
|
|
190
|
-
let currentHeight = 0;
|
|
191
|
-
for (const line of linesData) {
|
|
192
|
-
context.font = `${font.style || ""} ${font.variant || ""} ${font.weight || ""} ${fontSize} ${font.family}`;
|
|
193
|
-
if (fill) {
|
|
194
|
-
context.fillStyle = color;
|
|
195
|
-
context.fillText(line.text, 0, currentHeight + line.measure.actualBoundingBoxAscent);
|
|
196
|
-
} else {
|
|
197
|
-
context.strokeStyle = color;
|
|
198
|
-
context.strokeText(line.text, 0, currentHeight + line.measure.actualBoundingBoxAscent);
|
|
199
|
-
}
|
|
200
|
-
currentHeight += line.height + linesOptions.spacing;
|
|
201
|
-
}
|
|
202
|
-
return getCanvasImageData(context, canvas, offset);
|
|
203
|
-
}
|
|
204
|
-
;// CONCATENATED MODULE: ./dist/browser/EmittersCanvasShape.js
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
class EmittersCanvasShape extends plugin_emitters_root_window_.EmitterShapeBase {
|
|
209
|
-
constructor(position, size, fill, options) {
|
|
210
|
-
super(position, size, fill, options);
|
|
211
|
-
const filter = options.filter;
|
|
212
|
-
let filterFunc = pixel => pixel.a > 0;
|
|
213
|
-
if (filter !== undefined) {
|
|
214
|
-
if ((0,engine_root_window_.isString)(filter)) {
|
|
215
|
-
if (Object.hasOwn(window, filter)) {
|
|
216
|
-
const wndFilter = window[filter];
|
|
217
|
-
if ((0,engine_root_window_.isFunction)(wndFilter)) {
|
|
218
|
-
filterFunc = wndFilter;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
} else {
|
|
222
|
-
filterFunc = filter;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
this.filter = filterFunc;
|
|
226
|
-
this.scale = options.scale;
|
|
227
|
-
this.pixelData = {
|
|
228
|
-
pixels: [],
|
|
229
|
-
height: 0,
|
|
230
|
-
width: 0
|
|
231
|
-
};
|
|
232
|
-
}
|
|
233
|
-
async init() {
|
|
234
|
-
let pixelData;
|
|
235
|
-
const options = this.options,
|
|
236
|
-
selector = options.selector,
|
|
237
|
-
pixels = options.pixels,
|
|
238
|
-
image = options.image,
|
|
239
|
-
element = options.element,
|
|
240
|
-
text = options.text,
|
|
241
|
-
offset = pixels.offset;
|
|
242
|
-
if (image) {
|
|
243
|
-
const url = image.src;
|
|
244
|
-
if (!url) {
|
|
245
|
-
return;
|
|
246
|
-
}
|
|
247
|
-
pixelData = await getImageData(url, offset);
|
|
248
|
-
} else if (text) {
|
|
249
|
-
const data = getTextData(text, offset, this.fill);
|
|
250
|
-
if (!data) {
|
|
251
|
-
return;
|
|
252
|
-
}
|
|
253
|
-
pixelData = data;
|
|
254
|
-
} else if (element || selector) {
|
|
255
|
-
const canvas = element || selector && document.querySelector(selector);
|
|
256
|
-
if (!canvas) {
|
|
257
|
-
return;
|
|
258
|
-
}
|
|
259
|
-
const context = canvas.getContext("2d");
|
|
260
|
-
if (!context) {
|
|
261
|
-
return;
|
|
262
|
-
}
|
|
263
|
-
pixelData = getCanvasImageData(context, canvas, offset);
|
|
264
|
-
}
|
|
265
|
-
if (!pixelData) {
|
|
266
|
-
return;
|
|
267
|
-
}
|
|
268
|
-
this.pixelData = pixelData;
|
|
269
|
-
}
|
|
270
|
-
async randomPosition() {
|
|
271
|
-
const {
|
|
272
|
-
height,
|
|
273
|
-
width
|
|
274
|
-
} = this.pixelData,
|
|
275
|
-
data = this.pixelData,
|
|
276
|
-
position = this.position,
|
|
277
|
-
scale = this.scale;
|
|
278
|
-
const positionOffset = {
|
|
279
|
-
x: position.x - width * scale / 2,
|
|
280
|
-
y: position.y - height * scale / 2
|
|
281
|
-
};
|
|
282
|
-
for (let i = 0; i < 100; i++) {
|
|
283
|
-
const nextIndex = Math.floor((0,engine_root_window_.getRandom)() * width * height),
|
|
284
|
-
pixelPos = {
|
|
285
|
-
x: nextIndex % width,
|
|
286
|
-
y: Math.floor(nextIndex / width)
|
|
287
|
-
},
|
|
288
|
-
pixel = data.pixels[pixelPos.y][pixelPos.x],
|
|
289
|
-
shouldCreateParticle = this.filter(pixel);
|
|
290
|
-
if (!shouldCreateParticle) {
|
|
291
|
-
continue;
|
|
292
|
-
}
|
|
293
|
-
return {
|
|
294
|
-
position: {
|
|
295
|
-
x: pixelPos.x * scale + positionOffset.x,
|
|
296
|
-
y: pixelPos.y * scale + positionOffset.y
|
|
297
|
-
},
|
|
298
|
-
color: {
|
|
299
|
-
...pixel
|
|
300
|
-
},
|
|
301
|
-
opacity: pixel.a
|
|
302
|
-
};
|
|
303
|
-
}
|
|
304
|
-
return null;
|
|
305
|
-
}
|
|
306
|
-
resize(position, size) {
|
|
307
|
-
super.resize(position, size);
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
;// CONCATENATED MODULE: ./dist/browser/Options/Classes/PixelsOptions.js
|
|
311
|
-
class PixelsOptions {
|
|
312
|
-
constructor() {
|
|
313
|
-
this.offset = 4;
|
|
314
|
-
}
|
|
315
|
-
load(data) {
|
|
316
|
-
if (!data) {
|
|
317
|
-
return;
|
|
318
|
-
}
|
|
319
|
-
if (data.offset !== undefined) {
|
|
320
|
-
this.offset = data.offset;
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
;// CONCATENATED MODULE: ./dist/browser/Options/Classes/TextFontOptions.js
|
|
325
|
-
class TextFontOptions {
|
|
326
|
-
constructor() {
|
|
327
|
-
this.family = "Verdana";
|
|
328
|
-
this.size = 32;
|
|
329
|
-
this.style = "";
|
|
330
|
-
this.variant = "";
|
|
331
|
-
this.weight = "";
|
|
332
|
-
}
|
|
333
|
-
load(data) {
|
|
334
|
-
if (!data) {
|
|
335
|
-
return;
|
|
336
|
-
}
|
|
337
|
-
if (data.family !== undefined) {
|
|
338
|
-
this.family = data.family;
|
|
339
|
-
}
|
|
340
|
-
if (data.size !== undefined) {
|
|
341
|
-
this.size = data.size;
|
|
342
|
-
}
|
|
343
|
-
if (data.style !== undefined) {
|
|
344
|
-
this.style = data.style;
|
|
345
|
-
}
|
|
346
|
-
if (data.variant !== undefined) {
|
|
347
|
-
this.variant = data.variant;
|
|
348
|
-
}
|
|
349
|
-
if (data.weight !== undefined) {
|
|
350
|
-
this.weight = data.weight;
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
;// CONCATENATED MODULE: ./dist/browser/Options/Classes/TextLinesOptions.js
|
|
355
|
-
class TextLinesOptions {
|
|
356
|
-
constructor() {
|
|
357
|
-
this.separator = "\n";
|
|
358
|
-
this.spacing = 0;
|
|
359
|
-
}
|
|
360
|
-
load(data) {
|
|
361
|
-
if (!data) {
|
|
362
|
-
return;
|
|
363
|
-
}
|
|
364
|
-
if (data.separator !== undefined) {
|
|
365
|
-
this.separator = data.separator;
|
|
366
|
-
}
|
|
367
|
-
if (data.spacing !== undefined) {
|
|
368
|
-
this.spacing = data.spacing;
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
;// CONCATENATED MODULE: ./dist/browser/Options/Classes/TextOptions.js
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
class TextOptions {
|
|
376
|
-
constructor() {
|
|
377
|
-
this.color = "#000000";
|
|
378
|
-
this.font = new TextFontOptions();
|
|
379
|
-
this.lines = new TextLinesOptions();
|
|
380
|
-
this.text = "";
|
|
381
|
-
}
|
|
382
|
-
load(data) {
|
|
383
|
-
if (!data) {
|
|
384
|
-
return;
|
|
385
|
-
}
|
|
386
|
-
if (data.color !== undefined) {
|
|
387
|
-
this.color = data.color;
|
|
388
|
-
}
|
|
389
|
-
this.font.load(data.font);
|
|
390
|
-
this.lines.load(data.lines);
|
|
391
|
-
if (data.text !== undefined) {
|
|
392
|
-
this.text = data.text;
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
;// CONCATENATED MODULE: ./dist/browser/Options/Classes/EmittersCanvasShapeOptions.js
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
class EmittersCanvasShapeOptions {
|
|
400
|
-
constructor() {
|
|
401
|
-
this.filter = pixel => pixel.a > 0;
|
|
402
|
-
this.pixels = new PixelsOptions();
|
|
403
|
-
this.scale = 1;
|
|
404
|
-
this.selector = "";
|
|
405
|
-
this.text = new TextOptions();
|
|
406
|
-
}
|
|
407
|
-
load(data) {
|
|
408
|
-
if (!data) {
|
|
409
|
-
return;
|
|
410
|
-
}
|
|
411
|
-
if (data.element !== undefined) {
|
|
412
|
-
this.element = data.element;
|
|
413
|
-
}
|
|
414
|
-
if (data.filter !== undefined) {
|
|
415
|
-
this.filter = data.filter;
|
|
416
|
-
}
|
|
417
|
-
this.pixels.load(data.pixels);
|
|
418
|
-
if (data.scale !== undefined) {
|
|
419
|
-
this.scale = data.scale;
|
|
420
|
-
}
|
|
421
|
-
if (data.selector !== undefined) {
|
|
422
|
-
this.selector = data.selector;
|
|
423
|
-
}
|
|
424
|
-
if (data.image !== undefined) {
|
|
425
|
-
this.image = data.image;
|
|
426
|
-
}
|
|
427
|
-
this.text.load(data.text);
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
;// CONCATENATED MODULE: ./dist/browser/EmittersCanvasShapeGenerator.js
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
class EmittersCanvasShapeGenerator {
|
|
434
|
-
generate(position, size, fill, options) {
|
|
435
|
-
const shapeOptions = new EmittersCanvasShapeOptions();
|
|
436
|
-
shapeOptions.load(options);
|
|
437
|
-
return new EmittersCanvasShape(position, size, fill, shapeOptions);
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
;// CONCATENATED MODULE: ./dist/browser/index.js
|
|
441
|
-
|
|
442
|
-
async function loadEmittersShapeCanvas(engine, refresh = true) {
|
|
443
|
-
const emittersEngine = engine;
|
|
444
|
-
emittersEngine.addEmitterShapeGenerator && emittersEngine.addEmitterShapeGenerator("canvas", new EmittersCanvasShapeGenerator());
|
|
445
|
-
await emittersEngine.refresh(refresh);
|
|
446
|
-
}
|
|
447
|
-
})();
|
|
448
|
-
|
|
327
|
+
/******/
|
|
328
|
+
/******/ // startup
|
|
329
|
+
/******/ // Load entry module and return exports
|
|
330
|
+
/******/ // This entry module can't be inlined because the eval devtool is used.
|
|
331
|
+
/******/ var __webpack_exports__ = __webpack_require__("./dist/browser/index.js");
|
|
332
|
+
/******/
|
|
449
333
|
/******/ return __webpack_exports__;
|
|
450
334
|
/******/ })()
|
|
451
335
|
;
|