@tsparticles/shape-image 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/21.min.js +2 -0
- package/21.min.js.LICENSE.txt +1 -0
- package/618.min.js +2 -0
- package/618.min.js.LICENSE.txt +1 -0
- package/623.min.js +2 -0
- package/623.min.js.LICENSE.txt +1 -0
- package/browser/GifUtils/ByteStream.js +2 -1
- package/browser/GifUtils/Utils.js +96 -0
- package/browser/ImageDrawer.js +42 -113
- package/browser/ImagePreloader.js +2 -1
- package/browser/Utils.js +1 -20
- package/browser/index.js +3 -3
- package/cjs/GifUtils/ByteStream.js +2 -1
- package/cjs/GifUtils/Utils.js +122 -1
- package/cjs/ImageDrawer.js +64 -112
- package/cjs/ImagePreloader.js +2 -1
- package/cjs/Utils.js +2 -22
- package/cjs/index.js +28 -5
- package/dist_browser_GifUtils_Utils_js.js +50 -0
- package/dist_browser_ImageDrawer_js.js +30 -0
- package/dist_browser_ImagePreloader_js.js +40 -0
- package/esm/GifUtils/ByteStream.js +2 -1
- package/esm/GifUtils/Utils.js +96 -0
- package/esm/ImageDrawer.js +42 -113
- package/esm/ImagePreloader.js +2 -1
- package/esm/Utils.js +1 -20
- package/esm/index.js +3 -3
- package/package.json +2 -2
- package/report.html +3 -3
- package/tsparticles.shape.image.js +251 -910
- package/tsparticles.shape.image.min.js +1 -1
- package/tsparticles.shape.image.min.js.LICENSE.txt +1 -1
- package/types/GifUtils/Utils.d.ts +4 -0
- package/types/ImageDrawer.d.ts +4 -4
- package/types/ImagePreloader.d.ts +1 -1
- package/types/Utils.d.ts +0 -1
- package/umd/GifUtils/ByteStream.js +2 -1
- package/umd/GifUtils/Utils.js +123 -1
- package/umd/ImageDrawer.js +66 -113
- package/umd/ImagePreloader.js +2 -1
- package/umd/Utils.js +3 -23
- package/umd/index.js +30 -6
|
@@ -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,38 @@
|
|
|
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/Utils.js":
|
|
32
|
+
/*!*******************************!*\
|
|
33
|
+
!*** ./dist/browser/Utils.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 */ downloadSvgImage: () => (/* binding */ downloadSvgImage),\n/* harmony export */ loadImage: () => (/* binding */ loadImage),\n/* harmony export */ replaceImageColor: () => (/* binding */ replaceImageColor)\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 stringStart = 0,\n defaultOpacity = 1;\nconst currentColorRegex = /(#(?:[0-9a-f]{2}){2,4}|(#[0-9a-f]{3})|(rgb|hsl)a?\\((-?\\d+%?[,\\s]+){2,3}\\s*[\\d.]+%?\\))|currentcolor/gi;\nfunction replaceColorSvg(imageShape, color, opacity) {\n const {\n svgData\n } = imageShape;\n if (!svgData) {\n return \"\";\n }\n const colorStyle = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getStyleFromHsl)(color, opacity);\n if (svgData.includes(\"fill\")) {\n return svgData.replace(currentColorRegex, () => colorStyle);\n }\n const preFillIndex = svgData.indexOf(\">\");\n return `${svgData.substring(stringStart, preFillIndex)} fill=\"${colorStyle}\"${svgData.substring(preFillIndex)}`;\n}\nasync function loadImage(image) {\n return new Promise(resolve => {\n image.loading = true;\n const img = new Image();\n image.element = img;\n img.addEventListener(\"load\", () => {\n image.loading = false;\n resolve();\n });\n img.addEventListener(\"error\", () => {\n image.element = undefined;\n image.error = true;\n image.loading = false;\n (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getLogger)().error(`${_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.errorPrefix} loading image: ${image.source}`);\n resolve();\n });\n img.src = image.source;\n });\n}\nasync function downloadSvgImage(image) {\n if (image.type !== \"svg\") {\n await loadImage(image);\n return;\n }\n image.loading = true;\n const response = await fetch(image.source);\n if (!response.ok) {\n (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getLogger)().error(`${_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.errorPrefix} Image not found`);\n image.error = true;\n } else {\n image.svgData = await response.text();\n }\n image.loading = false;\n}\nfunction replaceImageColor(image, imageData, color, particle) {\n const svgColoredData = replaceColorSvg(image, color, particle.opacity?.value ?? defaultOpacity),\n imageRes = {\n color,\n gif: imageData.gif,\n data: {\n ...image,\n svgData: svgColoredData\n },\n loaded: false,\n ratio: imageData.width / imageData.height,\n replaceColor: imageData.replaceColor,\n source: imageData.src\n };\n return new Promise(resolve => {\n const svg = new Blob([svgColoredData], {\n type: \"image/svg+xml\"\n }),\n domUrl = URL || window.URL || window.webkitURL || window,\n url = domUrl.createObjectURL(svg),\n img = new Image();\n img.addEventListener(\"load\", () => {\n imageRes.loaded = true;\n imageRes.element = img;\n resolve(imageRes);\n domUrl.revokeObjectURL(url);\n });\n const errorHandler = async () => {\n domUrl.revokeObjectURL(url);\n const img2 = {\n ...image,\n error: false,\n loading: true\n };\n await loadImage(img2);\n imageRes.loaded = true;\n imageRes.element = img2.element;\n resolve(imageRes);\n };\n img.addEventListener(\"error\", () => void errorHandler());\n img.src = url;\n });\n}\n\n//# sourceURL=webpack://@tsparticles/shape-image/./dist/browser/Utils.js?");
|
|
38
|
+
|
|
39
|
+
/***/ }),
|
|
40
|
+
|
|
41
|
+
/***/ "./dist/browser/index.js":
|
|
42
|
+
/*!*******************************!*\
|
|
43
|
+
!*** ./dist/browser/index.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 */ loadImageShape: () => (/* binding */ loadImageShape)\n/* harmony export */ });\n/* harmony import */ var _Utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Utils.js */ \"./dist/browser/Utils.js\");\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\n\nconst extLength = 3;\nfunction addLoadImageToEngine(engine) {\n if (engine.loadImage) {\n return;\n }\n engine.loadImage = async data => {\n if (!data.name && !data.src) {\n throw new Error(`${_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.errorPrefix} no image source provided`);\n }\n if (!engine.images) {\n engine.images = [];\n }\n if (engine.images.find(t => t.name === data.name || t.source === data.src)) {\n return;\n }\n try {\n const image = {\n gif: data.gif ?? false,\n name: data.name ?? data.src,\n source: data.src,\n type: data.src.substring(data.src.length - extLength),\n error: false,\n loading: true,\n replaceColor: data.replaceColor,\n ratio: data.width && data.height ? data.width / data.height : undefined\n };\n engine.images.push(image);\n let imageFunc;\n if (data.gif) {\n const {\n loadGifImage\n } = await __webpack_require__.e(/*! import() */ \"dist_browser_GifUtils_Utils_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./GifUtils/Utils.js */ \"./dist/browser/GifUtils/Utils.js\"));\n imageFunc = loadGifImage;\n } else {\n imageFunc = data.replaceColor ? _Utils_js__WEBPACK_IMPORTED_MODULE_1__.downloadSvgImage : _Utils_js__WEBPACK_IMPORTED_MODULE_1__.loadImage;\n }\n await imageFunc(image);\n } catch {\n throw new Error(`${_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.errorPrefix} ${data.name ?? data.src} not found`);\n }\n };\n}\nasync function loadImageShape(engine, refresh = true) {\n addLoadImageToEngine(engine);\n const {\n ImagePreloaderPlugin\n } = await __webpack_require__.e(/*! import() */ \"dist_browser_ImagePreloader_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./ImagePreloader.js */ \"./dist/browser/ImagePreloader.js\")),\n {\n ImageDrawer\n } = await __webpack_require__.e(/*! import() */ \"dist_browser_ImageDrawer_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./ImageDrawer.js */ \"./dist/browser/ImageDrawer.js\"));\n const preloader = new ImagePreloaderPlugin(engine);\n await engine.addPlugin(preloader, refresh);\n await engine.addShape([\"image\", \"images\"], new ImageDrawer(engine), refresh);\n}\n\n//# sourceURL=webpack://@tsparticles/shape-image/./dist/browser/index.js?");
|
|
48
|
+
|
|
49
|
+
/***/ }),
|
|
50
|
+
|
|
51
|
+
/***/ "@tsparticles/engine":
|
|
52
|
+
/*!*********************************************************************************************************************************!*\
|
|
53
|
+
!*** external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"} ***!
|
|
54
|
+
\*********************************************************************************************************************************/
|
|
24
55
|
/***/ ((module) => {
|
|
25
56
|
|
|
26
|
-
module.exports =
|
|
57
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
|
|
27
58
|
|
|
28
59
|
/***/ })
|
|
29
60
|
|
|
@@ -53,7 +84,22 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__533__;
|
|
|
53
84
|
/******/ return module.exports;
|
|
54
85
|
/******/ }
|
|
55
86
|
/******/
|
|
87
|
+
/******/ // expose the modules object (__webpack_modules__)
|
|
88
|
+
/******/ __webpack_require__.m = __webpack_modules__;
|
|
89
|
+
/******/
|
|
56
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
|
+
/******/
|
|
57
103
|
/******/ /* webpack/runtime/define property getters */
|
|
58
104
|
/******/ (() => {
|
|
59
105
|
/******/ // define getter functions for harmony exports
|
|
@@ -66,11 +112,91 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__533__;
|
|
|
66
112
|
/******/ };
|
|
67
113
|
/******/ })();
|
|
68
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
|
+
/******/
|
|
69
149
|
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
70
150
|
/******/ (() => {
|
|
71
151
|
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
72
152
|
/******/ })();
|
|
73
153
|
/******/
|
|
154
|
+
/******/ /* webpack/runtime/load script */
|
|
155
|
+
/******/ (() => {
|
|
156
|
+
/******/ var inProgress = {};
|
|
157
|
+
/******/ var dataWebpackPrefix = "@tsparticles/shape-image:";
|
|
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
|
+
/******/
|
|
74
200
|
/******/ /* webpack/runtime/make namespace object */
|
|
75
201
|
/******/ (() => {
|
|
76
202
|
/******/ // define __esModule on exports
|
|
@@ -82,913 +208,128 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__533__;
|
|
|
82
208
|
/******/ };
|
|
83
209
|
/******/ })();
|
|
84
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.shape.image": 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_shape_image"] = this["webpackChunk_tsparticles_shape_image"] || [];
|
|
322
|
+
/******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));
|
|
323
|
+
/******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));
|
|
324
|
+
/******/ })();
|
|
325
|
+
/******/
|
|
85
326
|
/************************************************************************/
|
|
86
|
-
|
|
87
|
-
//
|
|
88
|
-
|
|
89
|
-
//
|
|
90
|
-
__webpack_require__.
|
|
91
|
-
|
|
92
|
-
// EXPORTS
|
|
93
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
94
|
-
loadImageShape: () => (/* binding */ loadImageShape)
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
// EXTERNAL MODULE: external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"}
|
|
98
|
-
var engine_root_window_ = __webpack_require__(533);
|
|
99
|
-
;// CONCATENATED MODULE: ./dist/browser/GifUtils/Constants.js
|
|
100
|
-
const InterlaceOffsets = [0, 4, 2, 1];
|
|
101
|
-
const InterlaceSteps = [8, 8, 4, 2];
|
|
102
|
-
;// CONCATENATED MODULE: ./dist/browser/GifUtils/ByteStream.js
|
|
103
|
-
class ByteStream {
|
|
104
|
-
constructor(bytes) {
|
|
105
|
-
this.pos = 0;
|
|
106
|
-
this.data = new Uint8ClampedArray(bytes);
|
|
107
|
-
}
|
|
108
|
-
getString(count) {
|
|
109
|
-
const slice = this.data.slice(this.pos, this.pos + count);
|
|
110
|
-
this.pos += slice.length;
|
|
111
|
-
return slice.reduce((acc, curr) => acc + String.fromCharCode(curr), "");
|
|
112
|
-
}
|
|
113
|
-
nextByte() {
|
|
114
|
-
return this.data[this.pos++];
|
|
115
|
-
}
|
|
116
|
-
nextTwoBytes() {
|
|
117
|
-
const increment = 2,
|
|
118
|
-
previous = 1,
|
|
119
|
-
shift = 8;
|
|
120
|
-
this.pos += increment;
|
|
121
|
-
return this.data[this.pos - increment] + (this.data[this.pos - previous] << shift);
|
|
122
|
-
}
|
|
123
|
-
readSubBlocks() {
|
|
124
|
-
let blockString = "",
|
|
125
|
-
size = 0;
|
|
126
|
-
const minCount = 0,
|
|
127
|
-
emptySize = 0;
|
|
128
|
-
do {
|
|
129
|
-
size = this.data[this.pos++];
|
|
130
|
-
for (let count = size; --count >= minCount; blockString += String.fromCharCode(this.data[this.pos++])) {}
|
|
131
|
-
} while (size !== emptySize);
|
|
132
|
-
return blockString;
|
|
133
|
-
}
|
|
134
|
-
readSubBlocksBin() {
|
|
135
|
-
let size = 0,
|
|
136
|
-
len = 0;
|
|
137
|
-
const emptySize = 0,
|
|
138
|
-
increment = 1;
|
|
139
|
-
for (let offset = 0; size !== emptySize; offset += size + increment, size = this.data[this.pos + offset]) {
|
|
140
|
-
len += size;
|
|
141
|
-
}
|
|
142
|
-
const blockData = new Uint8Array(len);
|
|
143
|
-
for (let i = 0; size !== emptySize; size = this.data[this.pos++]) {
|
|
144
|
-
for (let count = size; --count >= emptySize; blockData[i++] = this.data[this.pos++]) {}
|
|
145
|
-
}
|
|
146
|
-
return blockData;
|
|
147
|
-
}
|
|
148
|
-
skipSubBlocks() {
|
|
149
|
-
for (const increment = 1, noData = 0; this.data[this.pos] !== noData; this.pos += this.data[this.pos] + increment) {}
|
|
150
|
-
this.pos++;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
;// CONCATENATED MODULE: ./dist/browser/GifUtils/Utils.js
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
function parseColorTable(byteStream, count) {
|
|
157
|
-
const colors = [];
|
|
158
|
-
for (let i = 0; i < count; i++) {
|
|
159
|
-
colors.push({
|
|
160
|
-
r: byteStream.data[byteStream.pos],
|
|
161
|
-
g: byteStream.data[byteStream.pos + 1],
|
|
162
|
-
b: byteStream.data[byteStream.pos + 2]
|
|
163
|
-
});
|
|
164
|
-
byteStream.pos += 3;
|
|
165
|
-
}
|
|
166
|
-
return colors;
|
|
167
|
-
}
|
|
168
|
-
function parseExtensionBlock(byteStream, gif, getFrameIndex, getTransparencyIndex) {
|
|
169
|
-
switch (byteStream.nextByte()) {
|
|
170
|
-
case 249:
|
|
171
|
-
{
|
|
172
|
-
const frame = gif.frames[getFrameIndex(false)];
|
|
173
|
-
byteStream.pos++;
|
|
174
|
-
const packedByte = byteStream.nextByte();
|
|
175
|
-
frame.GCreserved = (packedByte & 0xe0) >>> 5;
|
|
176
|
-
frame.disposalMethod = (packedByte & 0x1c) >>> 2;
|
|
177
|
-
frame.userInputDelayFlag = (packedByte & 2) === 2;
|
|
178
|
-
const transparencyFlag = (packedByte & 1) === 1;
|
|
179
|
-
frame.delayTime = byteStream.nextTwoBytes() * 0xa;
|
|
180
|
-
const transparencyIndex = byteStream.nextByte();
|
|
181
|
-
if (transparencyFlag) {
|
|
182
|
-
getTransparencyIndex(transparencyIndex);
|
|
183
|
-
}
|
|
184
|
-
byteStream.pos++;
|
|
185
|
-
break;
|
|
186
|
-
}
|
|
187
|
-
case 255:
|
|
188
|
-
{
|
|
189
|
-
byteStream.pos++;
|
|
190
|
-
const applicationExtension = {
|
|
191
|
-
identifier: byteStream.getString(8),
|
|
192
|
-
authenticationCode: byteStream.getString(3),
|
|
193
|
-
data: byteStream.readSubBlocksBin()
|
|
194
|
-
};
|
|
195
|
-
gif.applicationExtensions.push(applicationExtension);
|
|
196
|
-
break;
|
|
197
|
-
}
|
|
198
|
-
case 254:
|
|
199
|
-
{
|
|
200
|
-
gif.comments.push([getFrameIndex(false), byteStream.readSubBlocks()]);
|
|
201
|
-
break;
|
|
202
|
-
}
|
|
203
|
-
case 1:
|
|
204
|
-
{
|
|
205
|
-
if (gif.globalColorTable.length === 0) {
|
|
206
|
-
throw new EvalError("plain text extension without global color table");
|
|
207
|
-
}
|
|
208
|
-
byteStream.pos++;
|
|
209
|
-
gif.frames[getFrameIndex(false)].plainTextData = {
|
|
210
|
-
left: byteStream.nextTwoBytes(),
|
|
211
|
-
top: byteStream.nextTwoBytes(),
|
|
212
|
-
width: byteStream.nextTwoBytes(),
|
|
213
|
-
height: byteStream.nextTwoBytes(),
|
|
214
|
-
charSize: {
|
|
215
|
-
width: byteStream.nextTwoBytes(),
|
|
216
|
-
height: byteStream.nextTwoBytes()
|
|
217
|
-
},
|
|
218
|
-
foregroundColor: byteStream.nextByte(),
|
|
219
|
-
backgroundColor: byteStream.nextByte(),
|
|
220
|
-
text: byteStream.readSubBlocks()
|
|
221
|
-
};
|
|
222
|
-
break;
|
|
223
|
-
}
|
|
224
|
-
default:
|
|
225
|
-
byteStream.skipSubBlocks();
|
|
226
|
-
break;
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
async function parseImageBlock(byteStream, gif, avgAlpha, getFrameIndex, getTransparencyIndex, progressCallback) {
|
|
230
|
-
const frame = gif.frames[getFrameIndex(true)];
|
|
231
|
-
frame.left = byteStream.nextTwoBytes();
|
|
232
|
-
frame.top = byteStream.nextTwoBytes();
|
|
233
|
-
frame.width = byteStream.nextTwoBytes();
|
|
234
|
-
frame.height = byteStream.nextTwoBytes();
|
|
235
|
-
const packedByte = byteStream.nextByte(),
|
|
236
|
-
localColorTableFlag = (packedByte & 0x80) === 0x80,
|
|
237
|
-
interlacedFlag = (packedByte & 0x40) === 0x40;
|
|
238
|
-
frame.sortFlag = (packedByte & 0x20) === 0x20;
|
|
239
|
-
frame.reserved = (packedByte & 0x18) >>> 3;
|
|
240
|
-
const localColorCount = 1 << (packedByte & 7) + 1;
|
|
241
|
-
if (localColorTableFlag) {
|
|
242
|
-
frame.localColorTable = parseColorTable(byteStream, localColorCount);
|
|
243
|
-
}
|
|
244
|
-
const getColor = index => {
|
|
245
|
-
const {
|
|
246
|
-
r,
|
|
247
|
-
g,
|
|
248
|
-
b
|
|
249
|
-
} = (localColorTableFlag ? frame.localColorTable : gif.globalColorTable)[index];
|
|
250
|
-
if (index !== getTransparencyIndex(null)) {
|
|
251
|
-
return {
|
|
252
|
-
r,
|
|
253
|
-
g,
|
|
254
|
-
b,
|
|
255
|
-
a: 255
|
|
256
|
-
};
|
|
257
|
-
}
|
|
258
|
-
return {
|
|
259
|
-
r,
|
|
260
|
-
g,
|
|
261
|
-
b,
|
|
262
|
-
a: avgAlpha ? ~~((r + g + b) / 3) : 0
|
|
263
|
-
};
|
|
264
|
-
};
|
|
265
|
-
const image = (() => {
|
|
266
|
-
try {
|
|
267
|
-
return new ImageData(frame.width, frame.height, {
|
|
268
|
-
colorSpace: "srgb"
|
|
269
|
-
});
|
|
270
|
-
} catch (error) {
|
|
271
|
-
if (error instanceof DOMException && error.name === "IndexSizeError") {
|
|
272
|
-
return null;
|
|
273
|
-
}
|
|
274
|
-
throw error;
|
|
275
|
-
}
|
|
276
|
-
})();
|
|
277
|
-
if (image == null) {
|
|
278
|
-
throw new EvalError("GIF frame size is to large");
|
|
279
|
-
}
|
|
280
|
-
const minCodeSize = byteStream.nextByte(),
|
|
281
|
-
imageData = byteStream.readSubBlocksBin(),
|
|
282
|
-
clearCode = 1 << minCodeSize;
|
|
283
|
-
const readBits = (pos, len) => {
|
|
284
|
-
const bytePos = pos >>> 3,
|
|
285
|
-
bitPos = pos & 7;
|
|
286
|
-
return (imageData[bytePos] + (imageData[bytePos + 1] << 8) + (imageData[bytePos + 2] << 16) & (1 << len) - 1 << bitPos) >>> bitPos;
|
|
287
|
-
};
|
|
288
|
-
if (interlacedFlag) {
|
|
289
|
-
for (let code = 0, size = minCodeSize + 1, pos = 0, dic = [[0]], pass = 0; pass < 4; pass++) {
|
|
290
|
-
if (InterlaceOffsets[pass] < frame.height) {
|
|
291
|
-
let pixelPos = 0,
|
|
292
|
-
lineIndex = 0,
|
|
293
|
-
exit = false;
|
|
294
|
-
while (!exit) {
|
|
295
|
-
const last = code;
|
|
296
|
-
code = readBits(pos, size);
|
|
297
|
-
pos += size + 1;
|
|
298
|
-
if (code === clearCode) {
|
|
299
|
-
size = minCodeSize + 1;
|
|
300
|
-
dic.length = clearCode + 2;
|
|
301
|
-
for (let i = 0; i < dic.length; i++) {
|
|
302
|
-
dic[i] = i < clearCode ? [i] : [];
|
|
303
|
-
}
|
|
304
|
-
} else {
|
|
305
|
-
if (code >= dic.length) {
|
|
306
|
-
dic.push(dic[last].concat(dic[last][0]));
|
|
307
|
-
} else if (last !== clearCode) {
|
|
308
|
-
dic.push(dic[last].concat(dic[code][0]));
|
|
309
|
-
}
|
|
310
|
-
for (const item of dic[code]) {
|
|
311
|
-
const {
|
|
312
|
-
r,
|
|
313
|
-
g,
|
|
314
|
-
b,
|
|
315
|
-
a
|
|
316
|
-
} = getColor(item);
|
|
317
|
-
image.data.set([r, g, b, a], InterlaceOffsets[pass] * frame.width + InterlaceSteps[pass] * lineIndex + pixelPos % (frame.width * 4));
|
|
318
|
-
pixelPos += 4;
|
|
319
|
-
}
|
|
320
|
-
if (dic.length === 1 << size && size < 0xc) {
|
|
321
|
-
size++;
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
if (pixelPos === frame.width * 4 * (lineIndex + 1)) {
|
|
325
|
-
lineIndex++;
|
|
326
|
-
if (InterlaceOffsets[pass] + InterlaceSteps[pass] * lineIndex >= frame.height) {
|
|
327
|
-
exit = true;
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
progressCallback?.(byteStream.pos / (byteStream.data.length - 1), getFrameIndex(false) + 1, image, {
|
|
333
|
-
x: frame.left,
|
|
334
|
-
y: frame.top
|
|
335
|
-
}, {
|
|
336
|
-
width: gif.width,
|
|
337
|
-
height: gif.height
|
|
338
|
-
});
|
|
339
|
-
}
|
|
340
|
-
frame.image = image;
|
|
341
|
-
frame.bitmap = await createImageBitmap(image);
|
|
342
|
-
} else {
|
|
343
|
-
let code = 0,
|
|
344
|
-
size = minCodeSize + 1,
|
|
345
|
-
pos = 0,
|
|
346
|
-
pixelPos = -4,
|
|
347
|
-
exit = false;
|
|
348
|
-
const dic = [[0]];
|
|
349
|
-
while (!exit) {
|
|
350
|
-
const last = code;
|
|
351
|
-
code = readBits(pos, size);
|
|
352
|
-
pos += size;
|
|
353
|
-
if (code === clearCode) {
|
|
354
|
-
size = minCodeSize + 1;
|
|
355
|
-
dic.length = clearCode + 2;
|
|
356
|
-
for (let i = 0; i < dic.length; i++) {
|
|
357
|
-
dic[i] = i < clearCode ? [i] : [];
|
|
358
|
-
}
|
|
359
|
-
} else {
|
|
360
|
-
if (code === clearCode + 1) {
|
|
361
|
-
exit = true;
|
|
362
|
-
break;
|
|
363
|
-
}
|
|
364
|
-
if (code >= dic.length) {
|
|
365
|
-
dic.push(dic[last].concat(dic[last][0]));
|
|
366
|
-
} else if (last !== clearCode) {
|
|
367
|
-
dic.push(dic[last].concat(dic[code][0]));
|
|
368
|
-
}
|
|
369
|
-
for (const item of dic[code]) {
|
|
370
|
-
const {
|
|
371
|
-
r,
|
|
372
|
-
g,
|
|
373
|
-
b,
|
|
374
|
-
a
|
|
375
|
-
} = getColor(item);
|
|
376
|
-
image.data.set([r, g, b, a], pixelPos += 4);
|
|
377
|
-
}
|
|
378
|
-
if (dic.length >= 1 << size && size < 0xc) {
|
|
379
|
-
size++;
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
frame.image = image;
|
|
384
|
-
frame.bitmap = await createImageBitmap(image);
|
|
385
|
-
progressCallback?.((byteStream.pos + 1) / byteStream.data.length, getFrameIndex(false) + 1, frame.image, {
|
|
386
|
-
x: frame.left,
|
|
387
|
-
y: frame.top
|
|
388
|
-
}, {
|
|
389
|
-
width: gif.width,
|
|
390
|
-
height: gif.height
|
|
391
|
-
});
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
async function parseBlock(byteStream, gif, avgAlpha, getFrameIndex, getTransparencyIndex, progressCallback) {
|
|
395
|
-
switch (byteStream.nextByte()) {
|
|
396
|
-
case 59:
|
|
397
|
-
return true;
|
|
398
|
-
case 44:
|
|
399
|
-
await parseImageBlock(byteStream, gif, avgAlpha, getFrameIndex, getTransparencyIndex, progressCallback);
|
|
400
|
-
break;
|
|
401
|
-
case 33:
|
|
402
|
-
parseExtensionBlock(byteStream, gif, getFrameIndex, getTransparencyIndex);
|
|
403
|
-
break;
|
|
404
|
-
default:
|
|
405
|
-
throw new EvalError("undefined block found");
|
|
406
|
-
}
|
|
407
|
-
return false;
|
|
408
|
-
}
|
|
409
|
-
function getGIFLoopAmount(gif) {
|
|
410
|
-
for (const extension of gif.applicationExtensions) {
|
|
411
|
-
if (extension.identifier + extension.authenticationCode !== "NETSCAPE2.0") {
|
|
412
|
-
continue;
|
|
413
|
-
}
|
|
414
|
-
return extension.data[1] + (extension.data[2] << 8);
|
|
415
|
-
}
|
|
416
|
-
return NaN;
|
|
417
|
-
}
|
|
418
|
-
async function decodeGIF(gifURL, progressCallback, avgAlpha) {
|
|
419
|
-
if (!avgAlpha) avgAlpha = false;
|
|
420
|
-
const res = await fetch(gifURL);
|
|
421
|
-
if (!res.ok && res.status === 404) {
|
|
422
|
-
throw new EvalError("file not found");
|
|
423
|
-
}
|
|
424
|
-
const buffer = await res.arrayBuffer();
|
|
425
|
-
const gif = {
|
|
426
|
-
width: 0,
|
|
427
|
-
height: 0,
|
|
428
|
-
totalTime: 0,
|
|
429
|
-
colorRes: 0,
|
|
430
|
-
pixelAspectRatio: 0,
|
|
431
|
-
frames: [],
|
|
432
|
-
sortFlag: false,
|
|
433
|
-
globalColorTable: [],
|
|
434
|
-
backgroundImage: new ImageData(1, 1, {
|
|
435
|
-
colorSpace: "srgb"
|
|
436
|
-
}),
|
|
437
|
-
comments: [],
|
|
438
|
-
applicationExtensions: []
|
|
439
|
-
},
|
|
440
|
-
byteStream = new ByteStream(new Uint8ClampedArray(buffer));
|
|
441
|
-
if (byteStream.getString(6) !== "GIF89a") {
|
|
442
|
-
throw new Error("not a supported GIF file");
|
|
443
|
-
}
|
|
444
|
-
gif.width = byteStream.nextTwoBytes();
|
|
445
|
-
gif.height = byteStream.nextTwoBytes();
|
|
446
|
-
const packedByte = byteStream.nextByte(),
|
|
447
|
-
globalColorTableFlag = (packedByte & 0x80) === 0x80;
|
|
448
|
-
gif.colorRes = (packedByte & 0x70) >>> 4;
|
|
449
|
-
gif.sortFlag = (packedByte & 8) === 8;
|
|
450
|
-
const globalColorCount = 1 << (packedByte & 7) + 1,
|
|
451
|
-
backgroundColorIndex = byteStream.nextByte();
|
|
452
|
-
gif.pixelAspectRatio = byteStream.nextByte();
|
|
453
|
-
if (gif.pixelAspectRatio !== 0) {
|
|
454
|
-
gif.pixelAspectRatio = (gif.pixelAspectRatio + 0xf) / 0x40;
|
|
455
|
-
}
|
|
456
|
-
if (globalColorTableFlag) {
|
|
457
|
-
gif.globalColorTable = parseColorTable(byteStream, globalColorCount);
|
|
458
|
-
}
|
|
459
|
-
const backgroundImage = (() => {
|
|
460
|
-
try {
|
|
461
|
-
return new ImageData(gif.width, gif.height, {
|
|
462
|
-
colorSpace: "srgb"
|
|
463
|
-
});
|
|
464
|
-
} catch (error) {
|
|
465
|
-
if (error instanceof DOMException && error.name === "IndexSizeError") {
|
|
466
|
-
return null;
|
|
467
|
-
}
|
|
468
|
-
throw error;
|
|
469
|
-
}
|
|
470
|
-
})();
|
|
471
|
-
if (backgroundImage == null) {
|
|
472
|
-
throw new Error("GIF frame size is to large");
|
|
473
|
-
}
|
|
474
|
-
const {
|
|
475
|
-
r,
|
|
476
|
-
g,
|
|
477
|
-
b
|
|
478
|
-
} = gif.globalColorTable[backgroundColorIndex];
|
|
479
|
-
backgroundImage.data.set(globalColorTableFlag ? [r, g, b, 255] : [0, 0, 0, 0]);
|
|
480
|
-
for (let i = 4; i < backgroundImage.data.length; i *= 2) {
|
|
481
|
-
backgroundImage.data.copyWithin(i, 0, i);
|
|
482
|
-
}
|
|
483
|
-
gif.backgroundImage = backgroundImage;
|
|
484
|
-
let frameIndex = -1,
|
|
485
|
-
incrementFrameIndex = true,
|
|
486
|
-
transparencyIndex = -1;
|
|
487
|
-
const getframeIndex = increment => {
|
|
488
|
-
if (increment) {
|
|
489
|
-
incrementFrameIndex = true;
|
|
490
|
-
}
|
|
491
|
-
return frameIndex;
|
|
492
|
-
};
|
|
493
|
-
const getTransparencyIndex = newValue => {
|
|
494
|
-
if (newValue != null) {
|
|
495
|
-
transparencyIndex = newValue;
|
|
496
|
-
}
|
|
497
|
-
return transparencyIndex;
|
|
498
|
-
};
|
|
499
|
-
try {
|
|
500
|
-
do {
|
|
501
|
-
if (incrementFrameIndex) {
|
|
502
|
-
gif.frames.push({
|
|
503
|
-
left: 0,
|
|
504
|
-
top: 0,
|
|
505
|
-
width: 0,
|
|
506
|
-
height: 0,
|
|
507
|
-
disposalMethod: 0,
|
|
508
|
-
image: new ImageData(1, 1, {
|
|
509
|
-
colorSpace: "srgb"
|
|
510
|
-
}),
|
|
511
|
-
plainTextData: null,
|
|
512
|
-
userInputDelayFlag: false,
|
|
513
|
-
delayTime: 0,
|
|
514
|
-
sortFlag: false,
|
|
515
|
-
localColorTable: [],
|
|
516
|
-
reserved: 0,
|
|
517
|
-
GCreserved: 0
|
|
518
|
-
});
|
|
519
|
-
frameIndex++;
|
|
520
|
-
transparencyIndex = -1;
|
|
521
|
-
incrementFrameIndex = false;
|
|
522
|
-
}
|
|
523
|
-
} while (!(await parseBlock(byteStream, gif, avgAlpha, getframeIndex, getTransparencyIndex, progressCallback)));
|
|
524
|
-
gif.frames.length--;
|
|
525
|
-
for (const frame of gif.frames) {
|
|
526
|
-
if (frame.userInputDelayFlag && frame.delayTime === 0) {
|
|
527
|
-
gif.totalTime = Infinity;
|
|
528
|
-
break;
|
|
529
|
-
}
|
|
530
|
-
gif.totalTime += frame.delayTime;
|
|
531
|
-
}
|
|
532
|
-
return gif;
|
|
533
|
-
} catch (error) {
|
|
534
|
-
if (error instanceof EvalError) {
|
|
535
|
-
throw new Error(`error while parsing frame ${frameIndex} "${error.message}"`);
|
|
536
|
-
}
|
|
537
|
-
throw error;
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
;// CONCATENATED MODULE: ./dist/browser/Utils.js
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
const stringStart = 0,
|
|
544
|
-
defaultLoopCount = 0,
|
|
545
|
-
defaultOpacity = 1;
|
|
546
|
-
const currentColorRegex = /(#(?:[0-9a-f]{2}){2,4}|(#[0-9a-f]{3})|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d.]+%?\))|currentcolor/gi;
|
|
547
|
-
function replaceColorSvg(imageShape, color, opacity) {
|
|
548
|
-
const {
|
|
549
|
-
svgData
|
|
550
|
-
} = imageShape;
|
|
551
|
-
if (!svgData) {
|
|
552
|
-
return "";
|
|
553
|
-
}
|
|
554
|
-
const colorStyle = (0,engine_root_window_.getStyleFromHsl)(color, opacity);
|
|
555
|
-
if (svgData.includes("fill")) {
|
|
556
|
-
return svgData.replace(currentColorRegex, () => colorStyle);
|
|
557
|
-
}
|
|
558
|
-
const preFillIndex = svgData.indexOf(">");
|
|
559
|
-
return `${svgData.substring(stringStart, preFillIndex)} fill="${colorStyle}"${svgData.substring(preFillIndex)}`;
|
|
560
|
-
}
|
|
561
|
-
async function loadImage(image) {
|
|
562
|
-
return new Promise(resolve => {
|
|
563
|
-
image.loading = true;
|
|
564
|
-
const img = new Image();
|
|
565
|
-
image.element = img;
|
|
566
|
-
img.addEventListener("load", () => {
|
|
567
|
-
image.loading = false;
|
|
568
|
-
resolve();
|
|
569
|
-
});
|
|
570
|
-
img.addEventListener("error", () => {
|
|
571
|
-
image.element = undefined;
|
|
572
|
-
image.error = true;
|
|
573
|
-
image.loading = false;
|
|
574
|
-
(0,engine_root_window_.getLogger)().error(`${engine_root_window_.errorPrefix} loading image: ${image.source}`);
|
|
575
|
-
resolve();
|
|
576
|
-
});
|
|
577
|
-
img.src = image.source;
|
|
578
|
-
});
|
|
579
|
-
}
|
|
580
|
-
async function loadGifImage(image) {
|
|
581
|
-
if (image.type !== "gif") {
|
|
582
|
-
await loadImage(image);
|
|
583
|
-
return;
|
|
584
|
-
}
|
|
585
|
-
image.loading = true;
|
|
586
|
-
try {
|
|
587
|
-
image.gifData = await decodeGIF(image.source);
|
|
588
|
-
image.gifLoopCount = getGIFLoopAmount(image.gifData) ?? defaultLoopCount;
|
|
589
|
-
if (!image.gifLoopCount) {
|
|
590
|
-
image.gifLoopCount = Infinity;
|
|
591
|
-
}
|
|
592
|
-
} catch {
|
|
593
|
-
image.error = true;
|
|
594
|
-
}
|
|
595
|
-
image.loading = false;
|
|
596
|
-
}
|
|
597
|
-
async function downloadSvgImage(image) {
|
|
598
|
-
if (image.type !== "svg") {
|
|
599
|
-
await loadImage(image);
|
|
600
|
-
return;
|
|
601
|
-
}
|
|
602
|
-
image.loading = true;
|
|
603
|
-
const response = await fetch(image.source);
|
|
604
|
-
if (!response.ok) {
|
|
605
|
-
(0,engine_root_window_.getLogger)().error(`${engine_root_window_.errorPrefix} Image not found`);
|
|
606
|
-
image.error = true;
|
|
607
|
-
} else {
|
|
608
|
-
image.svgData = await response.text();
|
|
609
|
-
}
|
|
610
|
-
image.loading = false;
|
|
611
|
-
}
|
|
612
|
-
function replaceImageColor(image, imageData, color, particle) {
|
|
613
|
-
const svgColoredData = replaceColorSvg(image, color, particle.opacity?.value ?? defaultOpacity),
|
|
614
|
-
imageRes = {
|
|
615
|
-
color,
|
|
616
|
-
gif: imageData.gif,
|
|
617
|
-
data: {
|
|
618
|
-
...image,
|
|
619
|
-
svgData: svgColoredData
|
|
620
|
-
},
|
|
621
|
-
loaded: false,
|
|
622
|
-
ratio: imageData.width / imageData.height,
|
|
623
|
-
replaceColor: imageData.replaceColor,
|
|
624
|
-
source: imageData.src
|
|
625
|
-
};
|
|
626
|
-
return new Promise(resolve => {
|
|
627
|
-
const svg = new Blob([svgColoredData], {
|
|
628
|
-
type: "image/svg+xml"
|
|
629
|
-
}),
|
|
630
|
-
domUrl = URL || window.URL || window.webkitURL || window,
|
|
631
|
-
url = domUrl.createObjectURL(svg),
|
|
632
|
-
img = new Image();
|
|
633
|
-
img.addEventListener("load", () => {
|
|
634
|
-
imageRes.loaded = true;
|
|
635
|
-
imageRes.element = img;
|
|
636
|
-
resolve(imageRes);
|
|
637
|
-
domUrl.revokeObjectURL(url);
|
|
638
|
-
});
|
|
639
|
-
const errorHandler = async () => {
|
|
640
|
-
domUrl.revokeObjectURL(url);
|
|
641
|
-
const img2 = {
|
|
642
|
-
...image,
|
|
643
|
-
error: false,
|
|
644
|
-
loading: true
|
|
645
|
-
};
|
|
646
|
-
await loadImage(img2);
|
|
647
|
-
imageRes.loaded = true;
|
|
648
|
-
imageRes.element = img2.element;
|
|
649
|
-
resolve(imageRes);
|
|
650
|
-
};
|
|
651
|
-
img.addEventListener("error", () => void errorHandler());
|
|
652
|
-
img.src = url;
|
|
653
|
-
});
|
|
654
|
-
}
|
|
655
|
-
;// CONCATENATED MODULE: ./dist/browser/ImageDrawer.js
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
const origin = {
|
|
659
|
-
x: 0,
|
|
660
|
-
y: 0
|
|
661
|
-
},
|
|
662
|
-
ImageDrawer_defaultLoopCount = 0,
|
|
663
|
-
defaultFrame = 0,
|
|
664
|
-
half = 0.5,
|
|
665
|
-
initialTime = 0,
|
|
666
|
-
firstIndex = 0,
|
|
667
|
-
ImageDrawer_double = 2,
|
|
668
|
-
defaultAlpha = 1,
|
|
669
|
-
sides = 12,
|
|
670
|
-
defaultRatio = 1;
|
|
671
|
-
class ImageDrawer {
|
|
672
|
-
constructor(engine) {
|
|
673
|
-
this.loadImageShape = async imageShape => {
|
|
674
|
-
if (!this._engine.loadImage) {
|
|
675
|
-
throw new Error(`${engine_root_window_.errorPrefix} image shape not initialized`);
|
|
676
|
-
}
|
|
677
|
-
await this._engine.loadImage({
|
|
678
|
-
gif: imageShape.gif,
|
|
679
|
-
name: imageShape.name,
|
|
680
|
-
replaceColor: imageShape.replaceColor ?? false,
|
|
681
|
-
src: imageShape.src
|
|
682
|
-
});
|
|
683
|
-
};
|
|
684
|
-
this._engine = engine;
|
|
685
|
-
}
|
|
686
|
-
addImage(image) {
|
|
687
|
-
if (!this._engine.images) {
|
|
688
|
-
this._engine.images = [];
|
|
689
|
-
}
|
|
690
|
-
this._engine.images.push(image);
|
|
691
|
-
}
|
|
692
|
-
draw(data) {
|
|
693
|
-
const {
|
|
694
|
-
context,
|
|
695
|
-
radius,
|
|
696
|
-
particle,
|
|
697
|
-
opacity,
|
|
698
|
-
delta
|
|
699
|
-
} = data,
|
|
700
|
-
image = particle.image,
|
|
701
|
-
element = image?.element;
|
|
702
|
-
if (!image) {
|
|
703
|
-
return;
|
|
704
|
-
}
|
|
705
|
-
context.globalAlpha = opacity;
|
|
706
|
-
if (image.gif && image.gifData) {
|
|
707
|
-
const offscreenCanvas = new OffscreenCanvas(image.gifData.width, image.gifData.height),
|
|
708
|
-
offscreenContext = offscreenCanvas.getContext("2d");
|
|
709
|
-
if (!offscreenContext) {
|
|
710
|
-
throw new Error("could not create offscreen canvas context");
|
|
711
|
-
}
|
|
712
|
-
offscreenContext.imageSmoothingQuality = "low";
|
|
713
|
-
offscreenContext.imageSmoothingEnabled = false;
|
|
714
|
-
offscreenContext.clearRect(origin.x, origin.y, offscreenCanvas.width, offscreenCanvas.height);
|
|
715
|
-
if (particle.gifLoopCount === undefined) {
|
|
716
|
-
particle.gifLoopCount = image.gifLoopCount ?? ImageDrawer_defaultLoopCount;
|
|
717
|
-
}
|
|
718
|
-
let frameIndex = particle.gifFrame ?? defaultFrame;
|
|
719
|
-
const pos = {
|
|
720
|
-
x: -image.gifData.width * half,
|
|
721
|
-
y: -image.gifData.height * half
|
|
722
|
-
},
|
|
723
|
-
frame = image.gifData.frames[frameIndex];
|
|
724
|
-
if (particle.gifTime === undefined) {
|
|
725
|
-
particle.gifTime = initialTime;
|
|
726
|
-
}
|
|
727
|
-
if (!frame.bitmap) {
|
|
728
|
-
return;
|
|
729
|
-
}
|
|
730
|
-
context.scale(radius / image.gifData.width, radius / image.gifData.height);
|
|
731
|
-
switch (frame.disposalMethod) {
|
|
732
|
-
case 4:
|
|
733
|
-
case 5:
|
|
734
|
-
case 6:
|
|
735
|
-
case 7:
|
|
736
|
-
case 0:
|
|
737
|
-
offscreenContext.drawImage(frame.bitmap, frame.left, frame.top);
|
|
738
|
-
context.drawImage(offscreenCanvas, pos.x, pos.y);
|
|
739
|
-
offscreenContext.clearRect(origin.x, origin.y, offscreenCanvas.width, offscreenCanvas.height);
|
|
740
|
-
break;
|
|
741
|
-
case 1:
|
|
742
|
-
offscreenContext.drawImage(frame.bitmap, frame.left, frame.top);
|
|
743
|
-
context.drawImage(offscreenCanvas, pos.x, pos.y);
|
|
744
|
-
break;
|
|
745
|
-
case 2:
|
|
746
|
-
offscreenContext.drawImage(frame.bitmap, frame.left, frame.top);
|
|
747
|
-
context.drawImage(offscreenCanvas, pos.x, pos.y);
|
|
748
|
-
offscreenContext.clearRect(origin.x, origin.y, offscreenCanvas.width, offscreenCanvas.height);
|
|
749
|
-
if (!image.gifData.globalColorTable.length) {
|
|
750
|
-
offscreenContext.putImageData(image.gifData.frames[firstIndex].image, pos.x + frame.left, pos.y + frame.top);
|
|
751
|
-
} else {
|
|
752
|
-
offscreenContext.putImageData(image.gifData.backgroundImage, pos.x, pos.y);
|
|
753
|
-
}
|
|
754
|
-
break;
|
|
755
|
-
case 3:
|
|
756
|
-
{
|
|
757
|
-
const previousImageData = offscreenContext.getImageData(origin.x, origin.y, offscreenCanvas.width, offscreenCanvas.height);
|
|
758
|
-
offscreenContext.drawImage(frame.bitmap, frame.left, frame.top);
|
|
759
|
-
context.drawImage(offscreenCanvas, pos.x, pos.y);
|
|
760
|
-
offscreenContext.clearRect(origin.x, origin.y, offscreenCanvas.width, offscreenCanvas.height);
|
|
761
|
-
offscreenContext.putImageData(previousImageData, origin.x, origin.y);
|
|
762
|
-
}
|
|
763
|
-
break;
|
|
764
|
-
}
|
|
765
|
-
particle.gifTime += delta.value;
|
|
766
|
-
if (particle.gifTime > frame.delayTime) {
|
|
767
|
-
particle.gifTime -= frame.delayTime;
|
|
768
|
-
if (++frameIndex >= image.gifData.frames.length) {
|
|
769
|
-
if (--particle.gifLoopCount <= ImageDrawer_defaultLoopCount) {
|
|
770
|
-
return;
|
|
771
|
-
}
|
|
772
|
-
frameIndex = firstIndex;
|
|
773
|
-
offscreenContext.clearRect(origin.x, origin.y, offscreenCanvas.width, offscreenCanvas.height);
|
|
774
|
-
}
|
|
775
|
-
particle.gifFrame = frameIndex;
|
|
776
|
-
}
|
|
777
|
-
context.scale(image.gifData.width / radius, image.gifData.height / radius);
|
|
778
|
-
} else if (element) {
|
|
779
|
-
const ratio = image.ratio,
|
|
780
|
-
pos = {
|
|
781
|
-
x: -radius,
|
|
782
|
-
y: -radius
|
|
783
|
-
},
|
|
784
|
-
diameter = radius * ImageDrawer_double;
|
|
785
|
-
context.drawImage(element, pos.x, pos.y, diameter, diameter / ratio);
|
|
786
|
-
}
|
|
787
|
-
context.globalAlpha = defaultAlpha;
|
|
788
|
-
}
|
|
789
|
-
getSidesCount() {
|
|
790
|
-
return sides;
|
|
791
|
-
}
|
|
792
|
-
async init(container) {
|
|
793
|
-
const options = container.actualOptions;
|
|
794
|
-
if (!options.preload || !this._engine.loadImage) {
|
|
795
|
-
return;
|
|
796
|
-
}
|
|
797
|
-
for (const imageData of options.preload) {
|
|
798
|
-
await this._engine.loadImage(imageData);
|
|
799
|
-
}
|
|
800
|
-
}
|
|
801
|
-
loadShape(particle) {
|
|
802
|
-
if (particle.shape !== "image" && particle.shape !== "images") {
|
|
803
|
-
return;
|
|
804
|
-
}
|
|
805
|
-
if (!this._engine.images) {
|
|
806
|
-
this._engine.images = [];
|
|
807
|
-
}
|
|
808
|
-
const imageData = particle.shapeData;
|
|
809
|
-
if (!imageData) {
|
|
810
|
-
return;
|
|
811
|
-
}
|
|
812
|
-
const image = this._engine.images.find(t => t.name === imageData.name || t.source === imageData.src);
|
|
813
|
-
if (!image) {
|
|
814
|
-
void this.loadImageShape(imageData).then(() => {
|
|
815
|
-
this.loadShape(particle);
|
|
816
|
-
});
|
|
817
|
-
}
|
|
818
|
-
}
|
|
819
|
-
particleInit(container, particle) {
|
|
820
|
-
if (particle.shape !== "image" && particle.shape !== "images") {
|
|
821
|
-
return;
|
|
822
|
-
}
|
|
823
|
-
if (!this._engine.images) {
|
|
824
|
-
this._engine.images = [];
|
|
825
|
-
}
|
|
826
|
-
const images = this._engine.images,
|
|
827
|
-
imageData = particle.shapeData;
|
|
828
|
-
if (!imageData) {
|
|
829
|
-
return;
|
|
830
|
-
}
|
|
831
|
-
const color = particle.getFillColor(),
|
|
832
|
-
image = images.find(t => t.name === imageData.name || t.source === imageData.src);
|
|
833
|
-
if (!image) {
|
|
834
|
-
return;
|
|
835
|
-
}
|
|
836
|
-
const replaceColor = imageData.replaceColor ?? image.replaceColor;
|
|
837
|
-
if (image.loading) {
|
|
838
|
-
setTimeout(() => {
|
|
839
|
-
this.particleInit(container, particle);
|
|
840
|
-
});
|
|
841
|
-
return;
|
|
842
|
-
}
|
|
843
|
-
void (async () => {
|
|
844
|
-
let imageRes;
|
|
845
|
-
if (image.svgData && color) {
|
|
846
|
-
imageRes = await replaceImageColor(image, imageData, color, particle);
|
|
847
|
-
} else {
|
|
848
|
-
imageRes = {
|
|
849
|
-
color,
|
|
850
|
-
data: image,
|
|
851
|
-
element: image.element,
|
|
852
|
-
gif: image.gif,
|
|
853
|
-
gifData: image.gifData,
|
|
854
|
-
gifLoopCount: image.gifLoopCount,
|
|
855
|
-
loaded: true,
|
|
856
|
-
ratio: imageData.width && imageData.height ? imageData.width / imageData.height : image.ratio ?? defaultRatio,
|
|
857
|
-
replaceColor: replaceColor,
|
|
858
|
-
source: imageData.src
|
|
859
|
-
};
|
|
860
|
-
}
|
|
861
|
-
if (!imageRes.ratio) {
|
|
862
|
-
imageRes.ratio = 1;
|
|
863
|
-
}
|
|
864
|
-
const fill = imageData.fill ?? particle.shapeFill,
|
|
865
|
-
close = imageData.close ?? particle.shapeClose,
|
|
866
|
-
imageShape = {
|
|
867
|
-
image: imageRes,
|
|
868
|
-
fill,
|
|
869
|
-
close
|
|
870
|
-
};
|
|
871
|
-
particle.image = imageShape.image;
|
|
872
|
-
particle.shapeFill = imageShape.fill;
|
|
873
|
-
particle.shapeClose = imageShape.close;
|
|
874
|
-
})();
|
|
875
|
-
}
|
|
876
|
-
}
|
|
877
|
-
;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Preload.js
|
|
878
|
-
class Preload {
|
|
879
|
-
constructor() {
|
|
880
|
-
this.src = "";
|
|
881
|
-
this.gif = false;
|
|
882
|
-
}
|
|
883
|
-
load(data) {
|
|
884
|
-
if (!data) {
|
|
885
|
-
return;
|
|
886
|
-
}
|
|
887
|
-
if (data.gif !== undefined) {
|
|
888
|
-
this.gif = data.gif;
|
|
889
|
-
}
|
|
890
|
-
if (data.height !== undefined) {
|
|
891
|
-
this.height = data.height;
|
|
892
|
-
}
|
|
893
|
-
if (data.name !== undefined) {
|
|
894
|
-
this.name = data.name;
|
|
895
|
-
}
|
|
896
|
-
if (data.replaceColor !== undefined) {
|
|
897
|
-
this.replaceColor = data.replaceColor;
|
|
898
|
-
}
|
|
899
|
-
if (data.src !== undefined) {
|
|
900
|
-
this.src = data.src;
|
|
901
|
-
}
|
|
902
|
-
if (data.width !== undefined) {
|
|
903
|
-
this.width = data.width;
|
|
904
|
-
}
|
|
905
|
-
}
|
|
906
|
-
}
|
|
907
|
-
;// CONCATENATED MODULE: ./dist/browser/ImagePreloader.js
|
|
908
|
-
|
|
909
|
-
class ImagePreloaderPlugin {
|
|
910
|
-
constructor(engine) {
|
|
911
|
-
this.id = "imagePreloader";
|
|
912
|
-
this._engine = engine;
|
|
913
|
-
}
|
|
914
|
-
getPlugin() {
|
|
915
|
-
return {};
|
|
916
|
-
}
|
|
917
|
-
loadOptions(options, source) {
|
|
918
|
-
if (!source?.preload) {
|
|
919
|
-
return;
|
|
920
|
-
}
|
|
921
|
-
if (!options.preload) {
|
|
922
|
-
options.preload = [];
|
|
923
|
-
}
|
|
924
|
-
const preloadOptions = options.preload;
|
|
925
|
-
for (const item of source.preload) {
|
|
926
|
-
const existing = preloadOptions.find(t => t.name === item.name || t.src === item.src);
|
|
927
|
-
if (existing) {
|
|
928
|
-
existing.load(item);
|
|
929
|
-
} else {
|
|
930
|
-
const preload = new Preload();
|
|
931
|
-
preload.load(item);
|
|
932
|
-
preloadOptions.push(preload);
|
|
933
|
-
}
|
|
934
|
-
}
|
|
935
|
-
}
|
|
936
|
-
needsPlugin() {
|
|
937
|
-
return true;
|
|
938
|
-
}
|
|
939
|
-
}
|
|
940
|
-
;// CONCATENATED MODULE: ./dist/browser/index.js
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
const extLength = 3;
|
|
946
|
-
function addLoadImageToEngine(engine) {
|
|
947
|
-
if (engine.loadImage) {
|
|
948
|
-
return;
|
|
949
|
-
}
|
|
950
|
-
engine.loadImage = async data => {
|
|
951
|
-
if (!data.name && !data.src) {
|
|
952
|
-
throw new Error(`${engine_root_window_.errorPrefix} no image source provided`);
|
|
953
|
-
}
|
|
954
|
-
if (!engine.images) {
|
|
955
|
-
engine.images = [];
|
|
956
|
-
}
|
|
957
|
-
if (engine.images.find(t => t.name === data.name || t.source === data.src)) {
|
|
958
|
-
return;
|
|
959
|
-
}
|
|
960
|
-
try {
|
|
961
|
-
const image = {
|
|
962
|
-
gif: data.gif ?? false,
|
|
963
|
-
name: data.name ?? data.src,
|
|
964
|
-
source: data.src,
|
|
965
|
-
type: data.src.substring(data.src.length - extLength),
|
|
966
|
-
error: false,
|
|
967
|
-
loading: true,
|
|
968
|
-
replaceColor: data.replaceColor,
|
|
969
|
-
ratio: data.width && data.height ? data.width / data.height : undefined
|
|
970
|
-
};
|
|
971
|
-
engine.images.push(image);
|
|
972
|
-
let imageFunc;
|
|
973
|
-
if (data.gif) {
|
|
974
|
-
imageFunc = loadGifImage;
|
|
975
|
-
} else {
|
|
976
|
-
imageFunc = data.replaceColor ? downloadSvgImage : loadImage;
|
|
977
|
-
}
|
|
978
|
-
await imageFunc(image);
|
|
979
|
-
} catch {
|
|
980
|
-
throw new Error(`${engine_root_window_.errorPrefix} ${data.name ?? data.src} not found`);
|
|
981
|
-
}
|
|
982
|
-
};
|
|
983
|
-
}
|
|
984
|
-
async function loadImageShape(engine, refresh = true) {
|
|
985
|
-
addLoadImageToEngine(engine);
|
|
986
|
-
const preloader = new ImagePreloaderPlugin(engine);
|
|
987
|
-
await engine.addPlugin(preloader, refresh);
|
|
988
|
-
await engine.addShape(["image", "images"], new ImageDrawer(engine), refresh);
|
|
989
|
-
}
|
|
990
|
-
})();
|
|
991
|
-
|
|
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
|
+
/******/
|
|
992
333
|
/******/ return __webpack_exports__;
|
|
993
334
|
/******/ })()
|
|
994
335
|
;
|