@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.
- package/README.md +25 -19
- package/browser/ExternalLighter.js +15 -15
- package/browser/Options/Classes/Light.js +2 -2
- package/browser/Options/Classes/LightArea.js +1 -1
- package/browser/ParticlesLighter.js +12 -11
- package/browser/Utils.js +14 -16
- package/browser/index.js +13 -13
- package/browser/package.json +1 -0
- package/cjs/ExternalLighter.js +16 -27
- package/cjs/Options/Classes/Light.js +4 -4
- package/cjs/Options/Classes/LightArea.js +2 -2
- package/cjs/ParticlesLighter.js +13 -23
- package/cjs/Utils.js +14 -16
- package/cjs/index.js +13 -13
- package/cjs/package.json +1 -0
- package/esm/ExternalLighter.js +15 -15
- package/esm/Options/Classes/Light.js +2 -2
- package/esm/Options/Classes/LightArea.js +1 -1
- package/esm/ParticlesLighter.js +12 -11
- package/esm/Utils.js +14 -16
- package/esm/index.js +13 -13
- package/esm/package.json +1 -0
- package/package.json +23 -6
- package/report.html +4 -4
- package/tsparticles.interaction.light.js +49 -48
- package/tsparticles.interaction.light.min.js +1 -1
- package/tsparticles.interaction.light.min.js.LICENSE.txt +1 -8
- package/types/ExternalLighter.d.ts +3 -4
- package/types/Options/Classes/Light.d.ts +3 -3
- package/types/Options/Classes/LightArea.d.ts +2 -2
- package/types/Options/Classes/LightGradient.d.ts +1 -1
- package/types/Options/Classes/LightOptions.d.ts +1 -1
- package/types/Options/Classes/LightShadow.d.ts +2 -3
- package/types/Options/Interfaces/ILight.d.ts +2 -2
- package/types/Options/Interfaces/ILightArea.d.ts +1 -1
- package/types/ParticlesLighter.d.ts +1 -1
- package/types/Types.d.ts +3 -3
- package/types/Utils.d.ts +2 -2
- package/types/index.d.ts +9 -9
- package/umd/ExternalLighter.js +16 -16
- package/umd/Options/Classes/Light.js +5 -5
- package/umd/Options/Classes/LightArea.js +3 -3
- package/umd/ParticlesLighter.js +13 -12
- package/umd/Utils.js +14 -16
- 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
|
-
|
|
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
|
-
|
|
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),
|
|
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
|
-
|
|
42
|
-
|
|
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 =
|
|
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].
|
|
52
|
-
context.lineTo(points[n].
|
|
53
|
-
context.lineTo(points[n].
|
|
54
|
-
context.lineTo(points[i].
|
|
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";
|
package/esm/package.json
ADDED
|
@@ -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-
|
|
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
|
-
"
|
|
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
|
-
"
|
|
87
|
-
"
|
|
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-
|
|
104
|
+
"@tsparticles/engine": "^3.0.0-beta.1"
|
|
105
|
+
},
|
|
106
|
+
"publishConfig": {
|
|
107
|
+
"access": "public"
|
|
91
108
|
}
|
|
92
|
-
}
|
|
109
|
+
}
|