@tsparticles/plugin-canvas-mask 4.0.0-beta.12 → 4.0.0-beta.16
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/browser/browser.js +5 -0
- package/browser/index.js +3 -3
- package/browser/index.lazy.js +7 -0
- package/cjs/browser.js +5 -0
- package/cjs/index.js +3 -3
- package/cjs/index.lazy.js +7 -0
- package/esm/browser.js +5 -0
- package/esm/index.js +3 -3
- package/esm/index.lazy.js +7 -0
- package/package.json +10 -3
- package/report.html +4949 -94
- package/tsparticles.plugin.canvas-mask.js +355 -317
- package/tsparticles.plugin.canvas-mask.min.js +1 -2
- package/types/browser.d.ts +1 -0
- package/types/index.lazy.d.ts +2 -0
- package/520.min.js +0 -1
- package/904.min.js +0 -2
- package/dist_browser_CanvasMaskPluginInstance_js.js +0 -40
- package/dist_browser_CanvasMaskPlugin_js.js +0 -100
|
@@ -1,327 +1,365 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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/).
|
|
16
|
-
*/
|
|
17
|
-
(function webpackUniversalModuleDefinition(root, factory) {
|
|
18
|
-
if(typeof exports === 'object' && typeof module === 'object')
|
|
19
|
-
module.exports = factory(require("@tsparticles/canvas-utils"), require("@tsparticles/engine"));
|
|
20
|
-
else if(typeof define === 'function' && define.amd)
|
|
21
|
-
define(["@tsparticles/canvas-utils", "@tsparticles/engine"], factory);
|
|
22
|
-
else {
|
|
23
|
-
var a = typeof exports === 'object' ? factory(require("@tsparticles/canvas-utils"), require("@tsparticles/engine")) : factory(root["window"], root["window"]);
|
|
24
|
-
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
|
|
25
|
-
}
|
|
26
|
-
})(this, (__WEBPACK_EXTERNAL_MODULE__tsparticles_canvas_utils__, __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__) => {
|
|
27
|
-
return /******/ (() => { // webpackBootstrap
|
|
28
|
-
/******/ "use strict";
|
|
29
|
-
/******/ var __webpack_modules__ = ({
|
|
1
|
+
(function(g){g.__tsParticlesInternals=g.__tsParticlesInternals||{};g.__tsParticlesInternals.bundles=g.__tsParticlesInternals.bundles||{};g.__tsParticlesInternals.effects=g.__tsParticlesInternals.effects||{};g.__tsParticlesInternals.engine=g.__tsParticlesInternals.engine||{};g.__tsParticlesInternals.interactions=g.__tsParticlesInternals.interactions||{};g.__tsParticlesInternals.palettes=g.__tsParticlesInternals.palettes||{};g.__tsParticlesInternals.paths=g.__tsParticlesInternals.paths||{};g.__tsParticlesInternals.plugins=g.__tsParticlesInternals.plugins||{};g.__tsParticlesInternals.plugins=g.__tsParticlesInternals.plugins||{};g.__tsParticlesInternals.plugins.emittersShapes=g.__tsParticlesInternals.plugins.emittersShapes||{};g.__tsParticlesInternals.presets=g.__tsParticlesInternals.presets||{};g.__tsParticlesInternals.shapes=g.__tsParticlesInternals.shapes||{};g.__tsParticlesInternals.updaters=g.__tsParticlesInternals.updaters||{};g.__tsParticlesInternals.utils=g.__tsParticlesInternals.utils||{};g.__tsParticlesInternals.canvas=g.__tsParticlesInternals.canvas||{};g.__tsParticlesInternals.canvas=g.__tsParticlesInternals.canvas||{};g.__tsParticlesInternals.canvas.utils=g.__tsParticlesInternals.canvas.utils||{};g.__tsParticlesInternals.path=g.__tsParticlesInternals.path||{};g.__tsParticlesInternals.path=g.__tsParticlesInternals.path||{};g.__tsParticlesInternals.path.utils=g.__tsParticlesInternals.path.utils||{};var __tsProxyFactory=typeof Proxy!=="undefined"?function(obj){return new Proxy(obj,{get:function(target,key){if(!(key in target)){target[key]={};}return target[key];}});}:function(obj){return obj;};g.__tsParticlesInternals.bundles=__tsProxyFactory(g.__tsParticlesInternals.bundles);g.__tsParticlesInternals.effects=__tsProxyFactory(g.__tsParticlesInternals.effects);g.__tsParticlesInternals.interactions=__tsProxyFactory(g.__tsParticlesInternals.interactions);g.__tsParticlesInternals.palettes=__tsProxyFactory(g.__tsParticlesInternals.palettes);g.__tsParticlesInternals.paths=__tsProxyFactory(g.__tsParticlesInternals.paths);g.__tsParticlesInternals.plugins=__tsProxyFactory(g.__tsParticlesInternals.plugins);g.__tsParticlesInternals.plugins.emittersShapes=__tsProxyFactory(g.__tsParticlesInternals.plugins.emittersShapes);g.__tsParticlesInternals.presets=__tsProxyFactory(g.__tsParticlesInternals.presets);g.__tsParticlesInternals.shapes=__tsProxyFactory(g.__tsParticlesInternals.shapes);g.__tsParticlesInternals.updaters=__tsProxyFactory(g.__tsParticlesInternals.updaters);g.__tsParticlesInternals.utils=__tsProxyFactory(g.__tsParticlesInternals.utils);g.__tsParticlesInternals.canvas=__tsProxyFactory(g.__tsParticlesInternals.canvas);g.__tsParticlesInternals.path=__tsProxyFactory(g.__tsParticlesInternals.path);g.tsparticlesInternalExports=g.tsparticlesInternalExports||{};})(typeof globalThis!=="undefined"?globalThis:typeof window!=="undefined"?window:this);
|
|
2
|
+
/* Plugin v4.0.0-beta.16 */
|
|
3
|
+
(function (global, factory) {
|
|
4
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tsparticles/engine'), require('@tsparticles/canvas-utils')) :
|
|
5
|
+
typeof define === 'function' && define.amd ? define(['exports', '@tsparticles/engine', '@tsparticles/canvas-utils'], factory) :
|
|
6
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.__tsParticlesInternals = global.__tsParticlesInternals || {}, global.__tsParticlesInternals.plugins = global.__tsParticlesInternals.plugins || {}, global.__tsParticlesInternals.plugins.canvasMask = global.__tsParticlesInternals.plugins.canvasMask || {}), global.__tsParticlesInternals.engine, global.__tsParticlesInternals.canvas.utils));
|
|
7
|
+
})(this, (function (exports, engine, canvasUtils) { 'use strict';
|
|
30
8
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
9
|
+
class CanvasMaskOverride {
|
|
10
|
+
color;
|
|
11
|
+
opacity;
|
|
12
|
+
constructor() {
|
|
13
|
+
this.color = true;
|
|
14
|
+
this.opacity = false;
|
|
15
|
+
}
|
|
16
|
+
load(data) {
|
|
17
|
+
if (engine.isNull(data)) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
if (data.color !== undefined) {
|
|
21
|
+
this.color = data.color;
|
|
22
|
+
}
|
|
23
|
+
if (data.opacity !== undefined) {
|
|
24
|
+
this.opacity = data.opacity;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
36
28
|
|
|
37
|
-
|
|
29
|
+
const minAlpha = 0;
|
|
30
|
+
class CanvasMaskPixels {
|
|
31
|
+
filter;
|
|
32
|
+
offset;
|
|
33
|
+
constructor() {
|
|
34
|
+
this.filter = (pixel) => pixel.a > minAlpha;
|
|
35
|
+
this.offset = 4;
|
|
36
|
+
}
|
|
37
|
+
load(data) {
|
|
38
|
+
if (engine.isNull(data)) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (data.filter !== undefined) {
|
|
42
|
+
if (engine.isString(data.filter)) {
|
|
43
|
+
if (data.filter in globalThis) {
|
|
44
|
+
const filter = globalThis[data.filter];
|
|
45
|
+
if (engine.isFunction(filter)) {
|
|
46
|
+
this.filter = filter;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
this.filter = data.filter;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (data.offset !== undefined) {
|
|
55
|
+
this.offset = data.offset;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
38
59
|
|
|
39
|
-
|
|
60
|
+
class ImageMask {
|
|
61
|
+
src;
|
|
62
|
+
constructor() {
|
|
63
|
+
this.src = "";
|
|
64
|
+
}
|
|
65
|
+
load(data) {
|
|
66
|
+
if (engine.isNull(data)) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (data.src !== undefined) {
|
|
70
|
+
this.src = data.src;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
40
74
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
75
|
+
class FontTextMask {
|
|
76
|
+
family;
|
|
77
|
+
size;
|
|
78
|
+
style;
|
|
79
|
+
variant;
|
|
80
|
+
weight;
|
|
81
|
+
constructor() {
|
|
82
|
+
this.family = "sans-serif";
|
|
83
|
+
this.size = 100;
|
|
84
|
+
this.style = "";
|
|
85
|
+
this.variant = "";
|
|
86
|
+
this.weight = "";
|
|
87
|
+
}
|
|
88
|
+
load(data) {
|
|
89
|
+
if (engine.isNull(data)) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if (data.family !== undefined) {
|
|
93
|
+
this.family = data.family;
|
|
94
|
+
}
|
|
95
|
+
if (data.size !== undefined) {
|
|
96
|
+
this.size = data.size;
|
|
97
|
+
}
|
|
98
|
+
if (data.style !== undefined) {
|
|
99
|
+
this.style = data.style;
|
|
100
|
+
}
|
|
101
|
+
if (data.variant !== undefined) {
|
|
102
|
+
this.variant = data.variant;
|
|
103
|
+
}
|
|
104
|
+
if (data.weight !== undefined) {
|
|
105
|
+
this.weight = data.weight;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
46
109
|
|
|
47
|
-
|
|
110
|
+
class TextMaskLine {
|
|
111
|
+
separator;
|
|
112
|
+
spacing;
|
|
113
|
+
constructor() {
|
|
114
|
+
this.separator = "\n";
|
|
115
|
+
this.spacing = 10;
|
|
116
|
+
}
|
|
117
|
+
load(data) {
|
|
118
|
+
if (engine.isNull(data)) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
if (data.separator !== undefined) {
|
|
122
|
+
this.separator = data.separator;
|
|
123
|
+
}
|
|
124
|
+
if (data.spacing !== undefined) {
|
|
125
|
+
this.spacing = data.spacing;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
48
129
|
|
|
49
|
-
|
|
130
|
+
class TextMask {
|
|
131
|
+
color;
|
|
132
|
+
fill;
|
|
133
|
+
font;
|
|
134
|
+
lines;
|
|
135
|
+
text;
|
|
136
|
+
constructor() {
|
|
137
|
+
this.color = "#000000";
|
|
138
|
+
this.fill = true;
|
|
139
|
+
this.font = new FontTextMask();
|
|
140
|
+
this.lines = new TextMaskLine();
|
|
141
|
+
this.text = "";
|
|
142
|
+
}
|
|
143
|
+
load(data) {
|
|
144
|
+
if (engine.isNull(data)) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
if (data.color !== undefined) {
|
|
148
|
+
this.color = data.color;
|
|
149
|
+
}
|
|
150
|
+
if (data.fill !== undefined) {
|
|
151
|
+
this.fill = data.fill;
|
|
152
|
+
}
|
|
153
|
+
this.font.load(data.font);
|
|
154
|
+
this.lines.load(data.lines);
|
|
155
|
+
if (data.text !== undefined) {
|
|
156
|
+
this.text = data.text;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
50
160
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
161
|
+
class CanvasMask {
|
|
162
|
+
element;
|
|
163
|
+
enable;
|
|
164
|
+
image;
|
|
165
|
+
override;
|
|
166
|
+
pixels;
|
|
167
|
+
position;
|
|
168
|
+
scale;
|
|
169
|
+
selector;
|
|
170
|
+
text;
|
|
171
|
+
constructor() {
|
|
172
|
+
this.enable = false;
|
|
173
|
+
this.override = new CanvasMaskOverride();
|
|
174
|
+
this.pixels = new CanvasMaskPixels();
|
|
175
|
+
this.position = {
|
|
176
|
+
x: 50,
|
|
177
|
+
y: 50,
|
|
178
|
+
};
|
|
179
|
+
this.scale = 1;
|
|
180
|
+
}
|
|
181
|
+
load(data) {
|
|
182
|
+
if (engine.isNull(data)) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
if (data.element !== undefined && data.element instanceof HTMLCanvasElement) {
|
|
186
|
+
this.element = data.element;
|
|
187
|
+
}
|
|
188
|
+
if (data.enable !== undefined) {
|
|
189
|
+
this.enable = data.enable;
|
|
190
|
+
}
|
|
191
|
+
if (data.image) {
|
|
192
|
+
this.image ??= new ImageMask();
|
|
193
|
+
this.image.load(data.image);
|
|
194
|
+
}
|
|
195
|
+
this.pixels.load(data.pixels);
|
|
196
|
+
if (data.position) {
|
|
197
|
+
this.position = {
|
|
198
|
+
x: data.position.x ?? this.position.x,
|
|
199
|
+
y: data.position.y ?? this.position.y,
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
this.override.load(data.override);
|
|
203
|
+
if (data.scale !== undefined) {
|
|
204
|
+
this.scale = data.scale;
|
|
205
|
+
}
|
|
206
|
+
if (data.selector !== undefined) {
|
|
207
|
+
this.selector = data.selector;
|
|
208
|
+
}
|
|
209
|
+
if (data.text) {
|
|
210
|
+
this.text ??= new TextMask();
|
|
211
|
+
this.text.load(data.text);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
56
215
|
|
|
57
|
-
|
|
216
|
+
class CanvasMaskPlugin {
|
|
217
|
+
id = "canvas-mask";
|
|
218
|
+
async getPlugin(container) {
|
|
219
|
+
const { CanvasMaskPluginInstance } = await Promise.resolve().then(function () { return CanvasMaskPluginInstance$1; });
|
|
220
|
+
return new CanvasMaskPluginInstance(container);
|
|
221
|
+
}
|
|
222
|
+
loadOptions(_container, options, source) {
|
|
223
|
+
if (!this.needsPlugin(options) && !this.needsPlugin(source)) {
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
let canvasMaskOptions = options.canvasMask;
|
|
227
|
+
if (canvasMaskOptions?.load === undefined) {
|
|
228
|
+
options.canvasMask = canvasMaskOptions = new CanvasMask();
|
|
229
|
+
}
|
|
230
|
+
canvasMaskOptions.load(source?.canvasMask);
|
|
231
|
+
}
|
|
232
|
+
needsPlugin(options) {
|
|
233
|
+
return options?.canvasMask?.enable ?? false;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
58
236
|
|
|
59
|
-
|
|
237
|
+
async function loadCanvasMaskPlugin(engine) {
|
|
238
|
+
engine.checkVersion("4.0.0-beta.16");
|
|
239
|
+
await engine.pluginManager.register(e => {
|
|
240
|
+
e.pluginManager.addPlugin(new CanvasMaskPlugin());
|
|
241
|
+
});
|
|
242
|
+
}
|
|
60
243
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
/******/ doneFns && doneFns.forEach((fn) => (fn(event)));
|
|
184
|
-
/******/ if(prev) return prev(event);
|
|
185
|
-
/******/ }
|
|
186
|
-
/******/ var timeout = setTimeout(onScriptComplete.bind(null, undefined, { type: 'timeout', target: script }), 120000);
|
|
187
|
-
/******/ script.onerror = onScriptComplete.bind(null, script.onerror);
|
|
188
|
-
/******/ script.onload = onScriptComplete.bind(null, script.onload);
|
|
189
|
-
/******/ needAttach && document.head.appendChild(script);
|
|
190
|
-
/******/ };
|
|
191
|
-
/******/ })();
|
|
192
|
-
/******/
|
|
193
|
-
/******/ /* webpack/runtime/make namespace object */
|
|
194
|
-
/******/ (() => {
|
|
195
|
-
/******/ // define __esModule on exports
|
|
196
|
-
/******/ __webpack_require__.r = (exports) => {
|
|
197
|
-
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
198
|
-
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
199
|
-
/******/ }
|
|
200
|
-
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
201
|
-
/******/ };
|
|
202
|
-
/******/ })();
|
|
203
|
-
/******/
|
|
204
|
-
/******/ /* webpack/runtime/publicPath */
|
|
205
|
-
/******/ (() => {
|
|
206
|
-
/******/ var scriptUrl;
|
|
207
|
-
/******/ if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + "";
|
|
208
|
-
/******/ var document = __webpack_require__.g.document;
|
|
209
|
-
/******/ if (!scriptUrl && document) {
|
|
210
|
-
/******/ if (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT')
|
|
211
|
-
/******/ scriptUrl = document.currentScript.src;
|
|
212
|
-
/******/ if (!scriptUrl) {
|
|
213
|
-
/******/ var scripts = document.getElementsByTagName("script");
|
|
214
|
-
/******/ if(scripts.length) {
|
|
215
|
-
/******/ var i = scripts.length - 1;
|
|
216
|
-
/******/ while (i > -1 && (!scriptUrl || !/^http(s?):/.test(scriptUrl))) scriptUrl = scripts[i--].src;
|
|
217
|
-
/******/ }
|
|
218
|
-
/******/ }
|
|
219
|
-
/******/ }
|
|
220
|
-
/******/ // When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration
|
|
221
|
-
/******/ // or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.
|
|
222
|
-
/******/ if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser");
|
|
223
|
-
/******/ scriptUrl = scriptUrl.replace(/^blob:/, "").replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/");
|
|
224
|
-
/******/ __webpack_require__.p = scriptUrl;
|
|
225
|
-
/******/ })();
|
|
226
|
-
/******/
|
|
227
|
-
/******/ /* webpack/runtime/jsonp chunk loading */
|
|
228
|
-
/******/ (() => {
|
|
229
|
-
/******/ // no baseURI
|
|
230
|
-
/******/
|
|
231
|
-
/******/ // object to store loaded and loading chunks
|
|
232
|
-
/******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
|
|
233
|
-
/******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded
|
|
234
|
-
/******/ var installedChunks = {
|
|
235
|
-
/******/ "tsparticles.plugin.canvas-mask": 0
|
|
236
|
-
/******/ };
|
|
237
|
-
/******/
|
|
238
|
-
/******/ __webpack_require__.f.j = (chunkId, promises) => {
|
|
239
|
-
/******/ // JSONP chunk loading for javascript
|
|
240
|
-
/******/ var installedChunkData = __webpack_require__.o(installedChunks, chunkId) ? installedChunks[chunkId] : undefined;
|
|
241
|
-
/******/ if(installedChunkData !== 0) { // 0 means "already installed".
|
|
242
|
-
/******/
|
|
243
|
-
/******/ // a Promise means "currently loading".
|
|
244
|
-
/******/ if(installedChunkData) {
|
|
245
|
-
/******/ promises.push(installedChunkData[2]);
|
|
246
|
-
/******/ } else {
|
|
247
|
-
/******/ if(true) { // all chunks have JS
|
|
248
|
-
/******/ // setup Promise in chunk cache
|
|
249
|
-
/******/ var promise = new Promise((resolve, reject) => (installedChunkData = installedChunks[chunkId] = [resolve, reject]));
|
|
250
|
-
/******/ promises.push(installedChunkData[2] = promise);
|
|
251
|
-
/******/
|
|
252
|
-
/******/ // start chunk loading
|
|
253
|
-
/******/ var url = __webpack_require__.p + __webpack_require__.u(chunkId);
|
|
254
|
-
/******/ // create error before stack unwound to get useful stacktrace later
|
|
255
|
-
/******/ var error = new Error();
|
|
256
|
-
/******/ var loadingEnded = (event) => {
|
|
257
|
-
/******/ if(__webpack_require__.o(installedChunks, chunkId)) {
|
|
258
|
-
/******/ installedChunkData = installedChunks[chunkId];
|
|
259
|
-
/******/ if(installedChunkData !== 0) installedChunks[chunkId] = undefined;
|
|
260
|
-
/******/ if(installedChunkData) {
|
|
261
|
-
/******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type);
|
|
262
|
-
/******/ var realSrc = event && event.target && event.target.src;
|
|
263
|
-
/******/ error.message = 'Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')';
|
|
264
|
-
/******/ error.name = 'ChunkLoadError';
|
|
265
|
-
/******/ error.type = errorType;
|
|
266
|
-
/******/ error.request = realSrc;
|
|
267
|
-
/******/ installedChunkData[1](error);
|
|
268
|
-
/******/ }
|
|
269
|
-
/******/ }
|
|
270
|
-
/******/ };
|
|
271
|
-
/******/ __webpack_require__.l(url, loadingEnded, "chunk-" + chunkId, chunkId);
|
|
272
|
-
/******/ }
|
|
273
|
-
/******/ }
|
|
274
|
-
/******/ }
|
|
275
|
-
/******/ };
|
|
276
|
-
/******/
|
|
277
|
-
/******/ // no prefetching
|
|
278
|
-
/******/
|
|
279
|
-
/******/ // no preloaded
|
|
280
|
-
/******/
|
|
281
|
-
/******/ // no HMR
|
|
282
|
-
/******/
|
|
283
|
-
/******/ // no HMR manifest
|
|
284
|
-
/******/
|
|
285
|
-
/******/ // no on chunks loaded
|
|
286
|
-
/******/
|
|
287
|
-
/******/ // install a JSONP callback for chunk loading
|
|
288
|
-
/******/ var webpackJsonpCallback = (parentChunkLoadingFunction, data) => {
|
|
289
|
-
/******/ var [chunkIds, moreModules, runtime] = data;
|
|
290
|
-
/******/ // add "moreModules" to the modules object,
|
|
291
|
-
/******/ // then flag all "chunkIds" as loaded and fire callback
|
|
292
|
-
/******/ var moduleId, chunkId, i = 0;
|
|
293
|
-
/******/ if(chunkIds.some((id) => (installedChunks[id] !== 0))) {
|
|
294
|
-
/******/ for(moduleId in moreModules) {
|
|
295
|
-
/******/ if(__webpack_require__.o(moreModules, moduleId)) {
|
|
296
|
-
/******/ __webpack_require__.m[moduleId] = moreModules[moduleId];
|
|
297
|
-
/******/ }
|
|
298
|
-
/******/ }
|
|
299
|
-
/******/ if(runtime) var result = runtime(__webpack_require__);
|
|
300
|
-
/******/ }
|
|
301
|
-
/******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data);
|
|
302
|
-
/******/ for(;i < chunkIds.length; i++) {
|
|
303
|
-
/******/ chunkId = chunkIds[i];
|
|
304
|
-
/******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {
|
|
305
|
-
/******/ installedChunks[chunkId][0]();
|
|
306
|
-
/******/ }
|
|
307
|
-
/******/ installedChunks[chunkId] = 0;
|
|
308
|
-
/******/ }
|
|
309
|
-
/******/
|
|
310
|
-
/******/ }
|
|
311
|
-
/******/
|
|
312
|
-
/******/ var chunkLoadingGlobal = this["webpackChunk_tsparticles_plugin_canvas_mask"] = this["webpackChunk_tsparticles_plugin_canvas_mask"] || [];
|
|
313
|
-
/******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));
|
|
314
|
-
/******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));
|
|
315
|
-
/******/ })();
|
|
316
|
-
/******/
|
|
317
|
-
/************************************************************************/
|
|
318
|
-
/******/
|
|
319
|
-
/******/ // startup
|
|
320
|
-
/******/ // Load entry module and return exports
|
|
321
|
-
/******/ // This entry module can't be inlined because the eval devtool is used.
|
|
322
|
-
/******/ var __webpack_exports__ = __webpack_require__("./dist/browser/index.js");
|
|
323
|
-
/******/
|
|
324
|
-
/******/ return __webpack_exports__;
|
|
325
|
-
/******/ })()
|
|
326
|
-
;
|
|
327
|
-
});
|
|
244
|
+
const globalObject = globalThis;
|
|
245
|
+
globalObject.__tsParticlesInternals = globalObject.__tsParticlesInternals ?? {};
|
|
246
|
+
globalObject.loadCanvasMaskPlugin = loadCanvasMaskPlugin;
|
|
247
|
+
|
|
248
|
+
function addParticlesFromCanvasPixels(container, data, position, scale, override, filter) {
|
|
249
|
+
const { height, width } = data, numPixels = height * width, indexArray = shuffle(range(numPixels)), maxParticles = Math.min(numPixels, container.actualOptions.particles.number.value), canvasSize = container.canvas.size;
|
|
250
|
+
let selectedPixels = 0;
|
|
251
|
+
const positionOffset = {
|
|
252
|
+
x: (canvasSize.width * position.x) / engine.percentDenominator - width * scale * engine.half,
|
|
253
|
+
y: (canvasSize.height * position.y) / engine.percentDenominator - height * scale * engine.half,
|
|
254
|
+
};
|
|
255
|
+
while (selectedPixels < maxParticles && indexArray.length) {
|
|
256
|
+
const defaultIndex = 0, nextIndex = indexArray.pop() ?? defaultIndex, pixelPos = {
|
|
257
|
+
x: nextIndex % width,
|
|
258
|
+
y: Math.floor(nextIndex / width),
|
|
259
|
+
}, row = data.pixels[pixelPos.y];
|
|
260
|
+
if (!row) {
|
|
261
|
+
continue;
|
|
262
|
+
}
|
|
263
|
+
const pixel = row[pixelPos.x];
|
|
264
|
+
if (!pixel) {
|
|
265
|
+
continue;
|
|
266
|
+
}
|
|
267
|
+
const shouldCreateParticle = filter(pixel);
|
|
268
|
+
if (!shouldCreateParticle) {
|
|
269
|
+
continue;
|
|
270
|
+
}
|
|
271
|
+
const pos = {
|
|
272
|
+
x: pixelPos.x * scale + positionOffset.x,
|
|
273
|
+
y: pixelPos.y * scale + positionOffset.y,
|
|
274
|
+
}, pOptions = {};
|
|
275
|
+
if (override.color) {
|
|
276
|
+
pOptions.paint = {
|
|
277
|
+
fill: {
|
|
278
|
+
color: {
|
|
279
|
+
value: pixel,
|
|
280
|
+
},
|
|
281
|
+
enable: true,
|
|
282
|
+
},
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
if (override.opacity) {
|
|
286
|
+
pOptions.opacity = {
|
|
287
|
+
value: pixel.a,
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
container.particles.addParticle(pos, pOptions);
|
|
291
|
+
selectedPixels++;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
function shuffle(array) {
|
|
295
|
+
const lengthOffset = 1, minIndex = 0;
|
|
296
|
+
for (let currentIndex = array.length - lengthOffset; currentIndex >= minIndex; currentIndex--) {
|
|
297
|
+
const randomIndex = Math.floor(engine.getRandom() * currentIndex), currentItem = array[currentIndex], randomItem = array[randomIndex];
|
|
298
|
+
if (randomItem === currentItem) {
|
|
299
|
+
continue;
|
|
300
|
+
}
|
|
301
|
+
if (randomItem === undefined || currentItem === undefined) {
|
|
302
|
+
continue;
|
|
303
|
+
}
|
|
304
|
+
array[currentIndex] = randomItem;
|
|
305
|
+
array[randomIndex] = currentItem;
|
|
306
|
+
}
|
|
307
|
+
return array;
|
|
308
|
+
}
|
|
309
|
+
const range = (n) => [...Array(n).keys()];
|
|
310
|
+
|
|
311
|
+
class CanvasMaskPluginInstance {
|
|
312
|
+
_container;
|
|
313
|
+
constructor(container) {
|
|
314
|
+
this._container = container;
|
|
315
|
+
}
|
|
316
|
+
async init() {
|
|
317
|
+
const container = this._container, options = container.actualOptions.canvasMask;
|
|
318
|
+
if (!options?.enable) {
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
let pixelData = {
|
|
322
|
+
pixels: [],
|
|
323
|
+
height: 0,
|
|
324
|
+
width: 0,
|
|
325
|
+
};
|
|
326
|
+
const offset = options.pixels.offset;
|
|
327
|
+
if (options.image) {
|
|
328
|
+
const url = options.image.src;
|
|
329
|
+
if (!url) {
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
pixelData = await canvasUtils.getImageData(url, offset, container.canvas.render.settings);
|
|
333
|
+
}
|
|
334
|
+
else if (options.text) {
|
|
335
|
+
const textOptions = options.text, data = canvasUtils.getTextData(textOptions, offset, textOptions.fill, container.canvas.render.settings);
|
|
336
|
+
if (engine.isNull(data)) {
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
pixelData = data;
|
|
340
|
+
}
|
|
341
|
+
else if (options.element ?? options.selector) {
|
|
342
|
+
const canvas = options.element ?? (options.selector && engine.safeDocument().querySelector(options.selector));
|
|
343
|
+
if (!canvas) {
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
const context = canvas.getContext("2d", container.canvas.render.settings);
|
|
347
|
+
if (!context) {
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
pixelData = canvasUtils.getCanvasImageData(context, canvas, offset);
|
|
351
|
+
}
|
|
352
|
+
addParticlesFromCanvasPixels(container, pixelData, options.position, options.scale, options.override, options.pixels.filter);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
var CanvasMaskPluginInstance$1 = /*#__PURE__*/Object.freeze({
|
|
357
|
+
__proto__: null,
|
|
358
|
+
CanvasMaskPluginInstance: CanvasMaskPluginInstance
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
exports.loadCanvasMaskPlugin = loadCanvasMaskPlugin;
|
|
362
|
+
|
|
363
|
+
}));
|
|
364
|
+
Object.assign(globalThis.window || globalThis, { loadCanvasMaskPlugin: (globalThis.__tsParticlesInternals.plugins.canvasMask || {}).loadCanvasMaskPlugin });
|
|
365
|
+
delete (globalThis.window || globalThis).tsparticlesInternalExports;
|