@tsparticles/interaction-light 3.0.0-alpha.1 → 3.0.0-beta.1

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.
Files changed (45) hide show
  1. package/README.md +25 -19
  2. package/browser/ExternalLighter.js +15 -15
  3. package/browser/Options/Classes/Light.js +2 -2
  4. package/browser/Options/Classes/LightArea.js +1 -1
  5. package/browser/ParticlesLighter.js +12 -11
  6. package/browser/Utils.js +14 -16
  7. package/browser/index.js +13 -13
  8. package/browser/package.json +1 -0
  9. package/cjs/ExternalLighter.js +16 -27
  10. package/cjs/Options/Classes/Light.js +4 -4
  11. package/cjs/Options/Classes/LightArea.js +2 -2
  12. package/cjs/ParticlesLighter.js +13 -23
  13. package/cjs/Utils.js +14 -16
  14. package/cjs/index.js +13 -13
  15. package/cjs/package.json +1 -0
  16. package/esm/ExternalLighter.js +15 -15
  17. package/esm/Options/Classes/Light.js +2 -2
  18. package/esm/Options/Classes/LightArea.js +1 -1
  19. package/esm/ParticlesLighter.js +12 -11
  20. package/esm/Utils.js +14 -16
  21. package/esm/index.js +13 -13
  22. package/esm/package.json +1 -0
  23. package/package.json +23 -6
  24. package/report.html +4 -4
  25. package/tsparticles.interaction.light.js +49 -48
  26. package/tsparticles.interaction.light.min.js +1 -1
  27. package/tsparticles.interaction.light.min.js.LICENSE.txt +1 -8
  28. package/types/ExternalLighter.d.ts +3 -4
  29. package/types/Options/Classes/Light.d.ts +3 -3
  30. package/types/Options/Classes/LightArea.d.ts +2 -2
  31. package/types/Options/Classes/LightGradient.d.ts +1 -1
  32. package/types/Options/Classes/LightOptions.d.ts +1 -1
  33. package/types/Options/Classes/LightShadow.d.ts +2 -3
  34. package/types/Options/Interfaces/ILight.d.ts +2 -2
  35. package/types/Options/Interfaces/ILightArea.d.ts +1 -1
  36. package/types/ParticlesLighter.d.ts +1 -1
  37. package/types/Types.d.ts +3 -3
  38. package/types/Utils.d.ts +2 -2
  39. package/types/index.d.ts +9 -9
  40. package/umd/ExternalLighter.js +16 -16
  41. package/umd/Options/Classes/Light.js +5 -5
  42. package/umd/Options/Classes/LightArea.js +3 -3
  43. package/umd/ParticlesLighter.js +13 -12
  44. package/umd/Utils.js +14 -16
  45. package/umd/index.js +14 -14
package/esm/Utils.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import { getStyleFromRgb } from "@tsparticles/engine";
2
2
  export function drawLight(container, context, mousePos) {
3
- var _a;
4
- const lightOptions = (_a = container.actualOptions.interactivity.modes.light) === null || _a === void 0 ? void 0 : _a.area;
3
+ const lightOptions = container.actualOptions.interactivity.modes.light?.area;
5
4
  if (!lightOptions) {
6
5
  return;
7
6
  }
@@ -18,8 +17,7 @@ export function drawLight(container, context, mousePos) {
18
17
  context.fill();
19
18
  }
20
19
  export function drawParticleShadow(container, context, particle, mousePos) {
21
- var _a;
22
- const pos = particle.getPosition(), shadowOptions = (_a = container.actualOptions.interactivity.modes.light) === null || _a === void 0 ? void 0 : _a.shadow;
20
+ const pos = particle.getPosition(), shadowOptions = container.actualOptions.interactivity.modes.light?.shadow;
23
21
  if (!shadowOptions) {
24
22
  return;
25
23
  }
@@ -36,22 +34,22 @@ export function drawParticleShadow(container, context, particle, mousePos) {
36
34
  }
37
35
  const points = [], shadowLength = shadowOptions.length;
38
36
  for (const dot of dots) {
39
- const dotAngle = Math.atan2(mousePos.y - dot.y, mousePos.x - dot.x), endX = dot.x + shadowLength * Math.sin(-dotAngle - Math.PI / 2), endY = dot.y + shadowLength * Math.cos(-dotAngle - Math.PI / 2);
37
+ const dotAngle = Math.atan2(mousePos.y - dot.y, mousePos.x - dot.x), end = {
38
+ x: dot.x + shadowLength * Math.sin(-dotAngle - Math.PI / 2),
39
+ y: dot.y + shadowLength * Math.cos(-dotAngle - Math.PI / 2),
40
+ };
40
41
  points.push({
41
- endX: endX,
42
- endY: endY,
43
- startX: dot.x,
44
- startY: dot.y,
42
+ end: end,
43
+ start: dot,
45
44
  });
46
45
  }
47
- const shadowColor = getStyleFromRgb(shadowRgb);
48
- for (let i = points.length - 1; i >= 0; i--) {
49
- const n = i === points.length - 1 ? 0 : i + 1;
46
+ const shadowColor = getStyleFromRgb(shadowRgb), last = points.length - 1;
47
+ for (let i = last, n = 0; i >= 0; n = i--) {
50
48
  context.beginPath();
51
- context.moveTo(points[i].startX, points[i].startY);
52
- context.lineTo(points[n].startX, points[n].startY);
53
- context.lineTo(points[n].endX, points[n].endY);
54
- context.lineTo(points[i].endX, points[i].endY);
49
+ context.moveTo(points[i].start.x, points[i].start.y);
50
+ context.lineTo(points[n].start.x, points[n].start.y);
51
+ context.lineTo(points[n].end.x, points[n].end.y);
52
+ context.lineTo(points[i].end.x, points[i].end.y);
55
53
  context.fillStyle = shadowColor;
56
54
  context.fill();
57
55
  }
package/esm/index.js CHANGED
@@ -1,14 +1,14 @@
1
- import { ExternalLighter } from "./ExternalLighter";
2
- import { ParticlesLighter } from "./ParticlesLighter";
3
- export function loadLightInteraction(engine) {
4
- engine.addInteractor("externalLight", (container) => new ExternalLighter(container));
5
- engine.addInteractor("particlesLight", (container) => new ParticlesLighter(container));
1
+ import { ExternalLighter } from "./ExternalLighter.js";
2
+ import { ParticlesLighter } from "./ParticlesLighter.js";
3
+ export async function loadLightInteraction(engine, refresh = true) {
4
+ await engine.addInteractor("externalLight", (container) => new ExternalLighter(container), refresh);
5
+ await engine.addInteractor("particlesLight", (container) => new ParticlesLighter(container), refresh);
6
6
  }
7
- export * from "./Options/Classes/Light";
8
- export * from "./Options/Classes/LightArea";
9
- export * from "./Options/Classes/LightGradient";
10
- export * from "./Options/Classes/LightShadow";
11
- export * from "./Options/Interfaces/ILight";
12
- export * from "./Options/Interfaces/ILightArea";
13
- export * from "./Options/Interfaces/ILightGradient";
14
- export * from "./Options/Interfaces/ILightShadow";
7
+ export * from "./Options/Classes/Light.js";
8
+ export * from "./Options/Classes/LightArea.js";
9
+ export * from "./Options/Classes/LightGradient.js";
10
+ export * from "./Options/Classes/LightShadow.js";
11
+ export * from "./Options/Interfaces/ILight.js";
12
+ export * from "./Options/Interfaces/ILightArea.js";
13
+ export * from "./Options/Interfaces/ILightGradient.js";
14
+ export * from "./Options/Interfaces/ILightShadow.js";
@@ -0,0 +1 @@
1
+ { "type": "module" }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/interaction-light",
3
- "version": "3.0.0-alpha.1",
3
+ "version": "3.0.0-beta.1",
4
4
  "description": "tsParticles Light interaction",
5
5
  "homepage": "https://particles.js.org",
6
6
  "repository": {
@@ -73,20 +73,37 @@
73
73
  "type": "github",
74
74
  "url": "https://github.com/sponsors/matteobruni"
75
75
  },
76
+ {
77
+ "type": "github",
78
+ "url": "https://github.com/sponsors/tsparticles"
79
+ },
76
80
  {
77
81
  "type": "buymeacoffee",
78
82
  "url": "https://www.buymeacoffee.com/matteobruni"
79
83
  }
80
84
  ],
81
- "main": "cjs/index.js",
85
+ "sideEffects": false,
82
86
  "jsdelivr": "tsparticles.interaction.light.min.js",
83
87
  "unpkg": "tsparticles.interaction.light.min.js",
88
+ "browser": "browser/index.js",
89
+ "main": "cjs/index.js",
84
90
  "module": "esm/index.js",
85
91
  "types": "types/index.d.ts",
86
- "publishConfig": {
87
- "access": "public"
92
+ "exports": {
93
+ ".": {
94
+ "types": "./types/index.d.ts",
95
+ "browser": "./browser/index.js",
96
+ "import": "./esm/index.js",
97
+ "require": "./cjs/index.js",
98
+ "umd": "./umd/index.js",
99
+ "default": "./cjs/index.js"
100
+ },
101
+ "./package.json": "./package.json"
88
102
  },
89
103
  "dependencies": {
90
- "@tsparticles/engine": "^3.0.0-alpha.1"
104
+ "@tsparticles/engine": "^3.0.0-beta.1"
105
+ },
106
+ "publishConfig": {
107
+ "access": "public"
91
108
  }
92
- }
109
+ }