@tsparticles/plugin-emitters-shape-path 4.0.0-beta.9 → 4.0.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/browser/browser.js +5 -0
- package/browser/index.js +4 -4
- package/browser/index.lazy.js +9 -0
- package/cjs/browser.js +5 -0
- package/cjs/index.js +4 -4
- package/cjs/index.lazy.js +9 -0
- package/esm/browser.js +5 -0
- package/esm/index.js +4 -4
- package/esm/index.lazy.js +9 -0
- package/package.json +11 -4
- package/report.html +4949 -94
- package/tsparticles.plugin.emitters.shape.path.js +149 -349
- package/tsparticles.plugin.emitters.shape.path.min.js +1 -2
- package/types/EmittersPathShape.d.ts +2 -2
- package/types/browser.d.ts +1 -0
- package/types/index.lazy.d.ts +2 -0
- package/types/utils.d.ts +3 -3
- package/16.min.js +0 -1
- package/dist_browser_EmittersPathShapeGenerator_js.js +0 -60
|
@@ -1,60 +0,0 @@
|
|
|
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
|
-
* v4.0.0-beta.9
|
|
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_path"] = this["webpackChunk_tsparticles_plugin_emitters_shape_path"] || []).push([["dist_browser_EmittersPathShapeGenerator_js"],{
|
|
19
|
-
|
|
20
|
-
/***/ "./dist/browser/EmittersPathShape.js"
|
|
21
|
-
/*!*******************************************!*\
|
|
22
|
-
!*** ./dist/browser/EmittersPathShape.js ***!
|
|
23
|
-
\*******************************************/
|
|
24
|
-
(__unused_webpack___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 */ EmittersPathShape: () => (/* binding */ EmittersPathShape)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_plugin_emitters__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @tsparticles/plugin-emitters */ \"@tsparticles/plugin-emitters\");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./utils.js */ \"./dist/browser/utils.js\");\n\n\n\nclass EmittersPathShape extends _tsparticles_plugin_emitters__WEBPACK_IMPORTED_MODULE_1__.EmitterShapeBase {\n checkContext;\n path;\n points;\n constructor(container, position, size, fill, options){\n super(position, size, fill, options);\n const ctx = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.safeDocument)().createElement(\"canvas\").getContext(\"2d\", container.canvas.render.settings);\n if (!ctx) {\n throw new Error(`No 2d context available`);\n }\n this.checkContext = ctx;\n this.points = options.points;\n const pathData = this.points, path = new Path2D(), offset = {\n x: position.x - size.width * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.half,\n y: position.y - size.height * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.half\n };\n for (const [index, point] of pathData.entries()){\n const coords = {\n x: offset.x + point.x * size.width / _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.percentDenominator,\n y: offset.y + point.y * size.height / _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.percentDenominator\n };\n if (!index) {\n path.moveTo(coords.x, coords.y);\n } else {\n path.lineTo(coords.x, coords.y);\n }\n }\n const firstIndex = 0, firstPathData = pathData[firstIndex];\n if (!firstPathData) {\n throw new Error(`No path data available`);\n }\n const coords = {\n x: offset.x + firstPathData.x * size.width / _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.percentDenominator,\n y: offset.y + firstPathData.y * size.height / _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.percentDenominator\n };\n path.lineTo(coords.x, coords.y);\n this.path = path;\n }\n async init() {}\n randomPosition() {\n const ctx = this.checkContext, position = this.position, size = this.size, fill = this.fill, path = this.path, res = fill ? (0,_utils_js__WEBPACK_IMPORTED_MODULE_2__.generateRandomPointWithinPath)(ctx, path, position, size) : (0,_utils_js__WEBPACK_IMPORTED_MODULE_2__.generateRandomPointOnPathPerimeter)(ctx, path, position, size);\n return res ? {\n position: res\n } : null;\n }\n resize(position, size) {\n super.resize(position, size);\n const pathData = this.points, path = new Path2D(), offset = {\n x: position.x - size.width * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.half,\n y: position.y - size.height * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.half\n };\n for (const [index, point] of pathData.entries()){\n const coords = {\n x: offset.x + point.x * size.width / _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.percentDenominator,\n y: offset.y + point.y * size.height / _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.percentDenominator\n };\n if (!index) {\n path.moveTo(coords.x, coords.y);\n } else {\n path.lineTo(coords.x, coords.y);\n }\n }\n const firstIndex = 0, firstPathData = pathData[firstIndex];\n if (!firstPathData) {\n throw new Error(`No path data available`);\n }\n const coords = {\n x: offset.x + firstPathData.x * size.width / _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.percentDenominator,\n y: offset.y + firstPathData.y * size.height / _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.percentDenominator\n };\n path.lineTo(coords.x, coords.y);\n this.path = path;\n }\n}\n\n\n//# sourceURL=webpack://@tsparticles/plugin-emitters-shape-path/./dist/browser/EmittersPathShape.js?\n}");
|
|
27
|
-
|
|
28
|
-
/***/ },
|
|
29
|
-
|
|
30
|
-
/***/ "./dist/browser/EmittersPathShapeGenerator.js"
|
|
31
|
-
/*!****************************************************!*\
|
|
32
|
-
!*** ./dist/browser/EmittersPathShapeGenerator.js ***!
|
|
33
|
-
\****************************************************/
|
|
34
|
-
(__unused_webpack___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 */ EmittersPathShapeGenerator: () => (/* binding */ EmittersPathShapeGenerator)\n/* harmony export */ });\n/* harmony import */ var _EmittersPathShape_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./EmittersPathShape.js */ \"./dist/browser/EmittersPathShape.js\");\n/* harmony import */ var _Options_Classes_EmittersPathShapeOptions_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Options/Classes/EmittersPathShapeOptions.js */ \"./dist/browser/Options/Classes/EmittersPathShapeOptions.js\");\n\n\nclass EmittersPathShapeGenerator {\n generate(container, position, size, fill, options) {\n const shapeOptions = new _Options_Classes_EmittersPathShapeOptions_js__WEBPACK_IMPORTED_MODULE_1__.EmittersPathShapeOptions();\n shapeOptions.load(options);\n return new _EmittersPathShape_js__WEBPACK_IMPORTED_MODULE_0__.EmittersPathShape(container, position, size, fill, shapeOptions);\n }\n}\n\n\n//# sourceURL=webpack://@tsparticles/plugin-emitters-shape-path/./dist/browser/EmittersPathShapeGenerator.js?\n}");
|
|
37
|
-
|
|
38
|
-
/***/ },
|
|
39
|
-
|
|
40
|
-
/***/ "./dist/browser/Options/Classes/EmittersPathShapeOptions.js"
|
|
41
|
-
/*!******************************************************************!*\
|
|
42
|
-
!*** ./dist/browser/Options/Classes/EmittersPathShapeOptions.js ***!
|
|
43
|
-
\******************************************************************/
|
|
44
|
-
(__unused_webpack___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 */ EmittersPathShapeOptions: () => (/* binding */ EmittersPathShapeOptions)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nconst defaultPosition = {\n x: 50,\n y: 50\n};\nclass EmittersPathShapeOptions {\n points;\n constructor(){\n this.points = [];\n }\n load(data) {\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isNull)(data)) {\n return;\n }\n if (data.points !== undefined) {\n this.points = data.points.map((t)=>({\n x: t.x ?? defaultPosition.x,\n y: t.y ?? defaultPosition.y\n }));\n }\n }\n}\n\n\n//# sourceURL=webpack://@tsparticles/plugin-emitters-shape-path/./dist/browser/Options/Classes/EmittersPathShapeOptions.js?\n}");
|
|
47
|
-
|
|
48
|
-
/***/ },
|
|
49
|
-
|
|
50
|
-
/***/ "./dist/browser/utils.js"
|
|
51
|
-
/*!*******************************!*\
|
|
52
|
-
!*** ./dist/browser/utils.js ***!
|
|
53
|
-
\*******************************/
|
|
54
|
-
(__unused_webpack___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 */ generateRandomPointOnPathPerimeter: () => (/* binding */ generateRandomPointOnPathPerimeter),\n/* harmony export */ generateRandomPointWithinPath: () => (/* binding */ generateRandomPointWithinPath)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nconst maxAttempts = 100;\nfunction generateRandomPointWithinPath(ctx, path, center, size) {\n let randomPoint = null;\n for(let attempts = 0; attempts < maxAttempts; attempts++){\n const tmpPoint = {\n x: center.x + (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)() * size.width - size.width * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.half,\n y: center.y + (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)() * size.height - size.height * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.half\n };\n if (ctx.isPointInPath(path, tmpPoint.x, tmpPoint.y)) {\n randomPoint = tmpPoint;\n break;\n }\n }\n return randomPoint;\n}\nfunction generateRandomPointOnPathPerimeter(ctx, path, center, size) {\n let randomPoint = null;\n for(let attempts = 0; attempts < maxAttempts; attempts++){\n const tmpPoint = {\n x: center.x + (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)() * size.width - size.width * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.half,\n y: center.y + (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)() * size.height - size.height * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.half\n };\n if (ctx.isPointInStroke(path, tmpPoint.x, tmpPoint.y)) {\n randomPoint = tmpPoint;\n break;\n }\n }\n return randomPoint;\n}\n\n\n//# sourceURL=webpack://@tsparticles/plugin-emitters-shape-path/./dist/browser/utils.js?\n}");
|
|
57
|
-
|
|
58
|
-
/***/ }
|
|
59
|
-
|
|
60
|
-
}]);
|