@tsparticles/plugin-emitters-shape-canvas 3.9.0 → 4.0.0-alpha.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/355.min.js +2 -0
- package/355.min.js.LICENSE.txt +1 -0
- package/browser/EmittersCanvasShape.js +25 -22
- package/browser/index.js +6 -6
- package/browser/utils.js +17 -15
- package/cjs/EmittersCanvasShape.js +31 -32
- package/cjs/EmittersCanvasShapeGenerator.js +5 -9
- package/cjs/Options/Classes/EmittersCanvasShapeOptions.js +7 -11
- package/cjs/Options/Classes/PixelsOptions.js +3 -7
- package/cjs/Options/Classes/TextFontOptions.js +3 -7
- package/cjs/Options/Classes/TextLinesOptions.js +3 -7
- package/cjs/Options/Classes/TextOptions.js +7 -11
- package/cjs/Options/Interfaces/IEmittersCanvasShapeOptions.js +1 -2
- package/cjs/Options/Interfaces/IPixelsOptions.js +1 -2
- package/cjs/Options/Interfaces/ITextFontOptions.js +1 -2
- package/cjs/Options/Interfaces/ITextLinesOptions.js +1 -2
- package/cjs/Options/Interfaces/ITextOptions.js +1 -2
- package/cjs/index.js +6 -9
- package/cjs/types.js +1 -2
- package/cjs/utils.js +20 -23
- package/dist_browser_EmittersCanvasShapeGenerator_js.js +100 -0
- package/esm/EmittersCanvasShape.js +25 -22
- package/esm/index.js +6 -6
- package/esm/utils.js +17 -15
- package/package.json +5 -4
- package/report.html +5 -4
- package/tsparticles.plugin.emitters.shape.canvas.js +212 -103
- package/tsparticles.plugin.emitters.shape.canvas.min.js +1 -1
- package/tsparticles.plugin.emitters.shape.canvas.min.js.LICENSE.txt +1 -1
- package/types/Options/Classes/EmittersCanvasShapeOptions.d.ts +1 -1
- package/types/Options/Classes/PixelsOptions.d.ts +1 -1
- package/types/Options/Classes/TextFontOptions.d.ts +1 -1
- package/types/Options/Classes/TextLinesOptions.d.ts +1 -1
- package/types/Options/Classes/TextOptions.d.ts +1 -1
- package/types/index.d.ts +1 -1
- package/umd/EmittersCanvasShape.js +24 -21
- package/umd/index.js +41 -7
- package/umd/utils.js +16 -14
|
@@ -4,7 +4,7 @@
|
|
|
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
|
-
*
|
|
7
|
+
* v4.0.0-alpha.0
|
|
8
8
|
*/
|
|
9
9
|
/*
|
|
10
10
|
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
@@ -28,115 +28,35 @@ return /******/ (() => { // webpackBootstrap
|
|
|
28
28
|
/******/ "use strict";
|
|
29
29
|
/******/ var __webpack_modules__ = ({
|
|
30
30
|
|
|
31
|
-
/***/ "./dist/browser/
|
|
32
|
-
/*!*********************************************!*\
|
|
33
|
-
!*** ./dist/browser/EmittersCanvasShape.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 */ 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 ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.isNull)(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 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 {\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 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?\n}");
|
|
38
|
-
|
|
39
|
-
/***/ }),
|
|
40
|
-
|
|
41
|
-
/***/ "./dist/browser/EmittersCanvasShapeGenerator.js":
|
|
42
|
-
/*!******************************************************!*\
|
|
43
|
-
!*** ./dist/browser/EmittersCanvasShapeGenerator.js ***!
|
|
44
|
-
\******************************************************/
|
|
45
|
-
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
46
|
-
|
|
47
|
-
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ EmittersCanvasShapeGenerator: () => (/* binding */ EmittersCanvasShapeGenerator)\n/* harmony export */ });\n/* harmony import */ var _EmittersCanvasShape_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./EmittersCanvasShape.js */ \"./dist/browser/EmittersCanvasShape.js\");\n/* harmony import */ var _Options_Classes_EmittersCanvasShapeOptions_js__WEBPACK_IMPORTED_MODULE_1__ = __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_1__.EmittersCanvasShapeOptions();\n shapeOptions.load(options);\n return new _EmittersCanvasShape_js__WEBPACK_IMPORTED_MODULE_0__.EmittersCanvasShape(position, size, fill, shapeOptions);\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-emitters-shape-canvas/./dist/browser/EmittersCanvasShapeGenerator.js?\n}");
|
|
48
|
-
|
|
49
|
-
/***/ }),
|
|
50
|
-
|
|
51
|
-
/***/ "./dist/browser/Options/Classes/EmittersCanvasShapeOptions.js":
|
|
52
|
-
/*!********************************************************************!*\
|
|
53
|
-
!*** ./dist/browser/Options/Classes/EmittersCanvasShapeOptions.js ***!
|
|
54
|
-
\********************************************************************/
|
|
55
|
-
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
56
|
-
|
|
57
|
-
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 _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/* harmony import */ var _PixelsOptions_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./PixelsOptions.js */ \"./dist/browser/Options/Classes/PixelsOptions.js\");\n/* harmony import */ var _TextOptions_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./TextOptions.js */ \"./dist/browser/Options/Classes/TextOptions.js\");\n\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_1__.PixelsOptions();\n this.scale = 1;\n this.selector = \"\";\n this.text = new _TextOptions_js__WEBPACK_IMPORTED_MODULE_2__.TextOptions();\n }\n load(data) {\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isNull)(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?\n}");
|
|
58
|
-
|
|
59
|
-
/***/ }),
|
|
60
|
-
|
|
61
|
-
/***/ "./dist/browser/Options/Classes/PixelsOptions.js":
|
|
62
|
-
/*!*******************************************************!*\
|
|
63
|
-
!*** ./dist/browser/Options/Classes/PixelsOptions.js ***!
|
|
64
|
-
\*******************************************************/
|
|
65
|
-
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
66
|
-
|
|
67
|
-
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PixelsOptions: () => (/* binding */ PixelsOptions)\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\nclass PixelsOptions {\n constructor() {\n this.offset = 4;\n }\n load(data) {\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isNull)(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?\n}");
|
|
68
|
-
|
|
69
|
-
/***/ }),
|
|
70
|
-
|
|
71
|
-
/***/ "./dist/browser/Options/Classes/TextFontOptions.js":
|
|
72
|
-
/*!*********************************************************!*\
|
|
73
|
-
!*** ./dist/browser/Options/Classes/TextFontOptions.js ***!
|
|
74
|
-
\*********************************************************/
|
|
75
|
-
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
76
|
-
|
|
77
|
-
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ TextFontOptions: () => (/* binding */ TextFontOptions)\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\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 ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isNull)(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?\n}");
|
|
78
|
-
|
|
79
|
-
/***/ }),
|
|
80
|
-
|
|
81
|
-
/***/ "./dist/browser/Options/Classes/TextLinesOptions.js":
|
|
82
|
-
/*!**********************************************************!*\
|
|
83
|
-
!*** ./dist/browser/Options/Classes/TextLinesOptions.js ***!
|
|
84
|
-
\**********************************************************/
|
|
85
|
-
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
86
|
-
|
|
87
|
-
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ TextLinesOptions: () => (/* binding */ TextLinesOptions)\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\nclass TextLinesOptions {\n constructor() {\n this.separator = \"\\n\";\n this.spacing = 0;\n }\n load(data) {\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isNull)(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?\n}");
|
|
88
|
-
|
|
89
|
-
/***/ }),
|
|
90
|
-
|
|
91
|
-
/***/ "./dist/browser/Options/Classes/TextOptions.js":
|
|
92
|
-
/*!*****************************************************!*\
|
|
93
|
-
!*** ./dist/browser/Options/Classes/TextOptions.js ***!
|
|
94
|
-
\*****************************************************/
|
|
95
|
-
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
96
|
-
|
|
97
|
-
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 _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/* harmony import */ var _TextFontOptions_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./TextFontOptions.js */ \"./dist/browser/Options/Classes/TextFontOptions.js\");\n/* harmony import */ var _TextLinesOptions_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./TextLinesOptions.js */ \"./dist/browser/Options/Classes/TextLinesOptions.js\");\n\n\n\nclass TextOptions {\n constructor() {\n this.color = \"#000000\";\n this.font = new _TextFontOptions_js__WEBPACK_IMPORTED_MODULE_1__.TextFontOptions();\n this.lines = new _TextLinesOptions_js__WEBPACK_IMPORTED_MODULE_2__.TextLinesOptions();\n this.text = \"\";\n }\n load(data) {\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isNull)(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?\n}");
|
|
98
|
-
|
|
99
|
-
/***/ }),
|
|
100
|
-
|
|
101
|
-
/***/ "./dist/browser/index.js":
|
|
31
|
+
/***/ "./dist/browser/index.js"
|
|
102
32
|
/*!*******************************!*\
|
|
103
33
|
!*** ./dist/browser/index.js ***!
|
|
104
34
|
\*******************************/
|
|
105
|
-
|
|
35
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
106
36
|
|
|
107
|
-
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadEmittersShapeCanvas: () => (/* binding */ loadEmittersShapeCanvas)\n/* harmony export */ });\n
|
|
37
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadEmittersShapeCanvas: () => (/* binding */ loadEmittersShapeCanvas)\n/* harmony export */ });\nfunction loadEmittersShapeCanvas(engine) {\n engine.checkVersion(\"4.0.0-alpha.0\");\n engine.register(async emittersEngine => {\n const {\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 });\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-emitters-shape-canvas/./dist/browser/index.js?\n}");
|
|
108
38
|
|
|
109
|
-
/***/ }
|
|
39
|
+
/***/ },
|
|
110
40
|
|
|
111
|
-
/***/ "
|
|
112
|
-
/*!*******************************!*\
|
|
113
|
-
!*** ./dist/browser/utils.js ***!
|
|
114
|
-
\*******************************/
|
|
115
|
-
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
116
|
-
|
|
117
|
-
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?\n}");
|
|
118
|
-
|
|
119
|
-
/***/ }),
|
|
120
|
-
|
|
121
|
-
/***/ "@tsparticles/engine":
|
|
41
|
+
/***/ "@tsparticles/engine"
|
|
122
42
|
/*!*********************************************************************************************************************************!*\
|
|
123
43
|
!*** external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"} ***!
|
|
124
44
|
\*********************************************************************************************************************************/
|
|
125
|
-
|
|
45
|
+
(module) {
|
|
126
46
|
|
|
127
47
|
module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
|
|
128
48
|
|
|
129
|
-
/***/ }
|
|
49
|
+
/***/ },
|
|
130
50
|
|
|
131
|
-
/***/ "@tsparticles/plugin-emitters"
|
|
51
|
+
/***/ "@tsparticles/plugin-emitters"
|
|
132
52
|
/*!************************************************************************************************************************************************************!*\
|
|
133
53
|
!*** external {"commonjs":"@tsparticles/plugin-emitters","commonjs2":"@tsparticles/plugin-emitters","amd":"@tsparticles/plugin-emitters","root":"window"} ***!
|
|
134
54
|
\************************************************************************************************************************************************************/
|
|
135
|
-
|
|
55
|
+
(module) {
|
|
136
56
|
|
|
137
57
|
module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_plugin_emitters__;
|
|
138
58
|
|
|
139
|
-
/***/ }
|
|
59
|
+
/***/ }
|
|
140
60
|
|
|
141
61
|
/******/ });
|
|
142
62
|
/************************************************************************/
|
|
@@ -150,6 +70,12 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_plugin_emitters__;
|
|
|
150
70
|
/******/ if (cachedModule !== undefined) {
|
|
151
71
|
/******/ return cachedModule.exports;
|
|
152
72
|
/******/ }
|
|
73
|
+
/******/ // Check if module exists (development only)
|
|
74
|
+
/******/ if (__webpack_modules__[moduleId] === undefined) {
|
|
75
|
+
/******/ var e = new Error("Cannot find module '" + moduleId + "'");
|
|
76
|
+
/******/ e.code = 'MODULE_NOT_FOUND';
|
|
77
|
+
/******/ throw e;
|
|
78
|
+
/******/ }
|
|
153
79
|
/******/ // Create a new module (and put it into the cache)
|
|
154
80
|
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
155
81
|
/******/ // no module.id needed
|
|
@@ -164,19 +90,10 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_plugin_emitters__;
|
|
|
164
90
|
/******/ return module.exports;
|
|
165
91
|
/******/ }
|
|
166
92
|
/******/
|
|
167
|
-
|
|
168
|
-
/******/
|
|
169
|
-
/******/ (() => {
|
|
170
|
-
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
171
|
-
/******/ __webpack_require__.n = (module) => {
|
|
172
|
-
/******/ var getter = module && module.__esModule ?
|
|
173
|
-
/******/ () => (module['default']) :
|
|
174
|
-
/******/ () => (module);
|
|
175
|
-
/******/ __webpack_require__.d(getter, { a: getter });
|
|
176
|
-
/******/ return getter;
|
|
177
|
-
/******/ };
|
|
178
|
-
/******/ })();
|
|
93
|
+
/******/ // expose the modules object (__webpack_modules__)
|
|
94
|
+
/******/ __webpack_require__.m = __webpack_modules__;
|
|
179
95
|
/******/
|
|
96
|
+
/************************************************************************/
|
|
180
97
|
/******/ /* webpack/runtime/define property getters */
|
|
181
98
|
/******/ (() => {
|
|
182
99
|
/******/ // define getter functions for harmony exports
|
|
@@ -189,11 +106,90 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_plugin_emitters__;
|
|
|
189
106
|
/******/ };
|
|
190
107
|
/******/ })();
|
|
191
108
|
/******/
|
|
109
|
+
/******/ /* webpack/runtime/ensure chunk */
|
|
110
|
+
/******/ (() => {
|
|
111
|
+
/******/ __webpack_require__.f = {};
|
|
112
|
+
/******/ // This file contains only the entry chunk.
|
|
113
|
+
/******/ // The chunk loading function for additional chunks
|
|
114
|
+
/******/ __webpack_require__.e = (chunkId) => {
|
|
115
|
+
/******/ return Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key) => {
|
|
116
|
+
/******/ __webpack_require__.f[key](chunkId, promises);
|
|
117
|
+
/******/ return promises;
|
|
118
|
+
/******/ }, []));
|
|
119
|
+
/******/ };
|
|
120
|
+
/******/ })();
|
|
121
|
+
/******/
|
|
122
|
+
/******/ /* webpack/runtime/get javascript chunk filename */
|
|
123
|
+
/******/ (() => {
|
|
124
|
+
/******/ // This function allow to reference async chunks
|
|
125
|
+
/******/ __webpack_require__.u = (chunkId) => {
|
|
126
|
+
/******/ // return url for filenames based on template
|
|
127
|
+
/******/ return "" + chunkId + ".js";
|
|
128
|
+
/******/ };
|
|
129
|
+
/******/ })();
|
|
130
|
+
/******/
|
|
131
|
+
/******/ /* webpack/runtime/global */
|
|
132
|
+
/******/ (() => {
|
|
133
|
+
/******/ __webpack_require__.g = (function() {
|
|
134
|
+
/******/ if (typeof globalThis === 'object') return globalThis;
|
|
135
|
+
/******/ try {
|
|
136
|
+
/******/ return this || new Function('return this')();
|
|
137
|
+
/******/ } catch (e) {
|
|
138
|
+
/******/ if (typeof window === 'object') return window;
|
|
139
|
+
/******/ }
|
|
140
|
+
/******/ })();
|
|
141
|
+
/******/ })();
|
|
142
|
+
/******/
|
|
192
143
|
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
193
144
|
/******/ (() => {
|
|
194
145
|
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
195
146
|
/******/ })();
|
|
196
147
|
/******/
|
|
148
|
+
/******/ /* webpack/runtime/load script */
|
|
149
|
+
/******/ (() => {
|
|
150
|
+
/******/ var inProgress = {};
|
|
151
|
+
/******/ var dataWebpackPrefix = "@tsparticles/plugin-emitters-shape-canvas:";
|
|
152
|
+
/******/ // loadScript function to load a script via script tag
|
|
153
|
+
/******/ __webpack_require__.l = (url, done, key, chunkId) => {
|
|
154
|
+
/******/ if(inProgress[url]) { inProgress[url].push(done); return; }
|
|
155
|
+
/******/ var script, needAttach;
|
|
156
|
+
/******/ if(key !== undefined) {
|
|
157
|
+
/******/ var scripts = document.getElementsByTagName("script");
|
|
158
|
+
/******/ for(var i = 0; i < scripts.length; i++) {
|
|
159
|
+
/******/ var s = scripts[i];
|
|
160
|
+
/******/ if(s.getAttribute("src") == url || s.getAttribute("data-webpack") == dataWebpackPrefix + key) { script = s; break; }
|
|
161
|
+
/******/ }
|
|
162
|
+
/******/ }
|
|
163
|
+
/******/ if(!script) {
|
|
164
|
+
/******/ needAttach = true;
|
|
165
|
+
/******/ script = document.createElement('script');
|
|
166
|
+
/******/
|
|
167
|
+
/******/ script.charset = 'utf-8';
|
|
168
|
+
/******/ if (__webpack_require__.nc) {
|
|
169
|
+
/******/ script.setAttribute("nonce", __webpack_require__.nc);
|
|
170
|
+
/******/ }
|
|
171
|
+
/******/ script.setAttribute("data-webpack", dataWebpackPrefix + key);
|
|
172
|
+
/******/
|
|
173
|
+
/******/ script.src = url;
|
|
174
|
+
/******/ }
|
|
175
|
+
/******/ inProgress[url] = [done];
|
|
176
|
+
/******/ var onScriptComplete = (prev, event) => {
|
|
177
|
+
/******/ // avoid mem leaks in IE.
|
|
178
|
+
/******/ script.onerror = script.onload = null;
|
|
179
|
+
/******/ clearTimeout(timeout);
|
|
180
|
+
/******/ var doneFns = inProgress[url];
|
|
181
|
+
/******/ delete inProgress[url];
|
|
182
|
+
/******/ script.parentNode && script.parentNode.removeChild(script);
|
|
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
|
+
/******/
|
|
197
193
|
/******/ /* webpack/runtime/make namespace object */
|
|
198
194
|
/******/ (() => {
|
|
199
195
|
/******/ // define __esModule on exports
|
|
@@ -205,6 +201,119 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_plugin_emitters__;
|
|
|
205
201
|
/******/ };
|
|
206
202
|
/******/ })();
|
|
207
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.emitters.shape.canvas": 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_emitters_shape_canvas"] = this["webpackChunk_tsparticles_plugin_emitters_shape_canvas"] || [];
|
|
313
|
+
/******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));
|
|
314
|
+
/******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));
|
|
315
|
+
/******/ })();
|
|
316
|
+
/******/
|
|
208
317
|
/************************************************************************/
|
|
209
318
|
/******/
|
|
210
319
|
/******/ // startup
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see tsparticles.plugin.emitters.shape.canvas.min.js.LICENSE.txt */
|
|
2
|
-
!function(t
|
|
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={303(e){e.exports=t},526(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",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&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName("script");if(r.length)for(var i=r.length-1;i>-1&&(!e||!/^http(s?):/.test(e));)e=r[i--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),a.p=e})(),(()=>{var e={346: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,s,p]=r,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={};function p(e){e.checkVersion("4.0.0-alpha.0"),e.register((async e=>{const{EmittersCanvasShapeGenerator:t}=await a.e(355).then(a.bind(a,355));e.addEmitterShapeGenerator?.("canvas",new t)}))}return a.r(s),a.d(s,{loadEmittersShapeCanvas:()=>p}),s})()));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
/*! tsParticles Emitters Shape Canvas Plugin
|
|
1
|
+
/*! tsParticles Emitters Shape Canvas Plugin v4.0.0-alpha.0 by Matteo Bruni */
|
|
@@ -11,5 +11,5 @@ export declare class EmittersCanvasShapeOptions implements IEmittersCanvasShapeO
|
|
|
11
11
|
selector: string;
|
|
12
12
|
text: TextOptions;
|
|
13
13
|
constructor();
|
|
14
|
-
load(data?: RecursivePartial<IEmittersCanvasShapeOptions>
|
|
14
|
+
load(data?: RecursivePartial<IEmittersCanvasShapeOptions>): void;
|
|
15
15
|
}
|
|
@@ -3,5 +3,5 @@ import type { IPixelsOptions } from "../Interfaces/IPixelsOptions.js";
|
|
|
3
3
|
export declare class PixelsOptions implements IPixelsOptions, IOptionLoader<IPixelsOptions> {
|
|
4
4
|
offset: number;
|
|
5
5
|
constructor();
|
|
6
|
-
load(data?: RecursivePartial<IPixelsOptions>
|
|
6
|
+
load(data?: RecursivePartial<IPixelsOptions>): void;
|
|
7
7
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { type Engine } from "@tsparticles/engine";
|
|
2
|
-
export declare function loadEmittersShapeCanvas(engine: Engine
|
|
2
|
+
export declare function loadEmittersShapeCanvas(engine: Engine): void;
|
|
@@ -19,18 +19,16 @@
|
|
|
19
19
|
super(position, size, fill, options);
|
|
20
20
|
const filter = options.filter, minAlpha = 0;
|
|
21
21
|
let filterFunc = (pixel) => pixel.a > minAlpha;
|
|
22
|
-
if (
|
|
23
|
-
if ((
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
filterFunc = wndFilter;
|
|
28
|
-
}
|
|
22
|
+
if ((0, engine_1.isString)(filter)) {
|
|
23
|
+
if (Object.hasOwn(globalThis, filter)) {
|
|
24
|
+
const wndFilter = globalThis[filter];
|
|
25
|
+
if ((0, engine_1.isFunction)(wndFilter)) {
|
|
26
|
+
filterFunc = wndFilter;
|
|
29
27
|
}
|
|
30
28
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
filterFunc = filter;
|
|
34
32
|
}
|
|
35
33
|
this.filter = filterFunc;
|
|
36
34
|
this.scale = options.scale;
|
|
@@ -50,15 +48,8 @@
|
|
|
50
48
|
}
|
|
51
49
|
pixelData = await (0, utils_js_1.getImageData)(url, offset);
|
|
52
50
|
}
|
|
53
|
-
else if (text) {
|
|
54
|
-
const data = (0, utils_js_1.getTextData)(text, offset, this.fill);
|
|
55
|
-
if ((0, engine_1.isNull)(data)) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
pixelData = data;
|
|
59
|
-
}
|
|
60
51
|
else if (element ?? selector) {
|
|
61
|
-
const canvas = element ?? (selector &&
|
|
52
|
+
const canvas = element ?? (selector && (0, engine_1.safeDocument)().querySelector(selector));
|
|
62
53
|
if (!canvas) {
|
|
63
54
|
return;
|
|
64
55
|
}
|
|
@@ -68,8 +59,12 @@
|
|
|
68
59
|
}
|
|
69
60
|
pixelData = (0, utils_js_1.getCanvasImageData)(context, canvas, offset);
|
|
70
61
|
}
|
|
71
|
-
|
|
72
|
-
|
|
62
|
+
else {
|
|
63
|
+
const data = (0, utils_js_1.getTextData)(text, offset, this.fill);
|
|
64
|
+
if ((0, engine_1.isNull)(data)) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
pixelData = data;
|
|
73
68
|
}
|
|
74
69
|
this.pixelData = pixelData;
|
|
75
70
|
}
|
|
@@ -82,7 +77,15 @@
|
|
|
82
77
|
const nextIndex = Math.floor((0, engine_1.getRandom)() * width * height), pixelPos = {
|
|
83
78
|
x: nextIndex % width,
|
|
84
79
|
y: Math.floor(nextIndex / width),
|
|
85
|
-
},
|
|
80
|
+
}, row = data.pixels[pixelPos.y];
|
|
81
|
+
if (!row) {
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
const pixel = row[pixelPos.x];
|
|
85
|
+
if (!pixel) {
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
const shouldCreateParticle = this.filter(pixel);
|
|
86
89
|
if (!shouldCreateParticle) {
|
|
87
90
|
continue;
|
|
88
91
|
}
|