@tsparticles/plugin-emitters-shape-canvas 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/720.min.js ADDED
@@ -0,0 +1,2 @@
1
+ /*! For license information please see 720.min.js.LICENSE.txt */
2
+ (this.webpackChunk_tsparticles_plugin_emitters_shape_canvas=this.webpackChunk_tsparticles_plugin_emitters_shape_canvas||[]).push([[720],{720:(t,e,i)=>{i.d(e,{EmittersCanvasShapeGenerator:()=>g});var s=i(68),o=i(533);const n={x:0,y:0};function a(t,e,i,s=!0){const o=t.getImageData(n.x,n.y,e.width,e.height).data;s&&t.clearRect(n.x,n.y,e.width,e.height);const a=[];for(let t=0;t<o.length;t+=i){const s=t/i,n={x:s%e.width,y:Math.floor(s/e.width)};a[n.y]||(a[n.y]=[]);const r={r:0,g:1,b:2,a:3},l=255;a[n.y][n.x]={r:o[t+r.r],g:o[t+r.g],b:o[t+r.b],a:o[t+r.a]/l}}return{pixels:a,width:Math.min(...a.map((t=>t.length))),height:a.length}}class r extends s.EmitterShapeBase{constructor(t,e,i,s){super(t,e,i,s);const n=s.filter;let a=t=>t.a>0;if(void 0!==n)if((0,o.isString)(n)){if(Object.hasOwn(window,n)){const t=window[n];(0,o.isFunction)(t)&&(a=t)}}else a=n;this.filter=a,this.scale=s.scale,this.pixelData={pixels:[],height:0,width:0}}async init(){let t;const e=this.options,i=e.selector,s=e.pixels,r=e.image,l=e.element,h=e.text,c=s.offset;if(r){const e=r.src;if(!e)return;t=await function(t,e){const i=new Image;i.crossOrigin="Anonymous";const s=new Promise(((t,s)=>{i.onerror=s,i.onload=()=>{const r=document.createElement("canvas");r.width=i.width,r.height=i.height;const l=r.getContext("2d");if(!l)return s(new Error(`${o.errorPrefix} Could not get canvas context`));l.drawImage(i,n.x,n.y,i.width,i.height,n.x,n.y,r.width,r.height),t(a(l,r,e))}}));return i.src=t,s}(e,c)}else if(h){const e=function(t,e,i){const s=document.createElement("canvas"),r=s.getContext("2d"),{font:l,text:h,lines:c,color:d}=t;if(!h||!r)return;const f=h.split(c.separator),g=(0,o.isNumber)(l.size)?`${l.size}px`:l.size,x=[];let u=0,p=0;for(const t of f){r.font=`${l.style||""} ${l.variant||""} ${l.weight||""} ${g} ${l.family}`;const e=r.measureText(t),i={measure:e,text:t,height:e.actualBoundingBoxAscent+e.actualBoundingBoxDescent,width:e.width};u=Math.max(u||0,i.width),p+=i.height+c.spacing,x.push(i)}s.width=u,s.height=p;let m=0;for(const t of x)r.font=`${l.style||""} ${l.variant||""} ${l.weight||""} ${g} ${l.family}`,i?(r.fillStyle=d,r.fillText(t.text,n.x,m+t.measure.actualBoundingBoxAscent)):(r.strokeStyle=d,r.strokeText(t.text,n.x,m+t.measure.actualBoundingBoxAscent)),m+=t.height+c.spacing;return a(r,s,e)}(h,c,this.fill);if(!e)return;t=e}else if(l??i){const e=l??(i&&document.querySelector(i));if(!e)return;const s=e.getContext("2d");if(!s)return;t=a(s,e,c)}t&&(this.pixelData=t)}async randomPosition(){const{height:t,width:e}=this.pixelData,i=this.pixelData,s=this.position,n=this.scale,a=s.x-e*n*.5,r=s.y-t*n*.5;for(let s=0;s<100;s++){const s=Math.floor((0,o.getRandom)()*e*t),l={x:s%e,y:Math.floor(s/e)},h=i.pixels[l.y][l.x];if(this.filter(h))return Promise.resolve({position:{x:l.x*n+a,y:l.y*n+r},color:{...h},opacity:h.a})}return Promise.resolve(null)}resize(t,e){super.resize(t,e)}}class l{constructor(){this.offset=4}load(t){t&&void 0!==t.offset&&(this.offset=t.offset)}}class h{constructor(){this.family="Verdana",this.size=32,this.style="",this.variant="",this.weight=""}load(t){t&&(void 0!==t.family&&(this.family=t.family),void 0!==t.size&&(this.size=t.size),void 0!==t.style&&(this.style=t.style),void 0!==t.variant&&(this.variant=t.variant),void 0!==t.weight&&(this.weight=t.weight))}}class c{constructor(){this.separator="\n",this.spacing=0}load(t){t&&(void 0!==t.separator&&(this.separator=t.separator),void 0!==t.spacing&&(this.spacing=t.spacing))}}class d{constructor(){this.color="#000000",this.font=new h,this.lines=new c,this.text=""}load(t){t&&(void 0!==t.color&&(this.color=t.color),this.font.load(t.font),this.lines.load(t.lines),void 0!==t.text&&(this.text=t.text))}}class f{constructor(){this.filter=t=>t.a>0,this.pixels=new l,this.scale=1,this.selector="",this.text=new d}load(t){t&&(void 0!==t.element&&(this.element=t.element),void 0!==t.filter&&(this.filter=t.filter),this.pixels.load(t.pixels),void 0!==t.scale&&(this.scale=t.scale),void 0!==t.selector&&(this.selector=t.selector),void 0!==t.image&&(this.image=t.image),this.text.load(t.text))}}class g{generate(t,e,i,s){const o=new f;return o.load(s),new r(t,e,i,o)}}}}]);
@@ -0,0 +1 @@
1
+ /*! tsParticles Emitters Shape Canvas Plugin v3.2.0 by Matteo Bruni */
package/browser/index.js CHANGED
@@ -1,6 +1,5 @@
1
- import { EmittersCanvasShapeGenerator } from "./EmittersCanvasShapeGenerator.js";
2
1
  export async function loadEmittersShapeCanvas(engine, refresh = true) {
3
- const emittersEngine = engine;
2
+ const emittersEngine = engine, { EmittersCanvasShapeGenerator } = await import("./EmittersCanvasShapeGenerator.js");
4
3
  emittersEngine.addEmitterShapeGenerator?.("canvas", new EmittersCanvasShapeGenerator());
5
4
  await emittersEngine.refresh(refresh);
6
5
  }
package/cjs/index.js CHANGED
@@ -1,10 +1,32 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  Object.defineProperty(exports, "__esModule", { value: true });
3
26
  exports.loadEmittersShapeCanvas = void 0;
4
- const EmittersCanvasShapeGenerator_js_1 = require("./EmittersCanvasShapeGenerator.js");
5
27
  async function loadEmittersShapeCanvas(engine, refresh = true) {
6
- const emittersEngine = engine;
7
- emittersEngine.addEmitterShapeGenerator?.("canvas", new EmittersCanvasShapeGenerator_js_1.EmittersCanvasShapeGenerator());
28
+ const emittersEngine = engine, { EmittersCanvasShapeGenerator } = await Promise.resolve().then(() => __importStar(require("./EmittersCanvasShapeGenerator.js")));
29
+ emittersEngine.addEmitterShapeGenerator?.("canvas", new EmittersCanvasShapeGenerator());
8
30
  await emittersEngine.refresh(refresh);
9
31
  }
10
32
  exports.loadEmittersShapeCanvas = loadEmittersShapeCanvas;
@@ -0,0 +1,100 @@
1
+ /*!
2
+ * Author : Matteo Bruni
3
+ * MIT license: https://opensource.org/licenses/MIT
4
+ * Demo / Generator : https://particles.js.org/
5
+ * GitHub : https://www.github.com/matteobruni/tsparticles
6
+ * How to use? : Check the GitHub README
7
+ * v3.2.0
8
+ */
9
+ "use strict";
10
+ /*
11
+ * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
12
+ * This devtool is neither made for production nor for readable output files.
13
+ * It uses "eval()" calls to create a separate source file in the browser devtools.
14
+ * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
15
+ * or disable the default devtool with "devtool: false".
16
+ * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
17
+ */
18
+ (this["webpackChunk_tsparticles_plugin_emitters_shape_canvas"] = this["webpackChunk_tsparticles_plugin_emitters_shape_canvas"] || []).push([["dist_browser_EmittersCanvasShapeGenerator_js"],{
19
+
20
+ /***/ "./dist/browser/EmittersCanvasShape.js":
21
+ /*!*********************************************!*\
22
+ !*** ./dist/browser/EmittersCanvasShape.js ***!
23
+ \*********************************************/
24
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
25
+
26
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ EmittersCanvasShape: () => (/* binding */ EmittersCanvasShape)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_plugin_emitters__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/plugin-emitters */ \"@tsparticles/plugin-emitters\");\n/* harmony import */ var _tsparticles_plugin_emitters__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_plugin_emitters__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./utils.js */ \"./dist/browser/utils.js\");\n\n\n\nconst maxRetries = 100,\n half = 0.5;\nclass EmittersCanvasShape extends _tsparticles_plugin_emitters__WEBPACK_IMPORTED_MODULE_0__.EmitterShapeBase {\n constructor(position, size, fill, options) {\n super(position, size, fill, options);\n const filter = options.filter,\n minAlpha = 0;\n let filterFunc = pixel => pixel.a > minAlpha;\n if (filter !== undefined) {\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.isString)(filter)) {\n if (Object.hasOwn(window, filter)) {\n const wndFilter = window[filter];\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.isFunction)(wndFilter)) {\n filterFunc = wndFilter;\n }\n }\n } else {\n filterFunc = filter;\n }\n }\n this.filter = filterFunc;\n this.scale = options.scale;\n this.pixelData = {\n pixels: [],\n height: 0,\n width: 0\n };\n }\n async init() {\n let pixelData;\n const options = this.options,\n selector = options.selector,\n pixels = options.pixels,\n image = options.image,\n element = options.element,\n text = options.text,\n offset = pixels.offset;\n if (image) {\n const url = image.src;\n if (!url) {\n return;\n }\n pixelData = await (0,_utils_js__WEBPACK_IMPORTED_MODULE_2__.getImageData)(url, offset);\n } else if (text) {\n const data = (0,_utils_js__WEBPACK_IMPORTED_MODULE_2__.getTextData)(text, offset, this.fill);\n if (!data) {\n return;\n }\n pixelData = data;\n } else if (element ?? selector) {\n const canvas = element ?? (selector && document.querySelector(selector));\n if (!canvas) {\n return;\n }\n const context = canvas.getContext(\"2d\");\n if (!context) {\n return;\n }\n pixelData = (0,_utils_js__WEBPACK_IMPORTED_MODULE_2__.getCanvasImageData)(context, canvas, offset);\n }\n if (!pixelData) {\n return;\n }\n this.pixelData = pixelData;\n }\n async randomPosition() {\n const {\n height,\n width\n } = this.pixelData,\n data = this.pixelData,\n position = this.position,\n scale = this.scale,\n positionOffset = {\n x: position.x - width * scale * half,\n y: position.y - height * scale * half\n };\n for (let i = 0; i < maxRetries; i++) {\n const nextIndex = Math.floor((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.getRandom)() * width * height),\n pixelPos = {\n x: nextIndex % width,\n y: Math.floor(nextIndex / width)\n },\n pixel = data.pixels[pixelPos.y][pixelPos.x],\n shouldCreateParticle = this.filter(pixel);\n if (!shouldCreateParticle) {\n continue;\n }\n return Promise.resolve({\n position: {\n x: pixelPos.x * scale + positionOffset.x,\n y: pixelPos.y * scale + positionOffset.y\n },\n color: {\n ...pixel\n },\n opacity: pixel.a\n });\n }\n return Promise.resolve(null);\n }\n resize(position, size) {\n super.resize(position, size);\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-emitters-shape-canvas/./dist/browser/EmittersCanvasShape.js?");
27
+
28
+ /***/ }),
29
+
30
+ /***/ "./dist/browser/EmittersCanvasShapeGenerator.js":
31
+ /*!******************************************************!*\
32
+ !*** ./dist/browser/EmittersCanvasShapeGenerator.js ***!
33
+ \******************************************************/
34
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
35
+
36
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ EmittersCanvasShapeGenerator: () => (/* binding */ EmittersCanvasShapeGenerator)\n/* harmony export */ });\n/* harmony import */ var _EmittersCanvasShape_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./EmittersCanvasShape.js */ \"./dist/browser/EmittersCanvasShape.js\");\n/* harmony import */ var _Options_Classes_EmittersCanvasShapeOptions_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Options/Classes/EmittersCanvasShapeOptions.js */ \"./dist/browser/Options/Classes/EmittersCanvasShapeOptions.js\");\n\n\nclass EmittersCanvasShapeGenerator {\n generate(position, size, fill, options) {\n const shapeOptions = new _Options_Classes_EmittersCanvasShapeOptions_js__WEBPACK_IMPORTED_MODULE_0__.EmittersCanvasShapeOptions();\n shapeOptions.load(options);\n return new _EmittersCanvasShape_js__WEBPACK_IMPORTED_MODULE_1__.EmittersCanvasShape(position, size, fill, shapeOptions);\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-emitters-shape-canvas/./dist/browser/EmittersCanvasShapeGenerator.js?");
37
+
38
+ /***/ }),
39
+
40
+ /***/ "./dist/browser/Options/Classes/EmittersCanvasShapeOptions.js":
41
+ /*!********************************************************************!*\
42
+ !*** ./dist/browser/Options/Classes/EmittersCanvasShapeOptions.js ***!
43
+ \********************************************************************/
44
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
45
+
46
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ EmittersCanvasShapeOptions: () => (/* binding */ EmittersCanvasShapeOptions)\n/* harmony export */ });\n/* harmony import */ var _PixelsOptions_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./PixelsOptions.js */ \"./dist/browser/Options/Classes/PixelsOptions.js\");\n/* harmony import */ var _TextOptions_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./TextOptions.js */ \"./dist/browser/Options/Classes/TextOptions.js\");\n\n\nconst minAlpha = 0;\nclass EmittersCanvasShapeOptions {\n constructor() {\n this.filter = pixel => pixel.a > minAlpha;\n this.pixels = new _PixelsOptions_js__WEBPACK_IMPORTED_MODULE_0__.PixelsOptions();\n this.scale = 1;\n this.selector = \"\";\n this.text = new _TextOptions_js__WEBPACK_IMPORTED_MODULE_1__.TextOptions();\n }\n load(data) {\n if (!data) {\n return;\n }\n if (data.element !== undefined) {\n this.element = data.element;\n }\n if (data.filter !== undefined) {\n this.filter = data.filter;\n }\n this.pixels.load(data.pixels);\n if (data.scale !== undefined) {\n this.scale = data.scale;\n }\n if (data.selector !== undefined) {\n this.selector = data.selector;\n }\n if (data.image !== undefined) {\n this.image = data.image;\n }\n this.text.load(data.text);\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-emitters-shape-canvas/./dist/browser/Options/Classes/EmittersCanvasShapeOptions.js?");
47
+
48
+ /***/ }),
49
+
50
+ /***/ "./dist/browser/Options/Classes/PixelsOptions.js":
51
+ /*!*******************************************************!*\
52
+ !*** ./dist/browser/Options/Classes/PixelsOptions.js ***!
53
+ \*******************************************************/
54
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
55
+
56
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PixelsOptions: () => (/* binding */ PixelsOptions)\n/* harmony export */ });\nclass PixelsOptions {\n constructor() {\n this.offset = 4;\n }\n load(data) {\n if (!data) {\n return;\n }\n if (data.offset !== undefined) {\n this.offset = data.offset;\n }\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-emitters-shape-canvas/./dist/browser/Options/Classes/PixelsOptions.js?");
57
+
58
+ /***/ }),
59
+
60
+ /***/ "./dist/browser/Options/Classes/TextFontOptions.js":
61
+ /*!*********************************************************!*\
62
+ !*** ./dist/browser/Options/Classes/TextFontOptions.js ***!
63
+ \*********************************************************/
64
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
65
+
66
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ TextFontOptions: () => (/* binding */ TextFontOptions)\n/* harmony export */ });\nclass TextFontOptions {\n constructor() {\n this.family = \"Verdana\";\n this.size = 32;\n this.style = \"\";\n this.variant = \"\";\n this.weight = \"\";\n }\n load(data) {\n if (!data) {\n return;\n }\n if (data.family !== undefined) {\n this.family = data.family;\n }\n if (data.size !== undefined) {\n this.size = data.size;\n }\n if (data.style !== undefined) {\n this.style = data.style;\n }\n if (data.variant !== undefined) {\n this.variant = data.variant;\n }\n if (data.weight !== undefined) {\n this.weight = data.weight;\n }\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-emitters-shape-canvas/./dist/browser/Options/Classes/TextFontOptions.js?");
67
+
68
+ /***/ }),
69
+
70
+ /***/ "./dist/browser/Options/Classes/TextLinesOptions.js":
71
+ /*!**********************************************************!*\
72
+ !*** ./dist/browser/Options/Classes/TextLinesOptions.js ***!
73
+ \**********************************************************/
74
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
75
+
76
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ TextLinesOptions: () => (/* binding */ TextLinesOptions)\n/* harmony export */ });\nclass TextLinesOptions {\n constructor() {\n this.separator = \"\\n\";\n this.spacing = 0;\n }\n load(data) {\n if (!data) {\n return;\n }\n if (data.separator !== undefined) {\n this.separator = data.separator;\n }\n if (data.spacing !== undefined) {\n this.spacing = data.spacing;\n }\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-emitters-shape-canvas/./dist/browser/Options/Classes/TextLinesOptions.js?");
77
+
78
+ /***/ }),
79
+
80
+ /***/ "./dist/browser/Options/Classes/TextOptions.js":
81
+ /*!*****************************************************!*\
82
+ !*** ./dist/browser/Options/Classes/TextOptions.js ***!
83
+ \*****************************************************/
84
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
85
+
86
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ TextOptions: () => (/* binding */ TextOptions)\n/* harmony export */ });\n/* harmony import */ var _TextFontOptions_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./TextFontOptions.js */ \"./dist/browser/Options/Classes/TextFontOptions.js\");\n/* harmony import */ var _TextLinesOptions_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./TextLinesOptions.js */ \"./dist/browser/Options/Classes/TextLinesOptions.js\");\n\n\nclass TextOptions {\n constructor() {\n this.color = \"#000000\";\n this.font = new _TextFontOptions_js__WEBPACK_IMPORTED_MODULE_0__.TextFontOptions();\n this.lines = new _TextLinesOptions_js__WEBPACK_IMPORTED_MODULE_1__.TextLinesOptions();\n this.text = \"\";\n }\n load(data) {\n if (!data) {\n return;\n }\n if (data.color !== undefined) {\n this.color = data.color;\n }\n this.font.load(data.font);\n this.lines.load(data.lines);\n if (data.text !== undefined) {\n this.text = data.text;\n }\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-emitters-shape-canvas/./dist/browser/Options/Classes/TextOptions.js?");
87
+
88
+ /***/ }),
89
+
90
+ /***/ "./dist/browser/utils.js":
91
+ /*!*******************************!*\
92
+ !*** ./dist/browser/utils.js ***!
93
+ \*******************************/
94
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
95
+
96
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ getCanvasImageData: () => (/* binding */ getCanvasImageData),\n/* harmony export */ getImageData: () => (/* binding */ getImageData),\n/* harmony export */ getTextData: () => (/* binding */ getTextData)\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 origin = {\n x: 0,\n y: 0\n },\n minWidth = 0;\nfunction getCanvasImageData(ctx, size, offset, clear = true) {\n const imageData = ctx.getImageData(origin.x, origin.y, size.width, size.height).data;\n if (clear) {\n ctx.clearRect(origin.x, origin.y, size.width, size.height);\n }\n const pixels = [];\n for (let i = 0; i < imageData.length; i += offset) {\n const idx = i / offset,\n pos = {\n x: idx % size.width,\n y: Math.floor(idx / size.width)\n };\n if (!pixels[pos.y]) {\n pixels[pos.y] = [];\n }\n const indexesOffset = {\n r: 0,\n g: 1,\n b: 2,\n a: 3\n },\n alphaFactor = 255;\n pixels[pos.y][pos.x] = {\n r: imageData[i + indexesOffset.r],\n g: imageData[i + indexesOffset.g],\n b: imageData[i + indexesOffset.b],\n a: imageData[i + indexesOffset.a] / alphaFactor\n };\n }\n return {\n pixels,\n width: Math.min(...pixels.map(row => row.length)),\n height: pixels.length\n };\n}\nfunction getImageData(src, offset) {\n const image = new Image();\n image.crossOrigin = \"Anonymous\";\n const p = new Promise((resolve, reject) => {\n image.onerror = reject;\n image.onload = () => {\n const canvas = document.createElement(\"canvas\");\n canvas.width = image.width;\n canvas.height = image.height;\n const context = canvas.getContext(\"2d\");\n if (!context) {\n return reject(new Error(`${_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.errorPrefix} Could not get canvas context`));\n }\n context.drawImage(image, origin.x, origin.y, image.width, image.height, origin.x, origin.y, canvas.width, canvas.height);\n resolve(getCanvasImageData(context, canvas, offset));\n };\n });\n image.src = src;\n return p;\n}\nfunction getTextData(textOptions, offset, fill) {\n const canvas = document.createElement(\"canvas\"),\n context = canvas.getContext(\"2d\"),\n {\n font,\n text,\n lines: linesOptions,\n color\n } = textOptions;\n if (!text || !context) {\n return;\n }\n const lines = text.split(linesOptions.separator),\n fontSize = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isNumber)(font.size) ? `${font.size}px` : font.size,\n linesData = [];\n let maxWidth = 0,\n totalHeight = 0;\n for (const line of lines) {\n context.font = `${font.style || \"\"} ${font.variant || \"\"} ${font.weight || \"\"} ${fontSize} ${font.family}`;\n const measure = context.measureText(line),\n lineData = {\n measure,\n text: line,\n height: measure.actualBoundingBoxAscent + measure.actualBoundingBoxDescent,\n width: measure.width\n };\n maxWidth = Math.max(maxWidth || minWidth, lineData.width);\n totalHeight += lineData.height + linesOptions.spacing;\n linesData.push(lineData);\n }\n canvas.width = maxWidth;\n canvas.height = totalHeight;\n let currentHeight = 0;\n for (const line of linesData) {\n context.font = `${font.style || \"\"} ${font.variant || \"\"} ${font.weight || \"\"} ${fontSize} ${font.family}`;\n if (fill) {\n context.fillStyle = color;\n context.fillText(line.text, origin.x, currentHeight + line.measure.actualBoundingBoxAscent);\n } else {\n context.strokeStyle = color;\n context.strokeText(line.text, origin.x, currentHeight + line.measure.actualBoundingBoxAscent);\n }\n currentHeight += line.height + linesOptions.spacing;\n }\n return getCanvasImageData(context, canvas, offset);\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-emitters-shape-canvas/./dist/browser/utils.js?");
97
+
98
+ /***/ })
99
+
100
+ }]);
package/esm/index.js CHANGED
@@ -1,6 +1,5 @@
1
- import { EmittersCanvasShapeGenerator } from "./EmittersCanvasShapeGenerator.js";
2
1
  export async function loadEmittersShapeCanvas(engine, refresh = true) {
3
- const emittersEngine = engine;
2
+ const emittersEngine = engine, { EmittersCanvasShapeGenerator } = await import("./EmittersCanvasShapeGenerator.js");
4
3
  emittersEngine.addEmitterShapeGenerator?.("canvas", new EmittersCanvasShapeGenerator());
5
4
  await emittersEngine.refresh(refresh);
6
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/plugin-emitters-shape-canvas",
3
- "version": "3.1.0",
3
+ "version": "3.2.0",
4
4
  "description": "tsParticles emitters shape canvas plugin",
5
5
  "homepage": "https://particles.js.org",
6
6
  "repository": {
@@ -100,8 +100,8 @@
100
100
  "./package.json": "./package.json"
101
101
  },
102
102
  "dependencies": {
103
- "@tsparticles/engine": "^3.1.0",
104
- "@tsparticles/plugin-emitters": "^3.1.0"
103
+ "@tsparticles/engine": "^3.2.0",
104
+ "@tsparticles/plugin-emitters": "^3.2.0"
105
105
  },
106
106
  "publishConfig": {
107
107
  "access": "public"
package/report.html CHANGED
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
  <meta charset="UTF-8"/>
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1"/>
6
- <title>@tsparticles/plugin-emitters-shape-canvas [13 Jan 2024 at 23:10]</title>
6
+ <title>@tsparticles/plugin-emitters-shape-canvas [31 Jan 2024 at 02:13]</title>
7
7
  <link rel="shortcut icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAABrVBMVEUAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+O1foceMD///+J0/qK1Pr7/v8Xdr/9///W8P4UdL7L7P0Scr2r4Pyj3vwad8D5/f/2/f+55f3E6f34+/2H0/ojfMKpzOd0rNgQcb3F3O/j9f7c8v6g3Pz0/P/w+v/q+P7n9v6T1/uQ1vuE0vqLut/y+v+Z2fvt+f+15Pzv9fuc2/vR7v2V2Pvd6/bg9P7I6/285/2y4/yp3/zp8vk8i8kqgMT7/P31+fyv4vxGkcz6/P6/6P3j7vfS5PNnpNUxhcbO7f7F6v3O4vHK3/DA2u631Ouy0eqXweKJud5wqthfoNMMbLvY8f73+v2dxeR8sNtTmdDx9/zX6PSjyeaCtd1YnNGX2PuQveCGt95Nls42h8dLlM3F4vBtAAAAM3RSTlMAAyOx0/sKBvik8opWGBMOAe3l1snDm2E9LSb06eHcu5JpHbarfHZCN9CBb08zzkdNS0kYaptYAAAFV0lEQVRYw92X51/aYBDHHS2O2qqttVbrqNq9m+TJIAYIShBkWwqIiCgoWvfeq7Z2/s29hyQNyUcR7LveGwVyXy6XH8/9rqxglLfUPLxVduUor3h0rfp2TYvpivk37929TkG037hffoX0+peVtZQc1589rigVUdXS/ABSAyEmGIO/1XfvldSK8vs3OqB6u3m0nxmIrvgB0dj7rr7Y9IbuF68hnfFaiHA/sxqm0wciIG43P60qKv9WXWc1RXGh/mFESFABTSBi0sNAKzqet17eCtOb3kZIDwxEEU0oAIJGYxNBDhBND29e0rtXXbcpuPmED9IhEAAQ/AXEaF8EPmnrrKsv0LvWR3fg5sWDNAFZOgAgaKvZDogHNU9MFwnnYROkc56RD5CjAbQX9Ow4g7upCsvYu55aSI/Nj0H1akgKQEUM94dwK65hYRmFU9MIcH/fqJYOZYcnuJSU/waKDgTOEVaVKhwrTRP5XzgSpAITYzom7UvkhFX5VutmxeNnWDjjswTKTyfgluNDGbUpWissXhF3s7mlSml+czWkg3D0l1nNjGNjz3myOQOa1KM/jOS6ebdbAVTCi4gljHSFrviza7tOgRWcS0MOUX9zdNgag5w7rRqA44Lzw0hr1WqES36dFliSJFlh2rXIae3FFcDDgKdxrUIDePr8jGcSClV1u7A9xeN0ModY/pHMxmR1EzRh8TJiwqsHmKW0l4FCEZI+jHio+JdPPE9qwQtTRxku2D8sIeRL2LnxWSllANCQGOIiqVHAz2ye2JR0DcH+HoxDkaADLjgxjKQ+AwCX/g0+DNgdG0ukYCONAe+dbc2IAc6fwt1ARoDSezNHxV2Cmzwv3O6lDMV55edBGwGK9n1+x2F8EDfAGCxug8MhpsMEcTEAWf3rx2vZhe/LAmtIn/6apE6PN0ULKgywD9mmdxbmFl3OvD5AS5fW5zLbv/YHmcsBTjf/afDz3MaZTVCfAP9z6/Bw6ycv8EUBWJIn9zYcoAWWlW9+OzO3vkTy8H+RANLmdrpOuYWdZYEXpo+TlCJrW5EARb7fF+bWdqf3hhyZI1nWJQHgznErZhbjoEsWqi8dQNoE294aldzFurwSABL2XXMf9+H1VQGke9exw5P/AnA5Pv5ngMul7LOvO922iwACu8WkCwLCafvM4CeWPxfA8lNHcWZSoi8EwMAIciKX2Z4SWCMAa3snCZ/G4EA8D6CMLNFsGQhkkz/gQNEBbPCbWsxGUpYVu3z8IyNAknwJkfPMEhLyrdi5RTyUVACkw4GSFRNWJNEW+fgPGwHD8/JxnRuLabN4CGNRkAE23na2+VmEAUmrYymSGjMAYqH84YUIyzgzs3XC7gNgH36Vcc4zKY9o9fgPBXUAiHHwVboBHGLiX6Zcjp1f2wu4tvzZKo0ecPnDtQYDQvJXaBeNzce45Fp28ZQLrEZVuFqgBwOalArKXnW1UzlnSusQKJqKYNuz4tOnI6sZG4zanpemv+7ySU2jbA9h6uhcgpfy6G2PahirDZ6zvq6zDduMVFTKvzw8wgyEdelwY9in3XkEPs3osJuwRQ4qTkfzifndg9Gfc4pdsu82+tTnHZTBa2EAMrqr2t43pguc8tNm7JQVQ2S0ukj2d22dhXYP0/veWtwKrCkNoNimAN5+Xr/oLrxswKbVJjteWrX7eR63o4j9q0GxnaBdWgGA5VStpanIjQmEhV0/nVt5VOFUvix6awJhPcAaTEShgrG+iGyvb5a0Ndb1YGHFPEwoqAinoaykaID1o1pdPNu7XsnCKQ3R+hwWIIhGvORcJUBYXe3Xa3vq/mF/N9V13ugufMkfXn+KHsRD0B8AAAAASUVORK5CYII=" type="image/x-icon" />
8
8
 
9
9
  <script>
@@ -31,8 +31,8 @@
31
31
  <body>
32
32
  <div id="app"></div>
33
33
  <script>
34
- window.chartData = [{"label":"tsparticles.plugin.emitters.shape.canvas.js","isAsset":true,"statSize":9718,"parsedSize":13934,"gzipSize":3694,"groups":[{"label":"dist/browser","path":"./dist/browser","statSize":9634,"groups":[{"id":806,"label":"index.js + 8 modules (concatenated)","path":"./dist/browser/index.js + 8 modules (concatenated)","statSize":9634,"parsedSize":13934,"gzipSize":3694,"concatenated":true,"groups":[{"label":"dist/browser","path":"./dist/browser/index.js + 8 modules (concatenated)/dist/browser","statSize":9634,"groups":[{"id":null,"label":"index.js","path":"./dist/browser/index.js + 8 modules (concatenated)/dist/browser/index.js","statSize":320,"parsedSize":462,"gzipSize":122,"inaccurateSizes":true},{"id":null,"label":"EmittersCanvasShapeGenerator.js","path":"./dist/browser/index.js + 8 modules (concatenated)/dist/browser/EmittersCanvasShapeGenerator.js","statSize":414,"parsedSize":598,"gzipSize":158,"inaccurateSizes":true},{"label":"Options/Classes","path":"./dist/browser/index.js + 8 modules (concatenated)/dist/browser/Options/Classes","statSize":2538,"groups":[{"id":null,"label":"EmittersCanvasShapeOptions.js","path":"./dist/browser/index.js + 8 modules (concatenated)/dist/browser/Options/Classes/EmittersCanvasShapeOptions.js","statSize":855,"parsedSize":1236,"gzipSize":327,"inaccurateSizes":true},{"id":null,"label":"PixelsOptions.js","path":"./dist/browser/index.js + 8 modules (concatenated)/dist/browser/Options/Classes/PixelsOptions.js","statSize":205,"parsedSize":296,"gzipSize":78,"inaccurateSizes":true},{"id":null,"label":"TextOptions.js","path":"./dist/browser/index.js + 8 modules (concatenated)/dist/browser/Options/Classes/TextOptions.js","statSize":555,"parsedSize":802,"gzipSize":212,"inaccurateSizes":true},{"id":null,"label":"TextFontOptions.js","path":"./dist/browser/index.js + 8 modules (concatenated)/dist/browser/Options/Classes/TextFontOptions.js","statSize":599,"parsedSize":866,"gzipSize":229,"inaccurateSizes":true},{"id":null,"label":"TextLinesOptions.js","path":"./dist/browser/index.js + 8 modules (concatenated)/dist/browser/Options/Classes/TextLinesOptions.js","statSize":324,"parsedSize":468,"gzipSize":124,"inaccurateSizes":true}],"parsedSize":3670,"gzipSize":973,"inaccurateSizes":true},{"id":null,"label":"EmittersCanvasShape.js","path":"./dist/browser/index.js + 8 modules (concatenated)/dist/browser/EmittersCanvasShape.js","statSize":2946,"parsedSize":4260,"gzipSize":1129,"inaccurateSizes":true},{"id":null,"label":"utils.js","path":"./dist/browser/index.js + 8 modules (concatenated)/dist/browser/utils.js","statSize":3416,"parsedSize":4940,"gzipSize":1309,"inaccurateSizes":true}],"parsedSize":13934,"gzipSize":3694,"inaccurateSizes":true}]}],"parsedSize":13934,"gzipSize":3694},{"label":"engine\",\"commonjs2\":\"@tsparticles/engine\",\"amd\":\"@tsparticles","path":"./engine\",\"commonjs2\":\"@tsparticles/engine\",\"amd\":\"@tsparticles","statSize":42,"groups":[{"id":533,"label":"engine\",\"root\":\"window\"}","path":"./engine\",\"commonjs2\":\"@tsparticles/engine\",\"amd\":\"@tsparticles/engine\",\"root\":\"window\"}","statSize":42}],"parsedSize":0,"gzipSize":0},{"label":"plugin-emitters\",\"commonjs2\":\"@tsparticles/plugin-emitters\",\"amd\":\"@tsparticles","path":"./plugin-emitters\",\"commonjs2\":\"@tsparticles/plugin-emitters\",\"amd\":\"@tsparticles","statSize":42,"groups":[{"id":68,"label":"plugin-emitters\",\"root\":\"window\"}","path":"./plugin-emitters\",\"commonjs2\":\"@tsparticles/plugin-emitters\",\"amd\":\"@tsparticles/plugin-emitters\",\"root\":\"window\"}","statSize":42}],"parsedSize":0,"gzipSize":0}],"isInitialByEntrypoint":{"tsparticles.plugin.emitters.shape.canvas":true}}];
35
- window.entrypoints = ["tsparticles.plugin.emitters.shape.canvas","tsparticles.plugin.emitters.shape.canvas.min"];
34
+ window.chartData = [];
35
+ window.entrypoints = ["tsparticles.plugin.emitters.shape.canvas.min"];
36
36
  window.defaultSizes = "parsed";
37
37
  </script>
38
38
  </body>
@@ -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.1.0
7
+ * v3.2.0
8
+ */
9
+ /*
10
+ * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
11
+ * This devtool is neither made for production nor for readable output files.
12
+ * It uses "eval()" calls to create a separate source file in the browser devtools.
13
+ * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
14
+ * or disable the default devtool with "devtool: false".
15
+ * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
8
16
  */
9
17
  (function webpackUniversalModuleDefinition(root, factory) {
10
18
  if(typeof exports === 'object' && typeof module === 'object')
@@ -15,22 +23,38 @@
15
23
  var a = typeof exports === 'object' ? factory(require("@tsparticles/plugin-emitters"), require("@tsparticles/engine")) : factory(root["window"], root["window"]);
16
24
  for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
17
25
  }
18
- })(this, (__WEBPACK_EXTERNAL_MODULE__68__, __WEBPACK_EXTERNAL_MODULE__533__) => {
26
+ })(this, (__WEBPACK_EXTERNAL_MODULE__tsparticles_plugin_emitters__, __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__) => {
19
27
  return /******/ (() => { // webpackBootstrap
20
28
  /******/ "use strict";
21
29
  /******/ var __webpack_modules__ = ({
22
30
 
23
- /***/ 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 */ loadEmittersShapeCanvas: () => (/* binding */ loadEmittersShapeCanvas)\n/* harmony export */ });\nasync function loadEmittersShapeCanvas(engine, refresh = true) {\n const emittersEngine = engine,\n {\n EmittersCanvasShapeGenerator\n } = await __webpack_require__.e(/*! import() */ \"dist_browser_EmittersCanvasShapeGenerator_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./EmittersCanvasShapeGenerator.js */ \"./dist/browser/EmittersCanvasShapeGenerator.js\"));\n emittersEngine.addEmitterShapeGenerator?.(\"canvas\", new EmittersCanvasShapeGenerator());\n await emittersEngine.refresh(refresh);\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-emitters-shape-canvas/./dist/browser/index.js?");
38
+
39
+ /***/ }),
40
+
41
+ /***/ "@tsparticles/engine":
42
+ /*!*********************************************************************************************************************************!*\
43
+ !*** external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"} ***!
44
+ \*********************************************************************************************************************************/
24
45
  /***/ ((module) => {
25
46
 
26
- module.exports = __WEBPACK_EXTERNAL_MODULE__533__;
47
+ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
27
48
 
28
49
  /***/ }),
29
50
 
30
- /***/ 68:
51
+ /***/ "@tsparticles/plugin-emitters":
52
+ /*!************************************************************************************************************************************************************!*\
53
+ !*** external {"commonjs":"@tsparticles/plugin-emitters","commonjs2":"@tsparticles/plugin-emitters","amd":"@tsparticles/plugin-emitters","root":"window"} ***!
54
+ \************************************************************************************************************************************************************/
31
55
  /***/ ((module) => {
32
56
 
33
- module.exports = __WEBPACK_EXTERNAL_MODULE__68__;
57
+ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_plugin_emitters__;
34
58
 
35
59
  /***/ })
36
60
 
@@ -60,7 +84,22 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__68__;
60
84
  /******/ return module.exports;
61
85
  /******/ }
62
86
  /******/
87
+ /******/ // expose the modules object (__webpack_modules__)
88
+ /******/ __webpack_require__.m = __webpack_modules__;
89
+ /******/
63
90
  /************************************************************************/
91
+ /******/ /* webpack/runtime/compat get default export */
92
+ /******/ (() => {
93
+ /******/ // getDefaultExport function for compatibility with non-harmony modules
94
+ /******/ __webpack_require__.n = (module) => {
95
+ /******/ var getter = module && module.__esModule ?
96
+ /******/ () => (module['default']) :
97
+ /******/ () => (module);
98
+ /******/ __webpack_require__.d(getter, { a: getter });
99
+ /******/ return getter;
100
+ /******/ };
101
+ /******/ })();
102
+ /******/
64
103
  /******/ /* webpack/runtime/define property getters */
65
104
  /******/ (() => {
66
105
  /******/ // define getter functions for harmony exports
@@ -73,11 +112,91 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__68__;
73
112
  /******/ };
74
113
  /******/ })();
75
114
  /******/
115
+ /******/ /* webpack/runtime/ensure chunk */
116
+ /******/ (() => {
117
+ /******/ __webpack_require__.f = {};
118
+ /******/ // This file contains only the entry chunk.
119
+ /******/ // The chunk loading function for additional chunks
120
+ /******/ __webpack_require__.e = (chunkId) => {
121
+ /******/ return Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key) => {
122
+ /******/ __webpack_require__.f[key](chunkId, promises);
123
+ /******/ return promises;
124
+ /******/ }, []));
125
+ /******/ };
126
+ /******/ })();
127
+ /******/
128
+ /******/ /* webpack/runtime/get javascript chunk filename */
129
+ /******/ (() => {
130
+ /******/ // This function allow to reference async chunks
131
+ /******/ __webpack_require__.u = (chunkId) => {
132
+ /******/ // return url for filenames based on template
133
+ /******/ return "" + chunkId + ".js";
134
+ /******/ };
135
+ /******/ })();
136
+ /******/
137
+ /******/ /* webpack/runtime/global */
138
+ /******/ (() => {
139
+ /******/ __webpack_require__.g = (function() {
140
+ /******/ if (typeof globalThis === 'object') return globalThis;
141
+ /******/ try {
142
+ /******/ return this || new Function('return this')();
143
+ /******/ } catch (e) {
144
+ /******/ if (typeof window === 'object') return window;
145
+ /******/ }
146
+ /******/ })();
147
+ /******/ })();
148
+ /******/
76
149
  /******/ /* webpack/runtime/hasOwnProperty shorthand */
77
150
  /******/ (() => {
78
151
  /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
79
152
  /******/ })();
80
153
  /******/
154
+ /******/ /* webpack/runtime/load script */
155
+ /******/ (() => {
156
+ /******/ var inProgress = {};
157
+ /******/ var dataWebpackPrefix = "@tsparticles/plugin-emitters-shape-canvas:";
158
+ /******/ // loadScript function to load a script via script tag
159
+ /******/ __webpack_require__.l = (url, done, key, chunkId) => {
160
+ /******/ if(inProgress[url]) { inProgress[url].push(done); return; }
161
+ /******/ var script, needAttach;
162
+ /******/ if(key !== undefined) {
163
+ /******/ var scripts = document.getElementsByTagName("script");
164
+ /******/ for(var i = 0; i < scripts.length; i++) {
165
+ /******/ var s = scripts[i];
166
+ /******/ if(s.getAttribute("src") == url || s.getAttribute("data-webpack") == dataWebpackPrefix + key) { script = s; break; }
167
+ /******/ }
168
+ /******/ }
169
+ /******/ if(!script) {
170
+ /******/ needAttach = true;
171
+ /******/ script = document.createElement('script');
172
+ /******/
173
+ /******/ script.charset = 'utf-8';
174
+ /******/ script.timeout = 120;
175
+ /******/ if (__webpack_require__.nc) {
176
+ /******/ script.setAttribute("nonce", __webpack_require__.nc);
177
+ /******/ }
178
+ /******/ script.setAttribute("data-webpack", dataWebpackPrefix + key);
179
+ /******/
180
+ /******/ script.src = url;
181
+ /******/ }
182
+ /******/ inProgress[url] = [done];
183
+ /******/ var onScriptComplete = (prev, event) => {
184
+ /******/ // avoid mem leaks in IE.
185
+ /******/ script.onerror = script.onload = null;
186
+ /******/ clearTimeout(timeout);
187
+ /******/ var doneFns = inProgress[url];
188
+ /******/ delete inProgress[url];
189
+ /******/ script.parentNode && script.parentNode.removeChild(script);
190
+ /******/ doneFns && doneFns.forEach((fn) => (fn(event)));
191
+ /******/ if(prev) return prev(event);
192
+ /******/ }
193
+ /******/ var timeout = setTimeout(onScriptComplete.bind(null, undefined, { type: 'timeout', target: script }), 120000);
194
+ /******/ script.onerror = onScriptComplete.bind(null, script.onerror);
195
+ /******/ script.onload = onScriptComplete.bind(null, script.onload);
196
+ /******/ needAttach && document.head.appendChild(script);
197
+ /******/ };
198
+ /******/ })();
199
+ /******/
81
200
  /******/ /* webpack/runtime/make namespace object */
82
201
  /******/ (() => {
83
202
  /******/ // define __esModule on exports
@@ -89,379 +208,128 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__68__;
89
208
  /******/ };
90
209
  /******/ })();
91
210
  /******/
211
+ /******/ /* webpack/runtime/publicPath */
212
+ /******/ (() => {
213
+ /******/ var scriptUrl;
214
+ /******/ if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + "";
215
+ /******/ var document = __webpack_require__.g.document;
216
+ /******/ if (!scriptUrl && document) {
217
+ /******/ if (document.currentScript)
218
+ /******/ scriptUrl = document.currentScript.src;
219
+ /******/ if (!scriptUrl) {
220
+ /******/ var scripts = document.getElementsByTagName("script");
221
+ /******/ if(scripts.length) {
222
+ /******/ var i = scripts.length - 1;
223
+ /******/ while (i > -1 && !scriptUrl) scriptUrl = scripts[i--].src;
224
+ /******/ }
225
+ /******/ }
226
+ /******/ }
227
+ /******/ // When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration
228
+ /******/ // or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.
229
+ /******/ if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser");
230
+ /******/ scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/");
231
+ /******/ __webpack_require__.p = scriptUrl;
232
+ /******/ })();
233
+ /******/
234
+ /******/ /* webpack/runtime/jsonp chunk loading */
235
+ /******/ (() => {
236
+ /******/ // no baseURI
237
+ /******/
238
+ /******/ // object to store loaded and loading chunks
239
+ /******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
240
+ /******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded
241
+ /******/ var installedChunks = {
242
+ /******/ "tsparticles.plugin.emitters.shape.canvas": 0
243
+ /******/ };
244
+ /******/
245
+ /******/ __webpack_require__.f.j = (chunkId, promises) => {
246
+ /******/ // JSONP chunk loading for javascript
247
+ /******/ var installedChunkData = __webpack_require__.o(installedChunks, chunkId) ? installedChunks[chunkId] : undefined;
248
+ /******/ if(installedChunkData !== 0) { // 0 means "already installed".
249
+ /******/
250
+ /******/ // a Promise means "currently loading".
251
+ /******/ if(installedChunkData) {
252
+ /******/ promises.push(installedChunkData[2]);
253
+ /******/ } else {
254
+ /******/ if(true) { // all chunks have JS
255
+ /******/ // setup Promise in chunk cache
256
+ /******/ var promise = new Promise((resolve, reject) => (installedChunkData = installedChunks[chunkId] = [resolve, reject]));
257
+ /******/ promises.push(installedChunkData[2] = promise);
258
+ /******/
259
+ /******/ // start chunk loading
260
+ /******/ var url = __webpack_require__.p + __webpack_require__.u(chunkId);
261
+ /******/ // create error before stack unwound to get useful stacktrace later
262
+ /******/ var error = new Error();
263
+ /******/ var loadingEnded = (event) => {
264
+ /******/ if(__webpack_require__.o(installedChunks, chunkId)) {
265
+ /******/ installedChunkData = installedChunks[chunkId];
266
+ /******/ if(installedChunkData !== 0) installedChunks[chunkId] = undefined;
267
+ /******/ if(installedChunkData) {
268
+ /******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type);
269
+ /******/ var realSrc = event && event.target && event.target.src;
270
+ /******/ error.message = 'Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')';
271
+ /******/ error.name = 'ChunkLoadError';
272
+ /******/ error.type = errorType;
273
+ /******/ error.request = realSrc;
274
+ /******/ installedChunkData[1](error);
275
+ /******/ }
276
+ /******/ }
277
+ /******/ };
278
+ /******/ __webpack_require__.l(url, loadingEnded, "chunk-" + chunkId, chunkId);
279
+ /******/ }
280
+ /******/ }
281
+ /******/ }
282
+ /******/ };
283
+ /******/
284
+ /******/ // no prefetching
285
+ /******/
286
+ /******/ // no preloaded
287
+ /******/
288
+ /******/ // no HMR
289
+ /******/
290
+ /******/ // no HMR manifest
291
+ /******/
292
+ /******/ // no on chunks loaded
293
+ /******/
294
+ /******/ // install a JSONP callback for chunk loading
295
+ /******/ var webpackJsonpCallback = (parentChunkLoadingFunction, data) => {
296
+ /******/ var chunkIds = data[0];
297
+ /******/ var moreModules = data[1];
298
+ /******/ var runtime = data[2];
299
+ /******/ // add "moreModules" to the modules object,
300
+ /******/ // then flag all "chunkIds" as loaded and fire callback
301
+ /******/ var moduleId, chunkId, i = 0;
302
+ /******/ if(chunkIds.some((id) => (installedChunks[id] !== 0))) {
303
+ /******/ for(moduleId in moreModules) {
304
+ /******/ if(__webpack_require__.o(moreModules, moduleId)) {
305
+ /******/ __webpack_require__.m[moduleId] = moreModules[moduleId];
306
+ /******/ }
307
+ /******/ }
308
+ /******/ if(runtime) var result = runtime(__webpack_require__);
309
+ /******/ }
310
+ /******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data);
311
+ /******/ for(;i < chunkIds.length; i++) {
312
+ /******/ chunkId = chunkIds[i];
313
+ /******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {
314
+ /******/ installedChunks[chunkId][0]();
315
+ /******/ }
316
+ /******/ installedChunks[chunkId] = 0;
317
+ /******/ }
318
+ /******/
319
+ /******/ }
320
+ /******/
321
+ /******/ var chunkLoadingGlobal = this["webpackChunk_tsparticles_plugin_emitters_shape_canvas"] = this["webpackChunk_tsparticles_plugin_emitters_shape_canvas"] || [];
322
+ /******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));
323
+ /******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));
324
+ /******/ })();
325
+ /******/
92
326
  /************************************************************************/
93
- var __webpack_exports__ = {};
94
- // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
95
- (() => {
96
- // ESM COMPAT FLAG
97
- __webpack_require__.r(__webpack_exports__);
98
-
99
- // EXPORTS
100
- __webpack_require__.d(__webpack_exports__, {
101
- loadEmittersShapeCanvas: () => (/* binding */ loadEmittersShapeCanvas)
102
- });
103
-
104
- // EXTERNAL MODULE: external {"commonjs":"@tsparticles/plugin-emitters","commonjs2":"@tsparticles/plugin-emitters","amd":"@tsparticles/plugin-emitters","root":"window"}
105
- var plugin_emitters_root_window_ = __webpack_require__(68);
106
- // EXTERNAL MODULE: external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"}
107
- var engine_root_window_ = __webpack_require__(533);
108
- ;// CONCATENATED MODULE: ./dist/browser/utils.js
109
-
110
- const origin = {
111
- x: 0,
112
- y: 0
113
- },
114
- minWidth = 0;
115
- function getCanvasImageData(ctx, size, offset, clear = true) {
116
- const imageData = ctx.getImageData(origin.x, origin.y, size.width, size.height).data;
117
- if (clear) {
118
- ctx.clearRect(origin.x, origin.y, size.width, size.height);
119
- }
120
- const pixels = [];
121
- for (let i = 0; i < imageData.length; i += offset) {
122
- const idx = i / offset,
123
- pos = {
124
- x: idx % size.width,
125
- y: Math.floor(idx / size.width)
126
- };
127
- if (!pixels[pos.y]) {
128
- pixels[pos.y] = [];
129
- }
130
- const indexesOffset = {
131
- r: 0,
132
- g: 1,
133
- b: 2,
134
- a: 3
135
- },
136
- alphaFactor = 255;
137
- pixels[pos.y][pos.x] = {
138
- r: imageData[i + indexesOffset.r],
139
- g: imageData[i + indexesOffset.g],
140
- b: imageData[i + indexesOffset.b],
141
- a: imageData[i + indexesOffset.a] / alphaFactor
142
- };
143
- }
144
- return {
145
- pixels,
146
- width: Math.min(...pixels.map(row => row.length)),
147
- height: pixels.length
148
- };
149
- }
150
- function getImageData(src, offset) {
151
- const image = new Image();
152
- image.crossOrigin = "Anonymous";
153
- const p = new Promise((resolve, reject) => {
154
- image.onerror = reject;
155
- image.onload = () => {
156
- const canvas = document.createElement("canvas");
157
- canvas.width = image.width;
158
- canvas.height = image.height;
159
- const context = canvas.getContext("2d");
160
- if (!context) {
161
- return reject(new Error(`${engine_root_window_.errorPrefix} Could not get canvas context`));
162
- }
163
- context.drawImage(image, origin.x, origin.y, image.width, image.height, origin.x, origin.y, canvas.width, canvas.height);
164
- resolve(getCanvasImageData(context, canvas, offset));
165
- };
166
- });
167
- image.src = src;
168
- return p;
169
- }
170
- function getTextData(textOptions, offset, fill) {
171
- const canvas = document.createElement("canvas"),
172
- context = canvas.getContext("2d"),
173
- {
174
- font,
175
- text,
176
- lines: linesOptions,
177
- color
178
- } = textOptions;
179
- if (!text || !context) {
180
- return;
181
- }
182
- const lines = text.split(linesOptions.separator),
183
- fontSize = (0,engine_root_window_.isNumber)(font.size) ? `${font.size}px` : font.size,
184
- linesData = [];
185
- let maxWidth = 0,
186
- totalHeight = 0;
187
- for (const line of lines) {
188
- context.font = `${font.style || ""} ${font.variant || ""} ${font.weight || ""} ${fontSize} ${font.family}`;
189
- const measure = context.measureText(line),
190
- lineData = {
191
- measure,
192
- text: line,
193
- height: measure.actualBoundingBoxAscent + measure.actualBoundingBoxDescent,
194
- width: measure.width
195
- };
196
- maxWidth = Math.max(maxWidth || minWidth, lineData.width);
197
- totalHeight += lineData.height + linesOptions.spacing;
198
- linesData.push(lineData);
199
- }
200
- canvas.width = maxWidth;
201
- canvas.height = totalHeight;
202
- let currentHeight = 0;
203
- for (const line of linesData) {
204
- context.font = `${font.style || ""} ${font.variant || ""} ${font.weight || ""} ${fontSize} ${font.family}`;
205
- if (fill) {
206
- context.fillStyle = color;
207
- context.fillText(line.text, origin.x, currentHeight + line.measure.actualBoundingBoxAscent);
208
- } else {
209
- context.strokeStyle = color;
210
- context.strokeText(line.text, origin.x, currentHeight + line.measure.actualBoundingBoxAscent);
211
- }
212
- currentHeight += line.height + linesOptions.spacing;
213
- }
214
- return getCanvasImageData(context, canvas, offset);
215
- }
216
- ;// CONCATENATED MODULE: ./dist/browser/EmittersCanvasShape.js
217
-
218
-
219
-
220
- const maxRetries = 100,
221
- half = 0.5;
222
- class EmittersCanvasShape extends plugin_emitters_root_window_.EmitterShapeBase {
223
- constructor(position, size, fill, options) {
224
- super(position, size, fill, options);
225
- const filter = options.filter,
226
- minAlpha = 0;
227
- let filterFunc = pixel => pixel.a > minAlpha;
228
- if (filter !== undefined) {
229
- if ((0,engine_root_window_.isString)(filter)) {
230
- if (Object.hasOwn(window, filter)) {
231
- const wndFilter = window[filter];
232
- if ((0,engine_root_window_.isFunction)(wndFilter)) {
233
- filterFunc = wndFilter;
234
- }
235
- }
236
- } else {
237
- filterFunc = filter;
238
- }
239
- }
240
- this.filter = filterFunc;
241
- this.scale = options.scale;
242
- this.pixelData = {
243
- pixels: [],
244
- height: 0,
245
- width: 0
246
- };
247
- }
248
- async init() {
249
- let pixelData;
250
- const options = this.options,
251
- selector = options.selector,
252
- pixels = options.pixels,
253
- image = options.image,
254
- element = options.element,
255
- text = options.text,
256
- offset = pixels.offset;
257
- if (image) {
258
- const url = image.src;
259
- if (!url) {
260
- return;
261
- }
262
- pixelData = await getImageData(url, offset);
263
- } else if (text) {
264
- const data = getTextData(text, offset, this.fill);
265
- if (!data) {
266
- return;
267
- }
268
- pixelData = data;
269
- } else if (element ?? selector) {
270
- const canvas = element ?? (selector && document.querySelector(selector));
271
- if (!canvas) {
272
- return;
273
- }
274
- const context = canvas.getContext("2d");
275
- if (!context) {
276
- return;
277
- }
278
- pixelData = getCanvasImageData(context, canvas, offset);
279
- }
280
- if (!pixelData) {
281
- return;
282
- }
283
- this.pixelData = pixelData;
284
- }
285
- async randomPosition() {
286
- const {
287
- height,
288
- width
289
- } = this.pixelData,
290
- data = this.pixelData,
291
- position = this.position,
292
- scale = this.scale,
293
- positionOffset = {
294
- x: position.x - width * scale * half,
295
- y: position.y - height * scale * half
296
- };
297
- for (let i = 0; i < maxRetries; i++) {
298
- const nextIndex = Math.floor((0,engine_root_window_.getRandom)() * width * height),
299
- pixelPos = {
300
- x: nextIndex % width,
301
- y: Math.floor(nextIndex / width)
302
- },
303
- pixel = data.pixels[pixelPos.y][pixelPos.x],
304
- shouldCreateParticle = this.filter(pixel);
305
- if (!shouldCreateParticle) {
306
- continue;
307
- }
308
- return Promise.resolve({
309
- position: {
310
- x: pixelPos.x * scale + positionOffset.x,
311
- y: pixelPos.y * scale + positionOffset.y
312
- },
313
- color: {
314
- ...pixel
315
- },
316
- opacity: pixel.a
317
- });
318
- }
319
- return Promise.resolve(null);
320
- }
321
- resize(position, size) {
322
- super.resize(position, size);
323
- }
324
- }
325
- ;// CONCATENATED MODULE: ./dist/browser/Options/Classes/PixelsOptions.js
326
- class PixelsOptions {
327
- constructor() {
328
- this.offset = 4;
329
- }
330
- load(data) {
331
- if (!data) {
332
- return;
333
- }
334
- if (data.offset !== undefined) {
335
- this.offset = data.offset;
336
- }
337
- }
338
- }
339
- ;// CONCATENATED MODULE: ./dist/browser/Options/Classes/TextFontOptions.js
340
- class TextFontOptions {
341
- constructor() {
342
- this.family = "Verdana";
343
- this.size = 32;
344
- this.style = "";
345
- this.variant = "";
346
- this.weight = "";
347
- }
348
- load(data) {
349
- if (!data) {
350
- return;
351
- }
352
- if (data.family !== undefined) {
353
- this.family = data.family;
354
- }
355
- if (data.size !== undefined) {
356
- this.size = data.size;
357
- }
358
- if (data.style !== undefined) {
359
- this.style = data.style;
360
- }
361
- if (data.variant !== undefined) {
362
- this.variant = data.variant;
363
- }
364
- if (data.weight !== undefined) {
365
- this.weight = data.weight;
366
- }
367
- }
368
- }
369
- ;// CONCATENATED MODULE: ./dist/browser/Options/Classes/TextLinesOptions.js
370
- class TextLinesOptions {
371
- constructor() {
372
- this.separator = "\n";
373
- this.spacing = 0;
374
- }
375
- load(data) {
376
- if (!data) {
377
- return;
378
- }
379
- if (data.separator !== undefined) {
380
- this.separator = data.separator;
381
- }
382
- if (data.spacing !== undefined) {
383
- this.spacing = data.spacing;
384
- }
385
- }
386
- }
387
- ;// CONCATENATED MODULE: ./dist/browser/Options/Classes/TextOptions.js
388
-
389
-
390
- class TextOptions {
391
- constructor() {
392
- this.color = "#000000";
393
- this.font = new TextFontOptions();
394
- this.lines = new TextLinesOptions();
395
- this.text = "";
396
- }
397
- load(data) {
398
- if (!data) {
399
- return;
400
- }
401
- if (data.color !== undefined) {
402
- this.color = data.color;
403
- }
404
- this.font.load(data.font);
405
- this.lines.load(data.lines);
406
- if (data.text !== undefined) {
407
- this.text = data.text;
408
- }
409
- }
410
- }
411
- ;// CONCATENATED MODULE: ./dist/browser/Options/Classes/EmittersCanvasShapeOptions.js
412
-
413
-
414
- const minAlpha = 0;
415
- class EmittersCanvasShapeOptions {
416
- constructor() {
417
- this.filter = pixel => pixel.a > minAlpha;
418
- this.pixels = new PixelsOptions();
419
- this.scale = 1;
420
- this.selector = "";
421
- this.text = new TextOptions();
422
- }
423
- load(data) {
424
- if (!data) {
425
- return;
426
- }
427
- if (data.element !== undefined) {
428
- this.element = data.element;
429
- }
430
- if (data.filter !== undefined) {
431
- this.filter = data.filter;
432
- }
433
- this.pixels.load(data.pixels);
434
- if (data.scale !== undefined) {
435
- this.scale = data.scale;
436
- }
437
- if (data.selector !== undefined) {
438
- this.selector = data.selector;
439
- }
440
- if (data.image !== undefined) {
441
- this.image = data.image;
442
- }
443
- this.text.load(data.text);
444
- }
445
- }
446
- ;// CONCATENATED MODULE: ./dist/browser/EmittersCanvasShapeGenerator.js
447
-
448
-
449
- class EmittersCanvasShapeGenerator {
450
- generate(position, size, fill, options) {
451
- const shapeOptions = new EmittersCanvasShapeOptions();
452
- shapeOptions.load(options);
453
- return new EmittersCanvasShape(position, size, fill, shapeOptions);
454
- }
455
- }
456
- ;// CONCATENATED MODULE: ./dist/browser/index.js
457
-
458
- async function loadEmittersShapeCanvas(engine, refresh = true) {
459
- const emittersEngine = engine;
460
- emittersEngine.addEmitterShapeGenerator?.("canvas", new EmittersCanvasShapeGenerator());
461
- await emittersEngine.refresh(refresh);
462
- }
463
- })();
464
-
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
+ /******/
465
333
  /******/ return __webpack_exports__;
466
334
  /******/ })()
467
335
  ;
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see tsparticles.plugin.emitters.shape.canvas.min.js.LICENSE.txt */
2
- !function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("@tsparticles/plugin-emitters"),require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/plugin-emitters","@tsparticles/engine"],e);else{var i="object"==typeof exports?e(require("@tsparticles/plugin-emitters"),require("@tsparticles/engine")):e(t.window,t.window);for(var s in i)("object"==typeof exports?exports:t)[s]=i[s]}}(this,((t,e)=>(()=>{"use strict";var i={533:t=>{t.exports=e},68:e=>{e.exports=t}},s={};function o(t){var e=s[t];if(void 0!==e)return e.exports;var r=s[t]={exports:{}};return i[t](r,r.exports,o),r.exports}o.d=(t,e)=>{for(var i in e)o.o(e,i)&&!o.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),o.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r={};return(()=>{o.r(r),o.d(r,{loadEmittersShapeCanvas:()=>u});var t=o(68),e=o(533);const i={x:0,y:0};function s(t,e,s,o=!0){const r=t.getImageData(i.x,i.y,e.width,e.height).data;o&&t.clearRect(i.x,i.y,e.width,e.height);const n=[];for(let t=0;t<r.length;t+=s){const i=t/s,o={x:i%e.width,y:Math.floor(i/e.width)};n[o.y]||(n[o.y]=[]);const a={r:0,g:1,b:2,a:3},l=255;n[o.y][o.x]={r:r[t+a.r],g:r[t+a.g],b:r[t+a.b],a:r[t+a.a]/l}}return{pixels:n,width:Math.min(...n.map((t=>t.length))),height:n.length}}class n extends t.EmitterShapeBase{constructor(t,i,s,o){super(t,i,s,o);const r=o.filter;let n=t=>t.a>0;if(void 0!==r)if((0,e.isString)(r)){if(Object.hasOwn(window,r)){const t=window[r];(0,e.isFunction)(t)&&(n=t)}}else n=r;this.filter=n,this.scale=o.scale,this.pixelData={pixels:[],height:0,width:0}}async init(){let t;const o=this.options,r=o.selector,n=o.pixels,a=o.image,l=o.element,c=o.text,h=n.offset;if(a){const o=a.src;if(!o)return;t=await function(t,o){const r=new Image;r.crossOrigin="Anonymous";const n=new Promise(((t,n)=>{r.onerror=n,r.onload=()=>{const a=document.createElement("canvas");a.width=r.width,a.height=r.height;const l=a.getContext("2d");if(!l)return n(new Error(`${e.errorPrefix} Could not get canvas context`));l.drawImage(r,i.x,i.y,r.width,r.height,i.x,i.y,a.width,a.height),t(s(l,a,o))}}));return r.src=t,n}(o,h)}else if(c){const o=function(t,o,r){const n=document.createElement("canvas"),a=n.getContext("2d"),{font:l,text:c,lines:h,color:d}=t;if(!c||!a)return;const f=c.split(h.separator),u=(0,e.isNumber)(l.size)?`${l.size}px`:l.size,p=[];let x=0,g=0;for(const t of f){a.font=`${l.style||""} ${l.variant||""} ${l.weight||""} ${u} ${l.family}`;const e=a.measureText(t),i={measure:e,text:t,height:e.actualBoundingBoxAscent+e.actualBoundingBoxDescent,width:e.width};x=Math.max(x||0,i.width),g+=i.height+h.spacing,p.push(i)}n.width=x,n.height=g;let m=0;for(const t of p)a.font=`${l.style||""} ${l.variant||""} ${l.weight||""} ${u} ${l.family}`,r?(a.fillStyle=d,a.fillText(t.text,i.x,m+t.measure.actualBoundingBoxAscent)):(a.strokeStyle=d,a.strokeText(t.text,i.x,m+t.measure.actualBoundingBoxAscent)),m+=t.height+h.spacing;return s(a,n,o)}(c,h,this.fill);if(!o)return;t=o}else if(l??r){const e=l??(r&&document.querySelector(r));if(!e)return;const i=e.getContext("2d");if(!i)return;t=s(i,e,h)}t&&(this.pixelData=t)}async randomPosition(){const{height:t,width:i}=this.pixelData,s=this.pixelData,o=this.position,r=this.scale,n=o.x-i*r*.5,a=o.y-t*r*.5;for(let o=0;o<100;o++){const o=Math.floor((0,e.getRandom)()*i*t),l={x:o%i,y:Math.floor(o/i)},c=s.pixels[l.y][l.x];if(this.filter(c))return Promise.resolve({position:{x:l.x*r+n,y:l.y*r+a},color:{...c},opacity:c.a})}return Promise.resolve(null)}resize(t,e){super.resize(t,e)}}class a{constructor(){this.offset=4}load(t){t&&void 0!==t.offset&&(this.offset=t.offset)}}class l{constructor(){this.family="Verdana",this.size=32,this.style="",this.variant="",this.weight=""}load(t){t&&(void 0!==t.family&&(this.family=t.family),void 0!==t.size&&(this.size=t.size),void 0!==t.style&&(this.style=t.style),void 0!==t.variant&&(this.variant=t.variant),void 0!==t.weight&&(this.weight=t.weight))}}class c{constructor(){this.separator="\n",this.spacing=0}load(t){t&&(void 0!==t.separator&&(this.separator=t.separator),void 0!==t.spacing&&(this.spacing=t.spacing))}}class h{constructor(){this.color="#000000",this.font=new l,this.lines=new c,this.text=""}load(t){t&&(void 0!==t.color&&(this.color=t.color),this.font.load(t.font),this.lines.load(t.lines),void 0!==t.text&&(this.text=t.text))}}class d{constructor(){this.filter=t=>t.a>0,this.pixels=new a,this.scale=1,this.selector="",this.text=new h}load(t){t&&(void 0!==t.element&&(this.element=t.element),void 0!==t.filter&&(this.filter=t.filter),this.pixels.load(t.pixels),void 0!==t.scale&&(this.scale=t.scale),void 0!==t.selector&&(this.selector=t.selector),void 0!==t.image&&(this.image=t.image),this.text.load(t.text))}}class f{generate(t,e,i,s){const o=new d;return o.load(s),new n(t,e,i,o)}}async function u(t,e=!0){const i=t;i.addEmitterShapeGenerator?.("canvas",new f),await i.refresh(e)}})(),r})()));
2
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/plugin-emitters"),require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/plugin-emitters","@tsparticles/engine"],t);else{var r="object"==typeof exports?t(require("@tsparticles/plugin-emitters"),require("@tsparticles/engine")):t(e.window,e.window);for(var i in r)("object"==typeof exports?exports:e)[i]=r[i]}}(this,((e,t)=>(()=>{var r,i,n={533:e=>{e.exports=t},68:t=>{t.exports=e}},o={};function a(e){var t=o[e];if(void 0!==t)return t.exports;var r=o[e]={exports:{}};return n[e](r,r.exports,a),r.exports}a.m=n,a.d=(e,t)=>{for(var r in t)a.o(t,r)&&!a.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},a.f={},a.e=e=>Promise.all(Object.keys(a.f).reduce(((t,r)=>(a.f[r](e,t),t)),[])),a.u=e=>e+".min.js",a.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r={},i="@tsparticles/plugin-emitters-shape-canvas:",a.l=(e,t,n,o)=>{if(r[e])r[e].push(t);else{var s,p;if(void 0!==n)for(var c=document.getElementsByTagName("script"),l=0;l<c.length;l++){var u=c[l];if(u.getAttribute("src")==e||u.getAttribute("data-webpack")==i+n){s=u;break}}s||(p=!0,(s=document.createElement("script")).charset="utf-8",s.timeout=120,a.nc&&s.setAttribute("nonce",a.nc),s.setAttribute("data-webpack",i+n),s.src=e),r[e]=[t];var d=(t,i)=>{s.onerror=s.onload=null,clearTimeout(f);var n=r[e];if(delete r[e],s.parentNode&&s.parentNode.removeChild(s),n&&n.forEach((e=>e(i))),t)return t(i)},f=setTimeout(d.bind(null,void 0,{type:"timeout",target:s}),12e4);s.onerror=d.bind(null,s.onerror),s.onload=d.bind(null,s.onload),p&&document.head.appendChild(s)}},a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;a.g.importScripts&&(e=a.g.location+"");var t=a.g.document;if(!e&&t&&(t.currentScript&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName("script");if(r.length)for(var i=r.length-1;i>-1&&!e;)e=r[i--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),a.p=e})(),(()=>{var e={926:0};a.f.j=(t,r)=>{var i=a.o(e,t)?e[t]:void 0;if(0!==i)if(i)r.push(i[2]);else{var n=new Promise(((r,n)=>i=e[t]=[r,n]));r.push(i[2]=n);var o=a.p+a.u(t),s=new Error;a.l(o,(r=>{if(a.o(e,t)&&(0!==(i=e[t])&&(e[t]=void 0),i)){var n=r&&("load"===r.type?"missing":r.type),o=r&&r.target&&r.target.src;s.message="Loading chunk "+t+" failed.\n("+n+": "+o+")",s.name="ChunkLoadError",s.type=n,s.request=o,i[1](s)}}),"chunk-"+t,t)}};var t=(t,r)=>{var i,n,o=r[0],s=r[1],p=r[2],c=0;if(o.some((t=>0!==e[t]))){for(i in s)a.o(s,i)&&(a.m[i]=s[i]);if(p)p(a)}for(t&&t(r);c<o.length;c++)n=o[c],a.o(e,n)&&e[n]&&e[n][0](),e[n]=0},r=this.webpackChunk_tsparticles_plugin_emitters_shape_canvas=this.webpackChunk_tsparticles_plugin_emitters_shape_canvas||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))})();var s={};return(()=>{async function e(e,t=!0){const r=e,{EmittersCanvasShapeGenerator:i}=await a.e(720).then(a.bind(a,720));r.addEmitterShapeGenerator?.("canvas",new i),await r.refresh(t)}a.r(s),a.d(s,{loadEmittersShapeCanvas:()=>e})})(),s})()));
@@ -1 +1 @@
1
- /*! tsParticles Emitters Shape Canvas Plugin v3.1.0 by Matteo Bruni */
1
+ /*! tsParticles Emitters Shape Canvas Plugin v3.2.0 by Matteo Bruni */
package/umd/index.js CHANGED
@@ -1,19 +1,42 @@
1
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
2
+ if (k2 === undefined) k2 = k;
3
+ var desc = Object.getOwnPropertyDescriptor(m, k);
4
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
5
+ desc = { enumerable: true, get: function() { return m[k]; } };
6
+ }
7
+ Object.defineProperty(o, k2, desc);
8
+ }) : (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ o[k2] = m[k];
11
+ }));
12
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
13
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
14
+ }) : function(o, v) {
15
+ o["default"] = v;
16
+ });
17
+ var __importStar = (this && this.__importStar) || function (mod) {
18
+ if (mod && mod.__esModule) return mod;
19
+ var result = {};
20
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
21
+ __setModuleDefault(result, mod);
22
+ return result;
23
+ };
1
24
  (function (factory) {
2
25
  if (typeof module === "object" && typeof module.exports === "object") {
3
26
  var v = factory(require, exports);
4
27
  if (v !== undefined) module.exports = v;
5
28
  }
6
29
  else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "./EmittersCanvasShapeGenerator.js"], factory);
30
+ define(["require", "exports"], factory);
8
31
  }
9
32
  })(function (require, exports) {
10
33
  "use strict";
34
+ var __syncRequire = typeof module === "object" && typeof module.exports === "object";
11
35
  Object.defineProperty(exports, "__esModule", { value: true });
12
36
  exports.loadEmittersShapeCanvas = void 0;
13
- const EmittersCanvasShapeGenerator_js_1 = require("./EmittersCanvasShapeGenerator.js");
14
37
  async function loadEmittersShapeCanvas(engine, refresh = true) {
15
- const emittersEngine = engine;
16
- emittersEngine.addEmitterShapeGenerator?.("canvas", new EmittersCanvasShapeGenerator_js_1.EmittersCanvasShapeGenerator());
38
+ const emittersEngine = engine, { EmittersCanvasShapeGenerator } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./EmittersCanvasShapeGenerator.js"))) : new Promise((resolve_1, reject_1) => { require(["./EmittersCanvasShapeGenerator.js"], resolve_1, reject_1); }).then(__importStar));
39
+ emittersEngine.addEmitterShapeGenerator?.("canvas", new EmittersCanvasShapeGenerator());
17
40
  await emittersEngine.refresh(refresh);
18
41
  }
19
42
  exports.loadEmittersShapeCanvas = loadEmittersShapeCanvas;