@tsparticles/effect-shadow 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/170.min.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";(this.webpackChunk_tsparticles_effect_shadow=this.webpackChunk_tsparticles_effect_shadow||[]).push([[170],{170(o,e,t){t.d(e,{ShadowDrawer:()=>r});var a=t(303);class r{_container;_pluginManager;constructor(o,e){this._pluginManager=o,this._container=e}drawAfter(o){let{context:e}=o;e.restore()}drawBefore(o){let{particle:e,context:t}=o,{_container:r}=this,s=e.shadowColor,h=e.shadowOffset;s&&(t.save(),t.shadowBlur=e.shadowBlur??0,t.shadowColor=(0,a.getStyleFromRgb)(s,r.hdr),t.shadowOffsetX=h?.x??0,t.shadowOffsetY=h?.y??0)}particleInit(o,e){let t=e.effectData,r=a.OptionsColor.create(new a.OptionsColor,t?.color);e.shadowColor=(0,a.rangeColorToRgb)(this._pluginManager,r),e.shadowBlur=t?.blur??0,e.shadowOffset=t?.offset??a.originPoint}}}}]);
package/README.md CHANGED
@@ -8,6 +8,12 @@
8
8
 
9
9
  [tsParticles](https://github.com/tsparticles/tsparticles) additional shadow effect.
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
@@ -73,3 +79,20 @@ import { loadShadowEffect } from "@tsparticles/effect-shadow";
73
79
  await loadShadowEffect(tsParticles);
74
80
  })();
75
81
  ```
82
+
83
+ ## Option mapping
84
+
85
+ - Effects are usually enabled through dedicated package loaders and effect-specific options.
86
+ - Package scope: `shadow`
87
+ - Start from the usage snippet in this README, then merge with your main options object incrementally.
88
+
89
+ ## Common pitfalls
90
+
91
+ - Calling `tsParticles.load(...)` before `loadShadowEffect(...)`
92
+ - Verify required peer packages before enabling advanced options
93
+ - Change one option group at a time to isolate regressions quickly
94
+
95
+ ## Related docs
96
+
97
+ - All packages catalog: <https://github.com/tsparticles/tsparticles>
98
+ - Main docs: <https://particles.js.org/docs/>
@@ -1,22 +1,22 @@
1
1
  import { OptionsColor, getStyleFromRgb, originPoint, rangeColorToRgb, } from "@tsparticles/engine";
2
2
  const defaultShadowBlur = 0, defaultShadowOffsetValue = 0;
3
3
  export class ShadowDrawer {
4
- _engine;
5
- constructor(engine) {
6
- this._engine = engine;
4
+ _container;
5
+ _pluginManager;
6
+ constructor(pluginManager, container) {
7
+ this._pluginManager = pluginManager;
8
+ this._container = container;
7
9
  }
8
10
  drawAfter(data) {
9
11
  const { context } = data;
10
- context.shadowBlur = 0;
11
- context.shadowColor = "transparent";
12
- context.shadowOffsetX = 0;
13
- context.shadowOffsetY = 0;
12
+ context.restore();
14
13
  }
15
14
  drawBefore(data) {
16
- const { particle, context } = data, { container } = particle, shadowParticle = particle, shadowColor = shadowParticle.shadowColor, shadowOffset = shadowParticle.shadowOffset;
15
+ const { particle, context } = data, { _container: container } = this, shadowParticle = particle, shadowColor = shadowParticle.shadowColor, shadowOffset = shadowParticle.shadowOffset;
17
16
  if (!shadowColor) {
18
17
  return;
19
18
  }
19
+ context.save();
20
20
  context.shadowBlur = shadowParticle.shadowBlur ?? defaultShadowBlur;
21
21
  context.shadowColor = getStyleFromRgb(shadowColor, container.hdr);
22
22
  context.shadowOffsetX = shadowOffset?.x ?? defaultShadowOffsetValue;
@@ -24,7 +24,7 @@ export class ShadowDrawer {
24
24
  }
25
25
  particleInit(_container, particle) {
26
26
  const effectData = particle.effectData, shadowColor = OptionsColor.create(new OptionsColor(), effectData?.color);
27
- particle.shadowColor = rangeColorToRgb(this._engine, shadowColor);
27
+ particle.shadowColor = rangeColorToRgb(this._pluginManager, shadowColor);
28
28
  particle.shadowBlur = effectData?.blur ?? defaultShadowBlur;
29
29
  particle.shadowOffset = effectData?.offset ?? originPoint;
30
30
  }
package/browser/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  export async function loadShadowEffect(engine) {
2
- engine.checkVersion("4.0.0-beta.0");
3
- await engine.register(e => {
4
- e.addEffect("shadow", async () => {
2
+ engine.checkVersion("4.0.0-beta.10");
3
+ await engine.pluginManager.register(e => {
4
+ e.pluginManager.addEffect("shadow", async (container) => {
5
5
  const { ShadowDrawer } = await import("./ShadowDrawer.js");
6
- return new ShadowDrawer(e);
6
+ return new ShadowDrawer(e.pluginManager, container);
7
7
  });
8
8
  });
9
9
  }
@@ -1,22 +1,22 @@
1
1
  import { OptionsColor, getStyleFromRgb, originPoint, rangeColorToRgb, } from "@tsparticles/engine";
2
2
  const defaultShadowBlur = 0, defaultShadowOffsetValue = 0;
3
3
  export class ShadowDrawer {
4
- _engine;
5
- constructor(engine) {
6
- this._engine = engine;
4
+ _container;
5
+ _pluginManager;
6
+ constructor(pluginManager, container) {
7
+ this._pluginManager = pluginManager;
8
+ this._container = container;
7
9
  }
8
10
  drawAfter(data) {
9
11
  const { context } = data;
10
- context.shadowBlur = 0;
11
- context.shadowColor = "transparent";
12
- context.shadowOffsetX = 0;
13
- context.shadowOffsetY = 0;
12
+ context.restore();
14
13
  }
15
14
  drawBefore(data) {
16
- const { particle, context } = data, { container } = particle, shadowParticle = particle, shadowColor = shadowParticle.shadowColor, shadowOffset = shadowParticle.shadowOffset;
15
+ const { particle, context } = data, { _container: container } = this, shadowParticle = particle, shadowColor = shadowParticle.shadowColor, shadowOffset = shadowParticle.shadowOffset;
17
16
  if (!shadowColor) {
18
17
  return;
19
18
  }
19
+ context.save();
20
20
  context.shadowBlur = shadowParticle.shadowBlur ?? defaultShadowBlur;
21
21
  context.shadowColor = getStyleFromRgb(shadowColor, container.hdr);
22
22
  context.shadowOffsetX = shadowOffset?.x ?? defaultShadowOffsetValue;
@@ -24,7 +24,7 @@ export class ShadowDrawer {
24
24
  }
25
25
  particleInit(_container, particle) {
26
26
  const effectData = particle.effectData, shadowColor = OptionsColor.create(new OptionsColor(), effectData?.color);
27
- particle.shadowColor = rangeColorToRgb(this._engine, shadowColor);
27
+ particle.shadowColor = rangeColorToRgb(this._pluginManager, shadowColor);
28
28
  particle.shadowBlur = effectData?.blur ?? defaultShadowBlur;
29
29
  particle.shadowOffset = effectData?.offset ?? originPoint;
30
30
  }
package/cjs/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  export async function loadShadowEffect(engine) {
2
- engine.checkVersion("4.0.0-beta.0");
3
- await engine.register(e => {
4
- e.addEffect("shadow", async () => {
2
+ engine.checkVersion("4.0.0-beta.10");
3
+ await engine.pluginManager.register(e => {
4
+ e.pluginManager.addEffect("shadow", async (container) => {
5
5
  const { ShadowDrawer } = await import("./ShadowDrawer.js");
6
- return new ShadowDrawer(e);
6
+ return new ShadowDrawer(e.pluginManager, container);
7
7
  });
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 */ ShadowDrawer: () => (/* binding */ ShadowDrawer)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nconst defaultShadowBlur = 0, defaultShadowOffsetValue = 0;\nclass ShadowDrawer {\n _engine;\n constructor(engine){\n this._engine = engine;\n }\n drawAfter(data) {\n const { context } = data;\n context.shadowBlur = 0;\n context.shadowColor = \"transparent\";\n context.shadowOffsetX = 0;\n context.shadowOffsetY = 0;\n }\n drawBefore(data) {\n const { particle, context } = data, { container } = particle, shadowParticle = particle, shadowColor = shadowParticle.shadowColor, shadowOffset = shadowParticle.shadowOffset;\n if (!shadowColor) {\n return;\n }\n context.shadowBlur = shadowParticle.shadowBlur ?? defaultShadowBlur;\n context.shadowColor = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getStyleFromRgb)(shadowColor, container.hdr);\n context.shadowOffsetX = shadowOffset?.x ?? defaultShadowOffsetValue;\n context.shadowOffsetY = shadowOffset?.y ?? defaultShadowOffsetValue;\n }\n particleInit(_container, particle) {\n const effectData = particle.effectData, shadowColor = _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.OptionsColor.create(new _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.OptionsColor(), effectData?.color);\n particle.shadowColor = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.rangeColorToRgb)(this._engine, shadowColor);\n particle.shadowBlur = effectData?.blur ?? defaultShadowBlur;\n particle.shadowOffset = effectData?.offset ?? _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.originPoint;\n }\n}\n\n\n//# sourceURL=webpack://@tsparticles/effect-shadow/./dist/browser/ShadowDrawer.js?\n}");
26
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ShadowDrawer: () => (/* binding */ ShadowDrawer)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nconst defaultShadowBlur = 0, defaultShadowOffsetValue = 0;\nclass ShadowDrawer {\n _container;\n _pluginManager;\n constructor(pluginManager, container){\n this._pluginManager = pluginManager;\n this._container = container;\n }\n drawAfter(data) {\n const { context } = data;\n context.restore();\n }\n drawBefore(data) {\n const { particle, context } = data, { _container: container } = this, shadowParticle = particle, shadowColor = shadowParticle.shadowColor, shadowOffset = shadowParticle.shadowOffset;\n if (!shadowColor) {\n return;\n }\n context.save();\n context.shadowBlur = shadowParticle.shadowBlur ?? defaultShadowBlur;\n context.shadowColor = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getStyleFromRgb)(shadowColor, container.hdr);\n context.shadowOffsetX = shadowOffset?.x ?? defaultShadowOffsetValue;\n context.shadowOffsetY = shadowOffset?.y ?? defaultShadowOffsetValue;\n }\n particleInit(_container, particle) {\n const effectData = particle.effectData, shadowColor = _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.OptionsColor.create(new _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.OptionsColor(), effectData?.color);\n particle.shadowColor = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.rangeColorToRgb)(this._pluginManager, shadowColor);\n particle.shadowBlur = effectData?.blur ?? defaultShadowBlur;\n particle.shadowOffset = effectData?.offset ?? _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.originPoint;\n }\n}\n\n\n//# sourceURL=webpack://@tsparticles/effect-shadow/./dist/browser/ShadowDrawer.js?\n}");
27
27
 
28
28
  /***/ }
29
29
 
@@ -1,22 +1,22 @@
1
1
  import { OptionsColor, getStyleFromRgb, originPoint, rangeColorToRgb, } from "@tsparticles/engine";
2
2
  const defaultShadowBlur = 0, defaultShadowOffsetValue = 0;
3
3
  export class ShadowDrawer {
4
- _engine;
5
- constructor(engine) {
6
- this._engine = engine;
4
+ _container;
5
+ _pluginManager;
6
+ constructor(pluginManager, container) {
7
+ this._pluginManager = pluginManager;
8
+ this._container = container;
7
9
  }
8
10
  drawAfter(data) {
9
11
  const { context } = data;
10
- context.shadowBlur = 0;
11
- context.shadowColor = "transparent";
12
- context.shadowOffsetX = 0;
13
- context.shadowOffsetY = 0;
12
+ context.restore();
14
13
  }
15
14
  drawBefore(data) {
16
- const { particle, context } = data, { container } = particle, shadowParticle = particle, shadowColor = shadowParticle.shadowColor, shadowOffset = shadowParticle.shadowOffset;
15
+ const { particle, context } = data, { _container: container } = this, shadowParticle = particle, shadowColor = shadowParticle.shadowColor, shadowOffset = shadowParticle.shadowOffset;
17
16
  if (!shadowColor) {
18
17
  return;
19
18
  }
19
+ context.save();
20
20
  context.shadowBlur = shadowParticle.shadowBlur ?? defaultShadowBlur;
21
21
  context.shadowColor = getStyleFromRgb(shadowColor, container.hdr);
22
22
  context.shadowOffsetX = shadowOffset?.x ?? defaultShadowOffsetValue;
@@ -24,7 +24,7 @@ export class ShadowDrawer {
24
24
  }
25
25
  particleInit(_container, particle) {
26
26
  const effectData = particle.effectData, shadowColor = OptionsColor.create(new OptionsColor(), effectData?.color);
27
- particle.shadowColor = rangeColorToRgb(this._engine, shadowColor);
27
+ particle.shadowColor = rangeColorToRgb(this._pluginManager, shadowColor);
28
28
  particle.shadowBlur = effectData?.blur ?? defaultShadowBlur;
29
29
  particle.shadowOffset = effectData?.offset ?? originPoint;
30
30
  }
package/esm/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  export async function loadShadowEffect(engine) {
2
- engine.checkVersion("4.0.0-beta.0");
3
- await engine.register(e => {
4
- e.addEffect("shadow", async () => {
2
+ engine.checkVersion("4.0.0-beta.10");
3
+ await engine.pluginManager.register(e => {
4
+ e.pluginManager.addEffect("shadow", async (container) => {
5
5
  const { ShadowDrawer } = await import("./ShadowDrawer.js");
6
- return new ShadowDrawer(e);
6
+ return new ShadowDrawer(e.pluginManager, container);
7
7
  });
8
8
  });
9
9
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/effect-shadow",
3
- "version": "4.0.0-beta.0",
3
+ "version": "4.0.0-beta.10",
4
4
  "description": "tsParticles shadow effect",
5
5
  "homepage": "https://particles.js.org",
6
6
  "repository": {
@@ -94,13 +94,12 @@
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"
101
+ "peerDependencies": {
102
+ "@tsparticles/engine": "4.0.0-beta.10"
104
103
  },
105
104
  "publishConfig": {
106
105
  "access": "public"