@tsparticles/updater-gradient 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.
@@ -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.3
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, (__WEBPACK_EXTERNAL_MODULE__533__) => {
26
+ })(this, (__WEBPACK_EXTERNAL_MODULE__tsparticles_engine__) => {
19
27
  return /******/ (() => { // webpackBootstrap
20
28
  /******/ "use strict";
21
29
  /******/ var __webpack_modules__ = ({
22
30
 
23
- /***/ 533:
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 */ loadGradientUpdater: () => (/* binding */ loadGradientUpdater)\n/* harmony export */ });\nasync function loadGradientUpdater(engine, refresh = true) {\n await engine.addParticleUpdater(\"gradient\", async () => {\n const {\n GradientUpdater\n } = await __webpack_require__.e(/*! import() */ \"dist_browser_GradientUpdater_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./GradientUpdater.js */ \"./dist/browser/GradientUpdater.js\"));\n return new GradientUpdater();\n }, refresh);\n}\n\n//# sourceURL=webpack://@tsparticles/updater-gradient/./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 = __WEBPACK_EXTERNAL_MODULE__533__;
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/updater-gradient:";
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,435 +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.updater.gradient": 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_updater_gradient"] = this["webpackChunk_tsparticles_updater_gradient"] || [];
312
+ /******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));
313
+ /******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));
314
+ /******/ })();
315
+ /******/
85
316
  /************************************************************************/
86
- var __webpack_exports__ = {};
87
- // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
88
- (() => {
89
- // ESM COMPAT FLAG
90
- __webpack_require__.r(__webpack_exports__);
91
-
92
- // EXPORTS
93
- __webpack_require__.d(__webpack_exports__, {
94
- loadGradientUpdater: () => (/* binding */ loadGradientUpdater)
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/Options/Classes/GradientColorOpacityAnimation.js
100
-
101
- class GradientColorOpacityAnimation {
102
- constructor() {
103
- this.count = 0;
104
- this.enable = false;
105
- this.speed = 0;
106
- this.decay = 0;
107
- this.delay = 0;
108
- this.sync = false;
109
- this.startValue = "random";
110
- }
111
- load(data) {
112
- if (!data) {
113
- return;
114
- }
115
- if (data.count !== undefined) {
116
- this.count = (0,engine_root_window_.setRangeValue)(data.count);
117
- }
118
- if (data.enable !== undefined) {
119
- this.enable = data.enable;
120
- }
121
- if (data.speed !== undefined) {
122
- this.speed = (0,engine_root_window_.setRangeValue)(data.speed);
123
- }
124
- if (data.sync !== undefined) {
125
- this.sync = data.sync;
126
- }
127
- if (data.startValue !== undefined) {
128
- this.startValue = data.startValue;
129
- }
130
- if (data.decay !== undefined) {
131
- this.decay = (0,engine_root_window_.setRangeValue)(data.decay);
132
- }
133
- if (data.delay !== undefined) {
134
- this.delay = (0,engine_root_window_.setRangeValue)(data.delay);
135
- }
136
- }
137
- }
138
- ;// CONCATENATED MODULE: ./dist/browser/Options/Classes/GradientColorOpacity.js
139
-
140
-
141
- class GradientColorOpacity {
142
- constructor() {
143
- this.value = 0;
144
- this.animation = new GradientColorOpacityAnimation();
145
- }
146
- load(data) {
147
- if (!data) {
148
- return;
149
- }
150
- this.animation.load(data.animation);
151
- if (data.value !== undefined) {
152
- this.value = (0,engine_root_window_.setRangeValue)(data.value);
153
- }
154
- }
155
- }
156
- ;// CONCATENATED MODULE: ./dist/browser/Options/Classes/AnimatableGradientColor.js
157
-
158
-
159
- class AnimatableGradientColor {
160
- constructor() {
161
- this.stop = 0;
162
- this.value = new engine_root_window_.AnimatableColor();
163
- }
164
- load(data) {
165
- if (!data) {
166
- return;
167
- }
168
- if (data.stop !== undefined) {
169
- this.stop = data.stop;
170
- }
171
- this.value = engine_root_window_.AnimatableColor.create(this.value, data.value);
172
- if (data.opacity !== undefined) {
173
- this.opacity = new GradientColorOpacity();
174
- if ((0,engine_root_window_.isNumber)(data.opacity)) {
175
- this.opacity.value = data.opacity;
176
- } else {
177
- this.opacity.load(data.opacity);
178
- }
179
- }
180
- }
181
- }
182
- ;// CONCATENATED MODULE: ./dist/browser/Options/Classes/GradientAngleAnimation.js
183
-
184
- class GradientAngleAnimation {
185
- constructor() {
186
- this.count = 0;
187
- this.enable = false;
188
- this.speed = 0;
189
- this.decay = 0;
190
- this.delay = 0;
191
- this.sync = false;
192
- }
193
- load(data) {
194
- if (!data) {
195
- return;
196
- }
197
- if (data.count !== undefined) {
198
- this.count = (0,engine_root_window_.setRangeValue)(data.count);
199
- }
200
- if (data.enable !== undefined) {
201
- this.enable = data.enable;
202
- }
203
- if (data.speed !== undefined) {
204
- this.speed = (0,engine_root_window_.setRangeValue)(data.speed);
205
- }
206
- if (data.decay !== undefined) {
207
- this.decay = (0,engine_root_window_.setRangeValue)(data.decay);
208
- }
209
- if (data.delay !== undefined) {
210
- this.delay = (0,engine_root_window_.setRangeValue)(data.delay);
211
- }
212
- if (data.sync !== undefined) {
213
- this.sync = data.sync;
214
- }
215
- }
216
- }
217
- ;// CONCATENATED MODULE: ./dist/browser/Options/Classes/GradientAngle.js
218
-
219
-
220
- class GradientAngle {
221
- constructor() {
222
- this.value = 0;
223
- this.animation = new GradientAngleAnimation();
224
- this.direction = "clockwise";
225
- }
226
- load(data) {
227
- if (!data) {
228
- return;
229
- }
230
- this.animation.load(data.animation);
231
- if (data.value !== undefined) {
232
- this.value = (0,engine_root_window_.setRangeValue)(data.value);
233
- }
234
- if (data.direction !== undefined) {
235
- this.direction = data.direction;
236
- }
237
- }
238
- }
239
- ;// CONCATENATED MODULE: ./dist/browser/Options/Classes/AnimatableGradient.js
240
-
241
-
242
- class AnimatableGradient {
243
- constructor() {
244
- this.angle = new GradientAngle();
245
- this.colors = [];
246
- this.type = "random";
247
- }
248
- load(data) {
249
- if (!data) {
250
- return;
251
- }
252
- this.angle.load(data.angle);
253
- if (data.colors !== undefined) {
254
- this.colors = data.colors.map(s => {
255
- const tmp = new AnimatableGradientColor();
256
- tmp.load(s);
257
- return tmp;
258
- });
259
- }
260
- if (data.type !== undefined) {
261
- this.type = data.type;
262
- }
263
- }
264
- }
265
- ;// CONCATENATED MODULE: ./dist/browser/Utils.js
266
- function updateColorOpacity(delta, value) {
267
- if (!value.enable) {
268
- return;
269
- }
270
- const decay = value.decay ?? 1;
271
- switch (value.status) {
272
- case "increasing":
273
- if (value.value >= value.max) {
274
- value.status = "decreasing";
275
- } else {
276
- value.value += (value.velocity ?? 0) * delta.factor;
277
- }
278
- break;
279
- case "decreasing":
280
- if (value.value <= value.min) {
281
- value.status = "increasing";
282
- } else {
283
- value.value -= (value.velocity ?? 0) * delta.factor;
284
- }
285
- break;
286
- }
287
- if (value.velocity && decay !== 1) {
288
- value.velocity *= decay;
289
- }
290
- }
291
- function updateColorValue(delta, colorValue, max, decrease) {
292
- if (!colorValue || !colorValue.enable) {
293
- return;
294
- }
295
- if (!colorValue.time) {
296
- colorValue.time = 0;
297
- }
298
- if ((colorValue.delayTime ?? 0) > 0 && colorValue.time < (colorValue.delayTime ?? 0)) {
299
- colorValue.time += delta.value;
300
- }
301
- if ((colorValue.delayTime ?? 0) > 0 && colorValue.time < (colorValue.delayTime ?? 0)) {
302
- return;
303
- }
304
- const velocity = (colorValue.velocity ?? 0) * delta.factor,
305
- decay = colorValue.decay ?? 1;
306
- if (!decrease || colorValue.status === "increasing") {
307
- colorValue.value += velocity;
308
- if (decrease && colorValue.value > max) {
309
- colorValue.status = "decreasing";
310
- colorValue.value -= colorValue.value % max;
311
- }
312
- } else {
313
- colorValue.value -= velocity;
314
- if (colorValue.value < 0) {
315
- colorValue.status = "increasing";
316
- colorValue.value += colorValue.value;
317
- }
318
- }
319
- if (colorValue.value > max) {
320
- colorValue.value %= max;
321
- }
322
- if (colorValue.velocity && decay !== 1) {
323
- colorValue.velocity *= decay;
324
- }
325
- }
326
- function updateAngle(delta, angle) {
327
- const speed = (angle.velocity ?? 0) * delta.factor,
328
- max = 2 * Math.PI,
329
- decay = angle.decay ?? 1;
330
- if (!angle.enable) {
331
- return;
332
- }
333
- switch (angle.status) {
334
- case "increasing":
335
- angle.value += speed;
336
- if (angle.value > max) {
337
- angle.value -= max;
338
- }
339
- break;
340
- case "decreasing":
341
- default:
342
- angle.value -= speed;
343
- if (angle.value < 0) {
344
- angle.value += max;
345
- }
346
- break;
347
- }
348
- if (angle.velocity && decay !== 1) {
349
- angle.velocity *= decay;
350
- }
351
- }
352
- function updateGradient(particle, delta) {
353
- const {
354
- gradient
355
- } = particle;
356
- if (!gradient) {
357
- return;
358
- }
359
- updateAngle(delta, gradient.angle);
360
- for (const color of gradient.colors) {
361
- if (particle.color?.h !== undefined) {
362
- updateColorValue(delta, color.value.h, 360, false);
363
- }
364
- if (particle.color?.s !== undefined) {
365
- updateColorValue(delta, color.value.s, 100, true);
366
- }
367
- if (particle.color?.l !== undefined) {
368
- updateColorValue(delta, color.value.l, 100, true);
369
- }
370
- if (color.opacity) {
371
- updateColorOpacity(delta, color.opacity);
372
- }
373
- }
374
- }
375
- ;// CONCATENATED MODULE: ./dist/browser/GradientUpdater.js
376
-
377
-
378
-
379
- class GradientUpdater {
380
- getColorStyles(particle, context, radius, opacity) {
381
- const gradient = particle.gradient;
382
- if (!gradient) {
383
- return {};
384
- }
385
- const gradientAngle = gradient.angle.value,
386
- fillGradient = gradient.type === "radial" ? context.createRadialGradient(0, 0, 0, 0, 0, radius) : context.createLinearGradient(Math.cos(gradientAngle) * -radius, Math.sin(gradientAngle) * -radius, Math.cos(gradientAngle) * radius, Math.sin(gradientAngle) * radius);
387
- for (const {
388
- stop,
389
- value,
390
- opacity: cOpacity
391
- } of gradient.colors) {
392
- fillGradient.addColorStop(stop, (0,engine_root_window_.getStyleFromHsl)({
393
- h: value.h.value,
394
- s: value.s.value,
395
- l: value.l.value
396
- }, cOpacity?.value ?? opacity));
397
- }
398
- return {
399
- fill: fillGradient
400
- };
401
- }
402
- init(particle) {
403
- const gradient = (0,engine_root_window_.itemFromSingleOrMultiple)(particle.options.gradient);
404
- if (!gradient) {
405
- return;
406
- }
407
- const {
408
- angle
409
- } = gradient;
410
- particle.gradient = {
411
- angle: {
412
- value: (0,engine_root_window_.getRangeValue)(angle.value),
413
- enable: angle.animation.enable,
414
- velocity: (0,engine_root_window_.getRangeValue)(angle.animation.speed) / 360 * particle.container.retina.reduceFactor,
415
- decay: 1 - (0,engine_root_window_.getRangeValue)(angle.animation.decay),
416
- delayTime: (0,engine_root_window_.getRangeValue)(angle.animation.delay) * 1000,
417
- time: 0
418
- },
419
- type: gradient.type,
420
- colors: []
421
- };
422
- let rotateDirection = gradient.angle.direction;
423
- if (rotateDirection === "random") {
424
- rotateDirection = (0,engine_root_window_.getRandom)() > 0.5 ? "counter-clockwise" : "clockwise";
425
- }
426
- switch (rotateDirection) {
427
- case "counter-clockwise":
428
- case "counterClockwise":
429
- particle.gradient.angle.status = "decreasing";
430
- break;
431
- case "clockwise":
432
- particle.gradient.angle.status = "increasing";
433
- break;
434
- }
435
- const reduceDuplicates = particle.options.reduceDuplicates;
436
- for (const grColor of gradient.colors) {
437
- const grHslColor = (0,engine_root_window_.rangeColorToHsl)(grColor.value, particle.id, reduceDuplicates);
438
- if (!grHslColor) {
439
- continue;
440
- }
441
- const grHslAnimation = (0,engine_root_window_.getHslAnimationFromHsl)(grHslColor, grColor.value.animation, particle.container.retina.reduceFactor),
442
- addColor = {
443
- stop: grColor.stop,
444
- value: grHslAnimation,
445
- opacity: grColor.opacity ? {
446
- enable: grColor.opacity.animation.enable,
447
- max: (0,engine_root_window_.getRangeMax)(grColor.opacity.value),
448
- min: (0,engine_root_window_.getRangeMin)(grColor.opacity.value),
449
- status: "increasing",
450
- value: (0,engine_root_window_.getRangeValue)(grColor.opacity.value),
451
- velocity: (0,engine_root_window_.getRangeValue)(grColor.opacity.animation.speed) / 100 * particle.container.retina.reduceFactor,
452
- decay: 1 - (0,engine_root_window_.getRangeValue)(grColor.opacity.animation.decay),
453
- delayTime: (0,engine_root_window_.getRangeValue)(grColor.opacity.animation.delay) * 1000,
454
- time: 0
455
- } : undefined
456
- };
457
- const {
458
- opacity: addOpacity
459
- } = addColor;
460
- if (grColor.opacity && addOpacity) {
461
- const opacityRange = grColor.opacity.value;
462
- addOpacity.min = (0,engine_root_window_.getRangeMin)(opacityRange);
463
- addOpacity.max = (0,engine_root_window_.getRangeMax)(opacityRange);
464
- const opacityAnimation = grColor.opacity.animation;
465
- switch (opacityAnimation.startValue) {
466
- case "min":
467
- addOpacity.value = addOpacity.min;
468
- addOpacity.status = "increasing";
469
- break;
470
- case "max":
471
- addOpacity.value = addOpacity.max;
472
- addOpacity.status = "decreasing";
473
- break;
474
- case "random":
475
- default:
476
- addOpacity.value = (0,engine_root_window_.randomInRange)(addOpacity);
477
- addOpacity.status = (0,engine_root_window_.getRandom)() >= 0.5 ? "increasing" : "decreasing";
478
- break;
479
- }
480
- }
481
- particle.gradient.colors.push(addColor);
482
- }
483
- }
484
- isEnabled(particle) {
485
- return !particle.destroyed && !particle.spawning && (particle.gradient?.angle.enable || (particle.gradient?.colors.some(c => c.value.h.enable || c.value.s.enable || c.value.l.enable) ?? false));
486
- }
487
- loadOptions(options, ...sources) {
488
- for (const source of sources) {
489
- if (!source?.gradient) {
490
- continue;
491
- }
492
- const gradientToLoad = source.gradient;
493
- if (!gradientToLoad) {
494
- continue;
495
- }
496
- options.gradient = (0,engine_root_window_.executeOnSingleOrMultiple)(gradientToLoad, gradient => {
497
- const tmp = new AnimatableGradient();
498
- tmp.load(gradient);
499
- return tmp;
500
- });
501
- }
502
- }
503
- update(particle, delta) {
504
- updateGradient(particle, delta);
505
- }
506
- }
507
- ;// CONCATENATED MODULE: ./dist/browser/index.js
508
-
509
- async function loadGradientUpdater(engine, refresh = true) {
510
- await engine.addParticleUpdater("gradient", () => new GradientUpdater(), refresh);
511
- }
512
- })();
513
-
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
+ /******/
514
323
  /******/ return __webpack_exports__;
515
324
  /******/ })()
516
325
  ;