@tsparticles/plugin-emitters-shape-path 4.0.0-beta.0 → 4.0.0-beta.10

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/16.min.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";(this.webpackChunk_tsparticles_plugin_emitters_shape_path=this.webpackChunk_tsparticles_plugin_emitters_shape_path||[]).push([[16],{16(t,e,i){i.d(e,{EmittersPathShapeGenerator:()=>s});var n=i(303),o=i(526);class h extends o.EmitterShapeBase{checkContext;path;points;constructor(t,e,i,o,h){super(e,i,o,h);const a=(0,n.safeDocument)().createElement("canvas").getContext("2d",t.canvas.render.settings);if(!a)throw Error("No 2d context available");this.checkContext=a,this.points=h.points;const s=this.points,r=new Path2D,l={x:e.x-i.width*n.half,y:e.y-i.height*n.half};for(const[t,e]of s.entries()){const o={x:l.x+e.x*i.width/n.percentDenominator,y:l.y+e.y*i.height/n.percentDenominator};t?r.lineTo(o.x,o.y):r.moveTo(o.x,o.y)}const p=s[0];if(!p)throw Error("No path data available");const c={x:l.x+p.x*i.width/n.percentDenominator,y:l.y+p.y*i.height/n.percentDenominator};r.lineTo(c.x,c.y),this.path=r}async init(){}randomPosition(){let t=this.checkContext,e=this.position,i=this.size,o=this.fill,h=this.path,a=o?function(t,e,i,o){let h=null;for(let a=0;a<100;a++){let a={x:i.x+(0,n.getRandom)()*o.width-o.width*n.half,y:i.y+(0,n.getRandom)()*o.height-o.height*n.half};if(t.isPointInPath(e,a.x,a.y)){h=a;break}}return h}(t,h,e,i):function(t,e,i,o){let h=null;for(let a=0;a<100;a++){let a={x:i.x+(0,n.getRandom)()*o.width-o.width*n.half,y:i.y+(0,n.getRandom)()*o.height-o.height*n.half};if(t.isPointInStroke(e,a.x,a.y)){h=a;break}}return h}(t,h,e,i);return a?{position:a}:null}resize(t,e){super.resize(t,e);let i=this.points,o=new Path2D,h={x:t.x-e.width*n.half,y:t.y-e.height*n.half};for(let[t,a]of i.entries()){let i={x:h.x+a.x*e.width/n.percentDenominator,y:h.y+a.y*e.height/n.percentDenominator};t?o.lineTo(i.x,i.y):o.moveTo(i.x,i.y)}let a=i[0];if(!a)throw Error("No path data available");let s={x:h.x+a.x*e.width/n.percentDenominator,y:h.y+a.y*e.height/n.percentDenominator};o.lineTo(s.x,s.y),this.path=o}}class a{points;constructor(){this.points=[]}load(t){(0,n.isNull)(t)||void 0!==t.points&&(this.points=t.points.map(t=>({x:t.x??50,y:t.y??50})))}}class s{generate(t,e,i,n,o){let s=new a;return s.load(o),new h(t,e,i,n,s)}}}}]);
package/README.md CHANGED
@@ -8,6 +8,12 @@
8
8
 
9
9
  [tsParticles](https://github.com/tsparticles/tsparticles) plugin for adding the emitters shape path support.
10
10
 
11
+ ## Quick checklist
12
+
13
+ 1. Install `@tsparticles/engine` (or use the CDN bundle below)
14
+ 2. Call the package loader function(s) before `tsParticles.load(...)`
15
+ 3. Apply the package options in your `tsParticles.load(...)` config
16
+
11
17
  ## How to use it
12
18
 
13
19
  ### CDN / Vanilla JS / jQuery
@@ -77,3 +83,19 @@ import { loadEmittersShapePathPlugin } from "@tsparticles/plugin-emitters-shape-
77
83
  await loadEmittersShapePathPlugin(tsParticles);
78
84
  })();
79
85
  ```
86
+
87
+ ## Option mapping
88
+
89
+ - This package primarily extends runtime behavior or rendering and may not expose a single dedicated root options key.
90
+ - Use the usage example in this README and combine with the nearest options section in the docs.
91
+
92
+ ## Common pitfalls
93
+
94
+ - Calling `tsParticles.load(...)` before `loadEmittersPlugin(...)`
95
+ - Verify required peer packages before enabling advanced options
96
+ - Change one option group at a time to isolate regressions quickly
97
+
98
+ ## Related docs
99
+
100
+ - All packages catalog: <https://github.com/tsparticles/tsparticles>
101
+ - Main docs: <https://particles.js.org/docs/>
@@ -7,7 +7,7 @@ export class EmittersPathShape extends EmitterShapeBase {
7
7
  points;
8
8
  constructor(container, position, size, fill, options) {
9
9
  super(position, size, fill, options);
10
- const ctx = safeDocument().createElement("canvas").getContext("2d", container.canvas.settings);
10
+ const ctx = safeDocument().createElement("canvas").getContext("2d", container.canvas.render.settings);
11
11
  if (!ctx) {
12
12
  throw new Error(`No 2d context available`);
13
13
  }
package/browser/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  export async function loadEmittersShapePath(engine) {
2
- engine.checkVersion("4.0.0-beta.0");
3
- await engine.register(async (e) => {
2
+ engine.checkVersion("4.0.0-beta.10");
3
+ await engine.pluginManager.register(async (e) => {
4
4
  const { ensureEmittersPluginLoaded } = await import("@tsparticles/plugin-emitters");
5
5
  ensureEmittersPluginLoaded(e);
6
6
  const { EmittersPathShapeGenerator } = await import("./EmittersPathShapeGenerator.js");
7
- e.addEmitterShapeGenerator?.("path", new EmittersPathShapeGenerator());
7
+ e.pluginManager.addEmitterShapeGenerator?.("path", new EmittersPathShapeGenerator());
8
8
  });
9
9
  }
@@ -7,7 +7,7 @@ export class EmittersPathShape extends EmitterShapeBase {
7
7
  points;
8
8
  constructor(container, position, size, fill, options) {
9
9
  super(position, size, fill, options);
10
- const ctx = safeDocument().createElement("canvas").getContext("2d", container.canvas.settings);
10
+ const ctx = safeDocument().createElement("canvas").getContext("2d", container.canvas.render.settings);
11
11
  if (!ctx) {
12
12
  throw new Error(`No 2d context available`);
13
13
  }
package/cjs/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  export async function loadEmittersShapePath(engine) {
2
- engine.checkVersion("4.0.0-beta.0");
3
- await engine.register(async (e) => {
2
+ engine.checkVersion("4.0.0-beta.10");
3
+ await engine.pluginManager.register(async (e) => {
4
4
  const { ensureEmittersPluginLoaded } = await import("@tsparticles/plugin-emitters");
5
5
  ensureEmittersPluginLoaded(e);
6
6
  const { EmittersPathShapeGenerator } = await import("./EmittersPathShapeGenerator.js");
7
- e.addEmitterShapeGenerator?.("path", new EmittersPathShapeGenerator());
7
+ e.pluginManager.addEmitterShapeGenerator?.("path", new EmittersPathShapeGenerator());
8
8
  });
9
9
  }
@@ -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
- * v4.0.0-beta.0
7
+ * v4.0.0-beta.10
8
8
  */
9
9
  "use strict";
10
10
  /*
@@ -23,7 +23,7 @@
23
23
  \*******************************************/
24
24
  (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
25
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.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}");
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
27
 
28
28
  /***/ },
29
29
 
@@ -7,7 +7,7 @@ export class EmittersPathShape extends EmitterShapeBase {
7
7
  points;
8
8
  constructor(container, position, size, fill, options) {
9
9
  super(position, size, fill, options);
10
- const ctx = safeDocument().createElement("canvas").getContext("2d", container.canvas.settings);
10
+ const ctx = safeDocument().createElement("canvas").getContext("2d", container.canvas.render.settings);
11
11
  if (!ctx) {
12
12
  throw new Error(`No 2d context available`);
13
13
  }
package/esm/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  export async function loadEmittersShapePath(engine) {
2
- engine.checkVersion("4.0.0-beta.0");
3
- await engine.register(async (e) => {
2
+ engine.checkVersion("4.0.0-beta.10");
3
+ await engine.pluginManager.register(async (e) => {
4
4
  const { ensureEmittersPluginLoaded } = await import("@tsparticles/plugin-emitters");
5
5
  ensureEmittersPluginLoaded(e);
6
6
  const { EmittersPathShapeGenerator } = await import("./EmittersPathShapeGenerator.js");
7
- e.addEmitterShapeGenerator?.("path", new EmittersPathShapeGenerator());
7
+ e.pluginManager.addEmitterShapeGenerator?.("path", new EmittersPathShapeGenerator());
8
8
  });
9
9
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/plugin-emitters-shape-path",
3
- "version": "4.0.0-beta.0",
3
+ "version": "4.0.0-beta.10",
4
4
  "description": "tsParticles emitters shape path plugin",
5
5
  "homepage": "https://particles.js.org",
6
6
  "repository": {
@@ -94,14 +94,13 @@
94
94
  "browser": "./browser/index.js",
95
95
  "import": "./esm/index.js",
96
96
  "require": "./cjs/index.js",
97
- "umd": "./umd/index.js",
98
- "default": "./cjs/index.js"
97
+ "default": "./esm/index.js"
99
98
  },
100
99
  "./package.json": "./package.json"
101
100
  },
102
- "dependencies": {
103
- "@tsparticles/engine": "4.0.0-beta.0",
104
- "@tsparticles/plugin-emitters": "4.0.0-beta.0"
101
+ "peerDependencies": {
102
+ "@tsparticles/engine": "4.0.0-beta.10",
103
+ "@tsparticles/plugin-emitters": "4.0.0-beta.10"
105
104
  },
106
105
  "publishConfig": {
107
106
  "access": "public"