@tsparticles/plugin-canvas-mask 3.1.0 → 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/262.min.js +2 -0
- package/262.min.js.LICENSE.txt +1 -0
- package/73.min.js +2 -0
- package/73.min.js.LICENSE.txt +1 -0
- package/browser/CanvasMaskInstance.js +1 -1
- package/browser/CanvasMaskPlugin.js +23 -0
- package/browser/index.js +1 -23
- package/browser/utils.js +2 -2
- package/cjs/CanvasMaskInstance.js +1 -1
- package/cjs/CanvasMaskPlugin.js +50 -0
- package/cjs/index.js +24 -23
- package/cjs/utils.js +2 -2
- package/dist_browser_CanvasMaskInstance_js.js +40 -0
- package/dist_browser_CanvasMaskPlugin_js.js +100 -0
- package/esm/CanvasMaskInstance.js +1 -1
- package/esm/CanvasMaskPlugin.js +23 -0
- package/esm/index.js +1 -23
- package/esm/utils.js +2 -2
- package/package.json +2 -2
- package/report.html +3 -3
- package/tsparticles.plugin.canvas-mask.js +241 -434
- package/tsparticles.plugin.canvas-mask.min.js +1 -1
- package/tsparticles.plugin.canvas-mask.min.js.LICENSE.txt +1 -1
- package/types/CanvasMaskPlugin.d.ts +10 -0
- package/types/utils.d.ts +1 -1
- package/umd/CanvasMaskInstance.js +1 -1
- package/umd/CanvasMaskPlugin.js +61 -0
- package/umd/index.js +26 -24
- package/umd/utils.js +2 -2
|
@@ -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.
|
|
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,15 +23,28 @@
|
|
|
15
23
|
var a = typeof exports === 'object' ? factory(require("@tsparticles/engine")) : factory(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_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 */ loadCanvasMaskPlugin: () => (/* binding */ loadCanvasMaskPlugin)\n/* harmony export */ });\nasync function loadCanvasMaskPlugin(engine, refresh = true) {\n const {\n CanvasMaskPlugin\n } = await __webpack_require__.e(/*! import() */ \"dist_browser_CanvasMaskPlugin_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./CanvasMaskPlugin.js */ \"./dist/browser/CanvasMaskPlugin.js\"));\n await engine.addPlugin(new CanvasMaskPlugin(), refresh);\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-canvas-mask/./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
|
|
|
@@ -53,7 +74,22 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__533__;
|
|
|
53
74
|
/******/ return module.exports;
|
|
54
75
|
/******/ }
|
|
55
76
|
/******/
|
|
77
|
+
/******/ // expose the modules object (__webpack_modules__)
|
|
78
|
+
/******/ __webpack_require__.m = __webpack_modules__;
|
|
79
|
+
/******/
|
|
56
80
|
/************************************************************************/
|
|
81
|
+
/******/ /* webpack/runtime/compat get default export */
|
|
82
|
+
/******/ (() => {
|
|
83
|
+
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
84
|
+
/******/ __webpack_require__.n = (module) => {
|
|
85
|
+
/******/ var getter = module && module.__esModule ?
|
|
86
|
+
/******/ () => (module['default']) :
|
|
87
|
+
/******/ () => (module);
|
|
88
|
+
/******/ __webpack_require__.d(getter, { a: getter });
|
|
89
|
+
/******/ return getter;
|
|
90
|
+
/******/ };
|
|
91
|
+
/******/ })();
|
|
92
|
+
/******/
|
|
57
93
|
/******/ /* webpack/runtime/define property getters */
|
|
58
94
|
/******/ (() => {
|
|
59
95
|
/******/ // define getter functions for harmony exports
|
|
@@ -66,11 +102,91 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__533__;
|
|
|
66
102
|
/******/ };
|
|
67
103
|
/******/ })();
|
|
68
104
|
/******/
|
|
105
|
+
/******/ /* webpack/runtime/ensure chunk */
|
|
106
|
+
/******/ (() => {
|
|
107
|
+
/******/ __webpack_require__.f = {};
|
|
108
|
+
/******/ // This file contains only the entry chunk.
|
|
109
|
+
/******/ // The chunk loading function for additional chunks
|
|
110
|
+
/******/ __webpack_require__.e = (chunkId) => {
|
|
111
|
+
/******/ return Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key) => {
|
|
112
|
+
/******/ __webpack_require__.f[key](chunkId, promises);
|
|
113
|
+
/******/ return promises;
|
|
114
|
+
/******/ }, []));
|
|
115
|
+
/******/ };
|
|
116
|
+
/******/ })();
|
|
117
|
+
/******/
|
|
118
|
+
/******/ /* webpack/runtime/get javascript chunk filename */
|
|
119
|
+
/******/ (() => {
|
|
120
|
+
/******/ // This function allow to reference async chunks
|
|
121
|
+
/******/ __webpack_require__.u = (chunkId) => {
|
|
122
|
+
/******/ // return url for filenames based on template
|
|
123
|
+
/******/ return "" + chunkId + ".js";
|
|
124
|
+
/******/ };
|
|
125
|
+
/******/ })();
|
|
126
|
+
/******/
|
|
127
|
+
/******/ /* webpack/runtime/global */
|
|
128
|
+
/******/ (() => {
|
|
129
|
+
/******/ __webpack_require__.g = (function() {
|
|
130
|
+
/******/ if (typeof globalThis === 'object') return globalThis;
|
|
131
|
+
/******/ try {
|
|
132
|
+
/******/ return this || new Function('return this')();
|
|
133
|
+
/******/ } catch (e) {
|
|
134
|
+
/******/ if (typeof window === 'object') return window;
|
|
135
|
+
/******/ }
|
|
136
|
+
/******/ })();
|
|
137
|
+
/******/ })();
|
|
138
|
+
/******/
|
|
69
139
|
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
70
140
|
/******/ (() => {
|
|
71
141
|
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
72
142
|
/******/ })();
|
|
73
143
|
/******/
|
|
144
|
+
/******/ /* webpack/runtime/load script */
|
|
145
|
+
/******/ (() => {
|
|
146
|
+
/******/ var inProgress = {};
|
|
147
|
+
/******/ var dataWebpackPrefix = "@tsparticles/plugin-canvas-mask:";
|
|
148
|
+
/******/ // loadScript function to load a script via script tag
|
|
149
|
+
/******/ __webpack_require__.l = (url, done, key, chunkId) => {
|
|
150
|
+
/******/ if(inProgress[url]) { inProgress[url].push(done); return; }
|
|
151
|
+
/******/ var script, needAttach;
|
|
152
|
+
/******/ if(key !== undefined) {
|
|
153
|
+
/******/ var scripts = document.getElementsByTagName("script");
|
|
154
|
+
/******/ for(var i = 0; i < scripts.length; i++) {
|
|
155
|
+
/******/ var s = scripts[i];
|
|
156
|
+
/******/ if(s.getAttribute("src") == url || s.getAttribute("data-webpack") == dataWebpackPrefix + key) { script = s; break; }
|
|
157
|
+
/******/ }
|
|
158
|
+
/******/ }
|
|
159
|
+
/******/ if(!script) {
|
|
160
|
+
/******/ needAttach = true;
|
|
161
|
+
/******/ script = document.createElement('script');
|
|
162
|
+
/******/
|
|
163
|
+
/******/ script.charset = 'utf-8';
|
|
164
|
+
/******/ script.timeout = 120;
|
|
165
|
+
/******/ if (__webpack_require__.nc) {
|
|
166
|
+
/******/ script.setAttribute("nonce", __webpack_require__.nc);
|
|
167
|
+
/******/ }
|
|
168
|
+
/******/ script.setAttribute("data-webpack", dataWebpackPrefix + key);
|
|
169
|
+
/******/
|
|
170
|
+
/******/ script.src = url;
|
|
171
|
+
/******/ }
|
|
172
|
+
/******/ inProgress[url] = [done];
|
|
173
|
+
/******/ var onScriptComplete = (prev, event) => {
|
|
174
|
+
/******/ // avoid mem leaks in IE.
|
|
175
|
+
/******/ script.onerror = script.onload = null;
|
|
176
|
+
/******/ clearTimeout(timeout);
|
|
177
|
+
/******/ var doneFns = inProgress[url];
|
|
178
|
+
/******/ delete inProgress[url];
|
|
179
|
+
/******/ script.parentNode && script.parentNode.removeChild(script);
|
|
180
|
+
/******/ doneFns && doneFns.forEach((fn) => (fn(event)));
|
|
181
|
+
/******/ if(prev) return prev(event);
|
|
182
|
+
/******/ }
|
|
183
|
+
/******/ var timeout = setTimeout(onScriptComplete.bind(null, undefined, { type: 'timeout', target: script }), 120000);
|
|
184
|
+
/******/ script.onerror = onScriptComplete.bind(null, script.onerror);
|
|
185
|
+
/******/ script.onload = onScriptComplete.bind(null, script.onload);
|
|
186
|
+
/******/ needAttach && document.head.appendChild(script);
|
|
187
|
+
/******/ };
|
|
188
|
+
/******/ })();
|
|
189
|
+
/******/
|
|
74
190
|
/******/ /* webpack/runtime/make namespace object */
|
|
75
191
|
/******/ (() => {
|
|
76
192
|
/******/ // define __esModule on exports
|
|
@@ -82,437 +198,128 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__533__;
|
|
|
82
198
|
/******/ };
|
|
83
199
|
/******/ })();
|
|
84
200
|
/******/
|
|
201
|
+
/******/ /* webpack/runtime/publicPath */
|
|
202
|
+
/******/ (() => {
|
|
203
|
+
/******/ var scriptUrl;
|
|
204
|
+
/******/ if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + "";
|
|
205
|
+
/******/ var document = __webpack_require__.g.document;
|
|
206
|
+
/******/ if (!scriptUrl && document) {
|
|
207
|
+
/******/ if (document.currentScript)
|
|
208
|
+
/******/ scriptUrl = document.currentScript.src;
|
|
209
|
+
/******/ if (!scriptUrl) {
|
|
210
|
+
/******/ var scripts = document.getElementsByTagName("script");
|
|
211
|
+
/******/ if(scripts.length) {
|
|
212
|
+
/******/ var i = scripts.length - 1;
|
|
213
|
+
/******/ while (i > -1 && !scriptUrl) scriptUrl = scripts[i--].src;
|
|
214
|
+
/******/ }
|
|
215
|
+
/******/ }
|
|
216
|
+
/******/ }
|
|
217
|
+
/******/ // When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration
|
|
218
|
+
/******/ // or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.
|
|
219
|
+
/******/ if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser");
|
|
220
|
+
/******/ scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/");
|
|
221
|
+
/******/ __webpack_require__.p = scriptUrl;
|
|
222
|
+
/******/ })();
|
|
223
|
+
/******/
|
|
224
|
+
/******/ /* webpack/runtime/jsonp chunk loading */
|
|
225
|
+
/******/ (() => {
|
|
226
|
+
/******/ // no baseURI
|
|
227
|
+
/******/
|
|
228
|
+
/******/ // object to store loaded and loading chunks
|
|
229
|
+
/******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
|
|
230
|
+
/******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded
|
|
231
|
+
/******/ var installedChunks = {
|
|
232
|
+
/******/ "tsparticles.plugin.canvas-mask": 0
|
|
233
|
+
/******/ };
|
|
234
|
+
/******/
|
|
235
|
+
/******/ __webpack_require__.f.j = (chunkId, promises) => {
|
|
236
|
+
/******/ // JSONP chunk loading for javascript
|
|
237
|
+
/******/ var installedChunkData = __webpack_require__.o(installedChunks, chunkId) ? installedChunks[chunkId] : undefined;
|
|
238
|
+
/******/ if(installedChunkData !== 0) { // 0 means "already installed".
|
|
239
|
+
/******/
|
|
240
|
+
/******/ // a Promise means "currently loading".
|
|
241
|
+
/******/ if(installedChunkData) {
|
|
242
|
+
/******/ promises.push(installedChunkData[2]);
|
|
243
|
+
/******/ } else {
|
|
244
|
+
/******/ if(true) { // all chunks have JS
|
|
245
|
+
/******/ // setup Promise in chunk cache
|
|
246
|
+
/******/ var promise = new Promise((resolve, reject) => (installedChunkData = installedChunks[chunkId] = [resolve, reject]));
|
|
247
|
+
/******/ promises.push(installedChunkData[2] = promise);
|
|
248
|
+
/******/
|
|
249
|
+
/******/ // start chunk loading
|
|
250
|
+
/******/ var url = __webpack_require__.p + __webpack_require__.u(chunkId);
|
|
251
|
+
/******/ // create error before stack unwound to get useful stacktrace later
|
|
252
|
+
/******/ var error = new Error();
|
|
253
|
+
/******/ var loadingEnded = (event) => {
|
|
254
|
+
/******/ if(__webpack_require__.o(installedChunks, chunkId)) {
|
|
255
|
+
/******/ installedChunkData = installedChunks[chunkId];
|
|
256
|
+
/******/ if(installedChunkData !== 0) installedChunks[chunkId] = undefined;
|
|
257
|
+
/******/ if(installedChunkData) {
|
|
258
|
+
/******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type);
|
|
259
|
+
/******/ var realSrc = event && event.target && event.target.src;
|
|
260
|
+
/******/ error.message = 'Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')';
|
|
261
|
+
/******/ error.name = 'ChunkLoadError';
|
|
262
|
+
/******/ error.type = errorType;
|
|
263
|
+
/******/ error.request = realSrc;
|
|
264
|
+
/******/ installedChunkData[1](error);
|
|
265
|
+
/******/ }
|
|
266
|
+
/******/ }
|
|
267
|
+
/******/ };
|
|
268
|
+
/******/ __webpack_require__.l(url, loadingEnded, "chunk-" + chunkId, chunkId);
|
|
269
|
+
/******/ }
|
|
270
|
+
/******/ }
|
|
271
|
+
/******/ }
|
|
272
|
+
/******/ };
|
|
273
|
+
/******/
|
|
274
|
+
/******/ // no prefetching
|
|
275
|
+
/******/
|
|
276
|
+
/******/ // no preloaded
|
|
277
|
+
/******/
|
|
278
|
+
/******/ // no HMR
|
|
279
|
+
/******/
|
|
280
|
+
/******/ // no HMR manifest
|
|
281
|
+
/******/
|
|
282
|
+
/******/ // no on chunks loaded
|
|
283
|
+
/******/
|
|
284
|
+
/******/ // install a JSONP callback for chunk loading
|
|
285
|
+
/******/ var webpackJsonpCallback = (parentChunkLoadingFunction, data) => {
|
|
286
|
+
/******/ var chunkIds = data[0];
|
|
287
|
+
/******/ var moreModules = data[1];
|
|
288
|
+
/******/ var runtime = data[2];
|
|
289
|
+
/******/ // add "moreModules" to the modules object,
|
|
290
|
+
/******/ // then flag all "chunkIds" as loaded and fire callback
|
|
291
|
+
/******/ var moduleId, chunkId, i = 0;
|
|
292
|
+
/******/ if(chunkIds.some((id) => (installedChunks[id] !== 0))) {
|
|
293
|
+
/******/ for(moduleId in moreModules) {
|
|
294
|
+
/******/ if(__webpack_require__.o(moreModules, moduleId)) {
|
|
295
|
+
/******/ __webpack_require__.m[moduleId] = moreModules[moduleId];
|
|
296
|
+
/******/ }
|
|
297
|
+
/******/ }
|
|
298
|
+
/******/ if(runtime) var result = runtime(__webpack_require__);
|
|
299
|
+
/******/ }
|
|
300
|
+
/******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data);
|
|
301
|
+
/******/ for(;i < chunkIds.length; i++) {
|
|
302
|
+
/******/ chunkId = chunkIds[i];
|
|
303
|
+
/******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {
|
|
304
|
+
/******/ installedChunks[chunkId][0]();
|
|
305
|
+
/******/ }
|
|
306
|
+
/******/ installedChunks[chunkId] = 0;
|
|
307
|
+
/******/ }
|
|
308
|
+
/******/
|
|
309
|
+
/******/ }
|
|
310
|
+
/******/
|
|
311
|
+
/******/ var chunkLoadingGlobal = this["webpackChunk_tsparticles_plugin_canvas_mask"] = this["webpackChunk_tsparticles_plugin_canvas_mask"] || [];
|
|
312
|
+
/******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));
|
|
313
|
+
/******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));
|
|
314
|
+
/******/ })();
|
|
315
|
+
/******/
|
|
85
316
|
/************************************************************************/
|
|
86
|
-
|
|
87
|
-
//
|
|
88
|
-
|
|
89
|
-
//
|
|
90
|
-
__webpack_require__.
|
|
91
|
-
|
|
92
|
-
// EXPORTS
|
|
93
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
94
|
-
loadCanvasMaskPlugin: () => (/* binding */ loadCanvasMaskPlugin)
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
;// CONCATENATED MODULE: ./dist/browser/Options/Classes/CanvasMaskOverride.js
|
|
98
|
-
class CanvasMaskOverride {
|
|
99
|
-
constructor() {
|
|
100
|
-
this.color = true;
|
|
101
|
-
this.opacity = false;
|
|
102
|
-
}
|
|
103
|
-
load(data) {
|
|
104
|
-
if (!data) {
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
if (data.color !== undefined) {
|
|
108
|
-
this.color = data.color;
|
|
109
|
-
}
|
|
110
|
-
if (data.opacity !== undefined) {
|
|
111
|
-
this.opacity = data.opacity;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
// EXTERNAL MODULE: external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"}
|
|
116
|
-
var engine_root_window_ = __webpack_require__(533);
|
|
117
|
-
;// CONCATENATED MODULE: ./dist/browser/Options/Classes/CanvasMaskPixels.js
|
|
118
|
-
|
|
119
|
-
const minAlpha = 0;
|
|
120
|
-
class CanvasMaskPixels {
|
|
121
|
-
constructor() {
|
|
122
|
-
this.filter = pixel => pixel.a > minAlpha;
|
|
123
|
-
this.offset = 4;
|
|
124
|
-
}
|
|
125
|
-
load(data) {
|
|
126
|
-
if (!data) {
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
if (data.filter !== undefined) {
|
|
130
|
-
if ((0,engine_root_window_.isString)(data.filter)) {
|
|
131
|
-
if (Object.hasOwn(window, data.filter)) {
|
|
132
|
-
const filter = window[data.filter];
|
|
133
|
-
if ((0,engine_root_window_.isFunction)(filter)) {
|
|
134
|
-
this.filter = filter;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
} else {
|
|
138
|
-
this.filter = data.filter;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
if (data.offset !== undefined) {
|
|
142
|
-
this.offset = data.offset;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
;// CONCATENATED MODULE: ./dist/browser/Options/Classes/ImageMask.js
|
|
147
|
-
class ImageMask {
|
|
148
|
-
constructor() {
|
|
149
|
-
this.src = "";
|
|
150
|
-
}
|
|
151
|
-
load(data) {
|
|
152
|
-
if (!data) {
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
if (data.src !== undefined) {
|
|
156
|
-
this.src = data.src;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
;// CONCATENATED MODULE: ./dist/browser/Options/Classes/FontTextMask.js
|
|
161
|
-
class FontTextMask {
|
|
162
|
-
constructor() {
|
|
163
|
-
this.family = "sans-serif";
|
|
164
|
-
this.size = 100;
|
|
165
|
-
}
|
|
166
|
-
load(data) {
|
|
167
|
-
if (!data) {
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
if (data.family !== undefined) {
|
|
171
|
-
this.family = data.family;
|
|
172
|
-
}
|
|
173
|
-
if (data.size !== undefined) {
|
|
174
|
-
this.size = data.size;
|
|
175
|
-
}
|
|
176
|
-
if (data.style !== undefined) {
|
|
177
|
-
this.style = data.style;
|
|
178
|
-
}
|
|
179
|
-
if (data.variant !== undefined) {
|
|
180
|
-
this.variant = data.variant;
|
|
181
|
-
}
|
|
182
|
-
if (data.weight !== undefined) {
|
|
183
|
-
this.weight = data.weight;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
;// CONCATENATED MODULE: ./dist/browser/Options/Classes/TextMaskLine.js
|
|
188
|
-
class TextMaskLine {
|
|
189
|
-
constructor() {
|
|
190
|
-
this.separator = "\n";
|
|
191
|
-
this.spacing = 10;
|
|
192
|
-
}
|
|
193
|
-
load(data) {
|
|
194
|
-
if (!data) {
|
|
195
|
-
return;
|
|
196
|
-
}
|
|
197
|
-
if (data.separator !== undefined) {
|
|
198
|
-
this.separator = data.separator;
|
|
199
|
-
}
|
|
200
|
-
if (data.spacing !== undefined) {
|
|
201
|
-
this.spacing = data.spacing;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
;// CONCATENATED MODULE: ./dist/browser/Options/Classes/TextMask.js
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
class TextMask {
|
|
209
|
-
constructor() {
|
|
210
|
-
this.color = "#000000";
|
|
211
|
-
this.font = new FontTextMask();
|
|
212
|
-
this.lines = new TextMaskLine();
|
|
213
|
-
this.text = "";
|
|
214
|
-
}
|
|
215
|
-
load(data) {
|
|
216
|
-
if (!data) {
|
|
217
|
-
return;
|
|
218
|
-
}
|
|
219
|
-
if (data.color !== undefined) {
|
|
220
|
-
this.color = data.color;
|
|
221
|
-
}
|
|
222
|
-
this.font.load(data.font);
|
|
223
|
-
this.lines.load(data.lines);
|
|
224
|
-
if (data.text !== undefined) {
|
|
225
|
-
this.text = data.text;
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
;// CONCATENATED MODULE: ./dist/browser/Options/Classes/CanvasMask.js
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
class CanvasMask {
|
|
235
|
-
constructor() {
|
|
236
|
-
this.enable = false;
|
|
237
|
-
this.override = new CanvasMaskOverride();
|
|
238
|
-
this.pixels = new CanvasMaskPixels();
|
|
239
|
-
this.position = {
|
|
240
|
-
x: 50,
|
|
241
|
-
y: 50
|
|
242
|
-
};
|
|
243
|
-
this.scale = 1;
|
|
244
|
-
}
|
|
245
|
-
load(data) {
|
|
246
|
-
if (!data) {
|
|
247
|
-
return;
|
|
248
|
-
}
|
|
249
|
-
if (data.element !== undefined && data.element instanceof HTMLCanvasElement) {
|
|
250
|
-
this.element = data.element;
|
|
251
|
-
}
|
|
252
|
-
if (data.enable !== undefined) {
|
|
253
|
-
this.enable = data.enable;
|
|
254
|
-
}
|
|
255
|
-
if (data.image) {
|
|
256
|
-
if (!this.image) {
|
|
257
|
-
this.image = new ImageMask();
|
|
258
|
-
}
|
|
259
|
-
this.image.load(data.image);
|
|
260
|
-
}
|
|
261
|
-
this.pixels.load(data.pixels);
|
|
262
|
-
if (data.position) {
|
|
263
|
-
this.position = {
|
|
264
|
-
x: data.position.x ?? this.position.x,
|
|
265
|
-
y: data.position.y ?? this.position.y
|
|
266
|
-
};
|
|
267
|
-
}
|
|
268
|
-
this.override.load(data.override);
|
|
269
|
-
if (data.scale !== undefined) {
|
|
270
|
-
this.scale = data.scale;
|
|
271
|
-
}
|
|
272
|
-
if (data.selector !== undefined) {
|
|
273
|
-
this.selector = data.selector;
|
|
274
|
-
}
|
|
275
|
-
if (data.text) {
|
|
276
|
-
if (!this.text) {
|
|
277
|
-
this.text = new TextMask();
|
|
278
|
-
}
|
|
279
|
-
this.text.load(data.text);
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
;// CONCATENATED MODULE: ./dist/browser/utils.js
|
|
284
|
-
|
|
285
|
-
const half = 0.5,
|
|
286
|
-
origin = {
|
|
287
|
-
x: 0,
|
|
288
|
-
y: 0
|
|
289
|
-
},
|
|
290
|
-
defaultWidth = 0;
|
|
291
|
-
function addParticlesFromCanvasPixels(container, data, position, scale, override, filter) {
|
|
292
|
-
const {
|
|
293
|
-
height,
|
|
294
|
-
width
|
|
295
|
-
} = data,
|
|
296
|
-
numPixels = height * width,
|
|
297
|
-
indexArray = shuffle(range(numPixels)),
|
|
298
|
-
maxParticles = Math.min(numPixels, container.actualOptions.particles.number.value),
|
|
299
|
-
canvasSize = container.canvas.size;
|
|
300
|
-
let selectedPixels = 0;
|
|
301
|
-
const positionOffset = {
|
|
302
|
-
x: canvasSize.width * position.x / engine_root_window_.percentDenominator - width * scale * half,
|
|
303
|
-
y: canvasSize.height * position.y / engine_root_window_.percentDenominator - height * scale * half
|
|
304
|
-
};
|
|
305
|
-
while (selectedPixels < maxParticles && indexArray.length) {
|
|
306
|
-
const defaultIndex = 0,
|
|
307
|
-
nextIndex = indexArray.pop() ?? defaultIndex,
|
|
308
|
-
pixelPos = {
|
|
309
|
-
x: nextIndex % width,
|
|
310
|
-
y: Math.floor(nextIndex / width)
|
|
311
|
-
},
|
|
312
|
-
pixel = data.pixels[pixelPos.y][pixelPos.x],
|
|
313
|
-
shouldCreateParticle = filter(pixel);
|
|
314
|
-
if (!shouldCreateParticle) {
|
|
315
|
-
continue;
|
|
316
|
-
}
|
|
317
|
-
const pos = {
|
|
318
|
-
x: pixelPos.x * scale + positionOffset.x,
|
|
319
|
-
y: pixelPos.y * scale + positionOffset.y
|
|
320
|
-
},
|
|
321
|
-
pOptions = {};
|
|
322
|
-
if (override.color) {
|
|
323
|
-
pOptions.color = {
|
|
324
|
-
value: pixel
|
|
325
|
-
};
|
|
326
|
-
}
|
|
327
|
-
if (override.opacity) {
|
|
328
|
-
pOptions.opacity = {
|
|
329
|
-
value: pixel.a
|
|
330
|
-
};
|
|
331
|
-
}
|
|
332
|
-
container.particles.addParticle(pos, pOptions);
|
|
333
|
-
selectedPixels++;
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
function getCanvasImageData(ctx, size, offset, clear = true) {
|
|
337
|
-
const imageData = ctx.getImageData(origin.x, origin.y, size.width, size.height).data;
|
|
338
|
-
if (clear) {
|
|
339
|
-
ctx.clearRect(origin.x, origin.y, size.width, size.height);
|
|
340
|
-
}
|
|
341
|
-
const pixels = [];
|
|
342
|
-
for (let i = 0; i < imageData.length; i += offset) {
|
|
343
|
-
const idx = i / offset,
|
|
344
|
-
pos = {
|
|
345
|
-
x: idx % size.width,
|
|
346
|
-
y: Math.floor(idx / size.width)
|
|
347
|
-
};
|
|
348
|
-
if (!pixels[pos.y]) {
|
|
349
|
-
pixels[pos.y] = [];
|
|
350
|
-
}
|
|
351
|
-
const indexesOffset = {
|
|
352
|
-
r: 0,
|
|
353
|
-
g: 1,
|
|
354
|
-
b: 2,
|
|
355
|
-
a: 3
|
|
356
|
-
},
|
|
357
|
-
alphaFactor = 255;
|
|
358
|
-
pixels[pos.y][pos.x] = {
|
|
359
|
-
r: imageData[i + indexesOffset.r],
|
|
360
|
-
g: imageData[i + indexesOffset.g],
|
|
361
|
-
b: imageData[i + indexesOffset.b],
|
|
362
|
-
a: imageData[i + indexesOffset.a] / alphaFactor
|
|
363
|
-
};
|
|
364
|
-
}
|
|
365
|
-
return {
|
|
366
|
-
pixels,
|
|
367
|
-
width: Math.min(...pixels.map(row => row.length)),
|
|
368
|
-
height: pixels.length
|
|
369
|
-
};
|
|
370
|
-
}
|
|
371
|
-
function getImageData(src, offset) {
|
|
372
|
-
const image = new Image();
|
|
373
|
-
image.crossOrigin = "Anonymous";
|
|
374
|
-
const p = new Promise((resolve, reject) => {
|
|
375
|
-
image.onerror = reject;
|
|
376
|
-
image.onload = () => {
|
|
377
|
-
const canvas = document.createElement("canvas");
|
|
378
|
-
canvas.width = image.width;
|
|
379
|
-
canvas.height = image.height;
|
|
380
|
-
const context = canvas.getContext("2d");
|
|
381
|
-
if (!context) {
|
|
382
|
-
return reject(new Error(`${engine_root_window_.errorPrefix} Could not get canvas context`));
|
|
383
|
-
}
|
|
384
|
-
context.drawImage(image, origin.x, origin.y, image.width, image.height, origin.x, origin.y, canvas.width, canvas.height);
|
|
385
|
-
resolve(getCanvasImageData(context, canvas, offset));
|
|
386
|
-
};
|
|
387
|
-
});
|
|
388
|
-
image.src = src;
|
|
389
|
-
return p;
|
|
390
|
-
}
|
|
391
|
-
function getTextData(textOptions, offset) {
|
|
392
|
-
const canvas = document.createElement("canvas"),
|
|
393
|
-
context = canvas.getContext("2d"),
|
|
394
|
-
{
|
|
395
|
-
font,
|
|
396
|
-
text,
|
|
397
|
-
lines: linesOptions,
|
|
398
|
-
color
|
|
399
|
-
} = textOptions;
|
|
400
|
-
if (!text || !context) {
|
|
401
|
-
return;
|
|
402
|
-
}
|
|
403
|
-
const lines = text.split(linesOptions.separator),
|
|
404
|
-
fontSize = (0,engine_root_window_.isNumber)(font.size) ? `${font.size}px` : font.size,
|
|
405
|
-
linesData = [];
|
|
406
|
-
let maxWidth = 0,
|
|
407
|
-
totalHeight = 0;
|
|
408
|
-
for (const line of lines) {
|
|
409
|
-
context.font = `${font.style ?? ""} ${font.variant ?? ""} ${font.weight ?? ""} ${fontSize} ${font.family}`;
|
|
410
|
-
const measure = context.measureText(line),
|
|
411
|
-
lineData = {
|
|
412
|
-
measure,
|
|
413
|
-
text: line,
|
|
414
|
-
height: measure.actualBoundingBoxAscent + measure.actualBoundingBoxDescent,
|
|
415
|
-
width: measure.width
|
|
416
|
-
};
|
|
417
|
-
maxWidth = Math.max(maxWidth || defaultWidth, lineData.width);
|
|
418
|
-
totalHeight += lineData.height + linesOptions.spacing;
|
|
419
|
-
linesData.push(lineData);
|
|
420
|
-
}
|
|
421
|
-
canvas.width = maxWidth;
|
|
422
|
-
canvas.height = totalHeight;
|
|
423
|
-
let currentHeight = 0;
|
|
424
|
-
for (const line of linesData) {
|
|
425
|
-
context.font = `${font.style ?? ""} ${font.variant ?? ""} ${font.weight ?? ""} ${fontSize} ${font.family}`;
|
|
426
|
-
context.fillStyle = color;
|
|
427
|
-
context.fillText(line.text, origin.x, currentHeight + line.measure.actualBoundingBoxAscent);
|
|
428
|
-
currentHeight += line.height + linesOptions.spacing;
|
|
429
|
-
}
|
|
430
|
-
return getCanvasImageData(context, canvas, offset);
|
|
431
|
-
}
|
|
432
|
-
function shuffle(array) {
|
|
433
|
-
const lengthOffset = 1,
|
|
434
|
-
minIndex = 0;
|
|
435
|
-
for (let currentIndex = array.length - lengthOffset; currentIndex >= minIndex; currentIndex--) {
|
|
436
|
-
const randomIndex = Math.floor((0,engine_root_window_.getRandom)() * currentIndex);
|
|
437
|
-
[array[currentIndex], array[randomIndex]] = [array[randomIndex], array[currentIndex]];
|
|
438
|
-
}
|
|
439
|
-
return array;
|
|
440
|
-
}
|
|
441
|
-
const range = n => [...Array(n).keys()];
|
|
442
|
-
;// CONCATENATED MODULE: ./dist/browser/CanvasMaskInstance.js
|
|
443
|
-
|
|
444
|
-
class CanvasMaskInstance {
|
|
445
|
-
constructor(container) {
|
|
446
|
-
this._container = container;
|
|
447
|
-
}
|
|
448
|
-
async init() {
|
|
449
|
-
const container = this._container,
|
|
450
|
-
options = container.actualOptions.canvasMask;
|
|
451
|
-
if (!options?.enable) {
|
|
452
|
-
return;
|
|
453
|
-
}
|
|
454
|
-
let pixelData = {
|
|
455
|
-
pixels: [],
|
|
456
|
-
height: 0,
|
|
457
|
-
width: 0
|
|
458
|
-
};
|
|
459
|
-
const offset = options.pixels.offset;
|
|
460
|
-
if (options.image) {
|
|
461
|
-
const url = options.image.src;
|
|
462
|
-
if (!url) {
|
|
463
|
-
return;
|
|
464
|
-
}
|
|
465
|
-
pixelData = await getImageData(url, offset);
|
|
466
|
-
} else if (options.text) {
|
|
467
|
-
const textOptions = options.text;
|
|
468
|
-
const data = getTextData(textOptions, offset);
|
|
469
|
-
if (!data) {
|
|
470
|
-
return;
|
|
471
|
-
}
|
|
472
|
-
pixelData = data;
|
|
473
|
-
} else if (options.element ?? options.selector) {
|
|
474
|
-
const canvas = options.element ?? (options.selector && document.querySelector(options.selector));
|
|
475
|
-
if (!canvas) {
|
|
476
|
-
return;
|
|
477
|
-
}
|
|
478
|
-
const context = canvas.getContext("2d");
|
|
479
|
-
if (!context) {
|
|
480
|
-
return;
|
|
481
|
-
}
|
|
482
|
-
pixelData = getCanvasImageData(context, canvas, offset);
|
|
483
|
-
}
|
|
484
|
-
addParticlesFromCanvasPixels(container, pixelData, options.position, options.scale, options.override, options.pixels.filter);
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
;// CONCATENATED MODULE: ./dist/browser/index.js
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
class CanvasMaskPlugin {
|
|
491
|
-
constructor() {
|
|
492
|
-
this.id = "canvasMask";
|
|
493
|
-
}
|
|
494
|
-
getPlugin(container) {
|
|
495
|
-
return new CanvasMaskInstance(container);
|
|
496
|
-
}
|
|
497
|
-
loadOptions(options, source) {
|
|
498
|
-
if (!this.needsPlugin(options) && !this.needsPlugin(source)) {
|
|
499
|
-
return;
|
|
500
|
-
}
|
|
501
|
-
let canvasMaskOptions = options.canvasMask;
|
|
502
|
-
if (canvasMaskOptions?.load === undefined) {
|
|
503
|
-
options.canvasMask = canvasMaskOptions = new CanvasMask();
|
|
504
|
-
}
|
|
505
|
-
canvasMaskOptions.load(source?.canvasMask);
|
|
506
|
-
}
|
|
507
|
-
needsPlugin(options) {
|
|
508
|
-
return options?.canvasMask?.enable ?? false;
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
async function loadCanvasMaskPlugin(engine, refresh = true) {
|
|
512
|
-
await engine.addPlugin(new CanvasMaskPlugin(), refresh);
|
|
513
|
-
}
|
|
514
|
-
})();
|
|
515
|
-
|
|
317
|
+
/******/
|
|
318
|
+
/******/ // startup
|
|
319
|
+
/******/ // Load entry module and return exports
|
|
320
|
+
/******/ // This entry module can't be inlined because the eval devtool is used.
|
|
321
|
+
/******/ var __webpack_exports__ = __webpack_require__("./dist/browser/index.js");
|
|
322
|
+
/******/
|
|
516
323
|
/******/ return __webpack_exports__;
|
|
517
324
|
/******/ })()
|
|
518
325
|
;
|