@tsparticles/interaction-light 3.0.2 → 3.1.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/ExternalLighter.js +1 -0
- package/browser/ParticlesLighter.js +1 -0
- package/browser/Utils.js +14 -10
- package/cjs/ExternalLighter.js +1 -0
- package/cjs/ParticlesLighter.js +1 -0
- package/cjs/Utils.js +14 -10
- package/esm/ExternalLighter.js +1 -0
- package/esm/ParticlesLighter.js +1 -0
- package/esm/Utils.js +14 -10
- package/package.json +2 -2
- package/report.html +2 -2
- package/tsparticles.interaction.light.js +27 -12
- package/tsparticles.interaction.light.min.js +1 -1
- package/tsparticles.interaction.light.min.js.LICENSE.txt +1 -1
- package/types/ExternalLighter.d.ts +1 -2
- package/types/Options/Classes/LightGradient.d.ts +1 -2
- package/types/Types.d.ts +4 -4
- package/umd/ExternalLighter.js +1 -0
- package/umd/ParticlesLighter.js +1 -0
- package/umd/Utils.js +14 -10
|
@@ -21,6 +21,7 @@ export class ExternalLighter extends ExternalInteractorBase {
|
|
|
21
21
|
container.canvas.draw((ctx) => {
|
|
22
22
|
drawLight(container, ctx, mousePos);
|
|
23
23
|
});
|
|
24
|
+
await Promise.resolve();
|
|
24
25
|
}
|
|
25
26
|
isEnabled(particle) {
|
|
26
27
|
const container = this.container, mouse = container.interactivity.mouse, interactivity = particle?.interactivity ?? container.actualOptions.interactivity, events = interactivity.events;
|
|
@@ -20,6 +20,7 @@ export class ParticlesLighter extends ParticlesInteractorBase {
|
|
|
20
20
|
container.canvas.draw((ctx) => {
|
|
21
21
|
drawParticleShadow(container, ctx, particle, mousePos);
|
|
22
22
|
});
|
|
23
|
+
await Promise.resolve();
|
|
23
24
|
}
|
|
24
25
|
isEnabled(particle) {
|
|
25
26
|
const container = this.container, interactivity = particle.interactivity ?? container.actualOptions.interactivity, mouse = container.interactivity.mouse, events = interactivity.events;
|
package/browser/Utils.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { getStyleFromRgb } from "@tsparticles/engine";
|
|
2
|
+
const gradientPos = {
|
|
3
|
+
max: 1,
|
|
4
|
+
min: 0,
|
|
5
|
+
}, half = 0.5, double = 2, halfPI = Math.PI * half, doublePI = Math.PI * double, quarter = 0.25, quarterPI = Math.PI * quarter, arcStart = 0;
|
|
2
6
|
export const lightMode = "light";
|
|
3
7
|
export function drawLight(container, context, mousePos) {
|
|
4
8
|
const lightOptions = container.actualOptions.interactivity.modes.light?.area;
|
|
@@ -6,14 +10,14 @@ export function drawLight(container, context, mousePos) {
|
|
|
6
10
|
return;
|
|
7
11
|
}
|
|
8
12
|
context.beginPath();
|
|
9
|
-
context.arc(mousePos.x, mousePos.y, lightOptions.radius,
|
|
10
|
-
const gradientAmbientLight = context.createRadialGradient(mousePos.x, mousePos.y,
|
|
13
|
+
context.arc(mousePos.x, mousePos.y, lightOptions.radius, arcStart, doublePI);
|
|
14
|
+
const gradientAmbientLight = context.createRadialGradient(mousePos.x, mousePos.y, arcStart, mousePos.x, mousePos.y, lightOptions.radius);
|
|
11
15
|
const gradientRgb = container.canvas.mouseLight;
|
|
12
|
-
if (!gradientRgb
|
|
16
|
+
if (!gradientRgb?.start || !gradientRgb.stop) {
|
|
13
17
|
return;
|
|
14
18
|
}
|
|
15
|
-
gradientAmbientLight.addColorStop(
|
|
16
|
-
gradientAmbientLight.addColorStop(
|
|
19
|
+
gradientAmbientLight.addColorStop(gradientPos.min, getStyleFromRgb(gradientRgb.start));
|
|
20
|
+
gradientAmbientLight.addColorStop(gradientPos.max, getStyleFromRgb(gradientRgb.stop));
|
|
17
21
|
context.fillStyle = gradientAmbientLight;
|
|
18
22
|
context.fill();
|
|
19
23
|
}
|
|
@@ -26,7 +30,7 @@ export function drawParticleShadow(container, context, particle, mousePos) {
|
|
|
26
30
|
if (!shadowRgb) {
|
|
27
31
|
return;
|
|
28
32
|
}
|
|
29
|
-
const radius = particle.getRadius(), sides = particle.sides, full =
|
|
33
|
+
const radius = particle.getRadius(), sides = particle.sides, full = doublePI / sides, angle = -particle.rotation + quarterPI, factor = 1, dots = [];
|
|
30
34
|
for (let i = 0; i < sides; i++) {
|
|
31
35
|
dots.push({
|
|
32
36
|
x: pos.x + radius * Math.sin(angle + full * i) * factor,
|
|
@@ -36,16 +40,16 @@ export function drawParticleShadow(container, context, particle, mousePos) {
|
|
|
36
40
|
const points = [], shadowLength = shadowOptions.length;
|
|
37
41
|
for (const dot of dots) {
|
|
38
42
|
const dotAngle = Math.atan2(mousePos.y - dot.y, mousePos.x - dot.x), end = {
|
|
39
|
-
x: dot.x + shadowLength * Math.sin(-dotAngle -
|
|
40
|
-
y: dot.y + shadowLength * Math.cos(-dotAngle -
|
|
43
|
+
x: dot.x + shadowLength * Math.sin(-dotAngle - halfPI),
|
|
44
|
+
y: dot.y + shadowLength * Math.cos(-dotAngle - halfPI),
|
|
41
45
|
};
|
|
42
46
|
points.push({
|
|
43
47
|
end: end,
|
|
44
48
|
start: dot,
|
|
45
49
|
});
|
|
46
50
|
}
|
|
47
|
-
const shadowColor = getStyleFromRgb(shadowRgb), last = points.length -
|
|
48
|
-
for (let i = last, n = 0; i >=
|
|
51
|
+
const shadowColor = getStyleFromRgb(shadowRgb), lastOffset = 1, firstPos = 0, last = points.length - lastOffset;
|
|
52
|
+
for (let i = last, n = 0; i >= firstPos; n = i--) {
|
|
49
53
|
context.beginPath();
|
|
50
54
|
context.moveTo(points[i].start.x, points[i].start.y);
|
|
51
55
|
context.lineTo(points[n].start.x, points[n].start.y);
|
package/cjs/ExternalLighter.js
CHANGED
|
@@ -24,6 +24,7 @@ class ExternalLighter extends engine_1.ExternalInteractorBase {
|
|
|
24
24
|
container.canvas.draw((ctx) => {
|
|
25
25
|
(0, Utils_js_1.drawLight)(container, ctx, mousePos);
|
|
26
26
|
});
|
|
27
|
+
await Promise.resolve();
|
|
27
28
|
}
|
|
28
29
|
isEnabled(particle) {
|
|
29
30
|
const container = this.container, mouse = container.interactivity.mouse, interactivity = particle?.interactivity ?? container.actualOptions.interactivity, events = interactivity.events;
|
package/cjs/ParticlesLighter.js
CHANGED
|
@@ -23,6 +23,7 @@ class ParticlesLighter extends engine_1.ParticlesInteractorBase {
|
|
|
23
23
|
container.canvas.draw((ctx) => {
|
|
24
24
|
(0, Utils_js_1.drawParticleShadow)(container, ctx, particle, mousePos);
|
|
25
25
|
});
|
|
26
|
+
await Promise.resolve();
|
|
26
27
|
}
|
|
27
28
|
isEnabled(particle) {
|
|
28
29
|
const container = this.container, interactivity = particle.interactivity ?? container.actualOptions.interactivity, mouse = container.interactivity.mouse, events = interactivity.events;
|
package/cjs/Utils.js
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.drawParticleShadow = exports.drawLight = exports.lightMode = void 0;
|
|
4
4
|
const engine_1 = require("@tsparticles/engine");
|
|
5
|
+
const gradientPos = {
|
|
6
|
+
max: 1,
|
|
7
|
+
min: 0,
|
|
8
|
+
}, half = 0.5, double = 2, halfPI = Math.PI * half, doublePI = Math.PI * double, quarter = 0.25, quarterPI = Math.PI * quarter, arcStart = 0;
|
|
5
9
|
exports.lightMode = "light";
|
|
6
10
|
function drawLight(container, context, mousePos) {
|
|
7
11
|
const lightOptions = container.actualOptions.interactivity.modes.light?.area;
|
|
@@ -9,14 +13,14 @@ function drawLight(container, context, mousePos) {
|
|
|
9
13
|
return;
|
|
10
14
|
}
|
|
11
15
|
context.beginPath();
|
|
12
|
-
context.arc(mousePos.x, mousePos.y, lightOptions.radius,
|
|
13
|
-
const gradientAmbientLight = context.createRadialGradient(mousePos.x, mousePos.y,
|
|
16
|
+
context.arc(mousePos.x, mousePos.y, lightOptions.radius, arcStart, doublePI);
|
|
17
|
+
const gradientAmbientLight = context.createRadialGradient(mousePos.x, mousePos.y, arcStart, mousePos.x, mousePos.y, lightOptions.radius);
|
|
14
18
|
const gradientRgb = container.canvas.mouseLight;
|
|
15
|
-
if (!gradientRgb
|
|
19
|
+
if (!gradientRgb?.start || !gradientRgb.stop) {
|
|
16
20
|
return;
|
|
17
21
|
}
|
|
18
|
-
gradientAmbientLight.addColorStop(
|
|
19
|
-
gradientAmbientLight.addColorStop(
|
|
22
|
+
gradientAmbientLight.addColorStop(gradientPos.min, (0, engine_1.getStyleFromRgb)(gradientRgb.start));
|
|
23
|
+
gradientAmbientLight.addColorStop(gradientPos.max, (0, engine_1.getStyleFromRgb)(gradientRgb.stop));
|
|
20
24
|
context.fillStyle = gradientAmbientLight;
|
|
21
25
|
context.fill();
|
|
22
26
|
}
|
|
@@ -30,7 +34,7 @@ function drawParticleShadow(container, context, particle, mousePos) {
|
|
|
30
34
|
if (!shadowRgb) {
|
|
31
35
|
return;
|
|
32
36
|
}
|
|
33
|
-
const radius = particle.getRadius(), sides = particle.sides, full =
|
|
37
|
+
const radius = particle.getRadius(), sides = particle.sides, full = doublePI / sides, angle = -particle.rotation + quarterPI, factor = 1, dots = [];
|
|
34
38
|
for (let i = 0; i < sides; i++) {
|
|
35
39
|
dots.push({
|
|
36
40
|
x: pos.x + radius * Math.sin(angle + full * i) * factor,
|
|
@@ -40,16 +44,16 @@ function drawParticleShadow(container, context, particle, mousePos) {
|
|
|
40
44
|
const points = [], shadowLength = shadowOptions.length;
|
|
41
45
|
for (const dot of dots) {
|
|
42
46
|
const dotAngle = Math.atan2(mousePos.y - dot.y, mousePos.x - dot.x), end = {
|
|
43
|
-
x: dot.x + shadowLength * Math.sin(-dotAngle -
|
|
44
|
-
y: dot.y + shadowLength * Math.cos(-dotAngle -
|
|
47
|
+
x: dot.x + shadowLength * Math.sin(-dotAngle - halfPI),
|
|
48
|
+
y: dot.y + shadowLength * Math.cos(-dotAngle - halfPI),
|
|
45
49
|
};
|
|
46
50
|
points.push({
|
|
47
51
|
end: end,
|
|
48
52
|
start: dot,
|
|
49
53
|
});
|
|
50
54
|
}
|
|
51
|
-
const shadowColor = (0, engine_1.getStyleFromRgb)(shadowRgb), last = points.length -
|
|
52
|
-
for (let i = last, n = 0; i >=
|
|
55
|
+
const shadowColor = (0, engine_1.getStyleFromRgb)(shadowRgb), lastOffset = 1, firstPos = 0, last = points.length - lastOffset;
|
|
56
|
+
for (let i = last, n = 0; i >= firstPos; n = i--) {
|
|
53
57
|
context.beginPath();
|
|
54
58
|
context.moveTo(points[i].start.x, points[i].start.y);
|
|
55
59
|
context.lineTo(points[n].start.x, points[n].start.y);
|
package/esm/ExternalLighter.js
CHANGED
|
@@ -21,6 +21,7 @@ export class ExternalLighter extends ExternalInteractorBase {
|
|
|
21
21
|
container.canvas.draw((ctx) => {
|
|
22
22
|
drawLight(container, ctx, mousePos);
|
|
23
23
|
});
|
|
24
|
+
await Promise.resolve();
|
|
24
25
|
}
|
|
25
26
|
isEnabled(particle) {
|
|
26
27
|
const container = this.container, mouse = container.interactivity.mouse, interactivity = particle?.interactivity ?? container.actualOptions.interactivity, events = interactivity.events;
|
package/esm/ParticlesLighter.js
CHANGED
|
@@ -20,6 +20,7 @@ export class ParticlesLighter extends ParticlesInteractorBase {
|
|
|
20
20
|
container.canvas.draw((ctx) => {
|
|
21
21
|
drawParticleShadow(container, ctx, particle, mousePos);
|
|
22
22
|
});
|
|
23
|
+
await Promise.resolve();
|
|
23
24
|
}
|
|
24
25
|
isEnabled(particle) {
|
|
25
26
|
const container = this.container, interactivity = particle.interactivity ?? container.actualOptions.interactivity, mouse = container.interactivity.mouse, events = interactivity.events;
|
package/esm/Utils.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { getStyleFromRgb } from "@tsparticles/engine";
|
|
2
|
+
const gradientPos = {
|
|
3
|
+
max: 1,
|
|
4
|
+
min: 0,
|
|
5
|
+
}, half = 0.5, double = 2, halfPI = Math.PI * half, doublePI = Math.PI * double, quarter = 0.25, quarterPI = Math.PI * quarter, arcStart = 0;
|
|
2
6
|
export const lightMode = "light";
|
|
3
7
|
export function drawLight(container, context, mousePos) {
|
|
4
8
|
const lightOptions = container.actualOptions.interactivity.modes.light?.area;
|
|
@@ -6,14 +10,14 @@ export function drawLight(container, context, mousePos) {
|
|
|
6
10
|
return;
|
|
7
11
|
}
|
|
8
12
|
context.beginPath();
|
|
9
|
-
context.arc(mousePos.x, mousePos.y, lightOptions.radius,
|
|
10
|
-
const gradientAmbientLight = context.createRadialGradient(mousePos.x, mousePos.y,
|
|
13
|
+
context.arc(mousePos.x, mousePos.y, lightOptions.radius, arcStart, doublePI);
|
|
14
|
+
const gradientAmbientLight = context.createRadialGradient(mousePos.x, mousePos.y, arcStart, mousePos.x, mousePos.y, lightOptions.radius);
|
|
11
15
|
const gradientRgb = container.canvas.mouseLight;
|
|
12
|
-
if (!gradientRgb
|
|
16
|
+
if (!gradientRgb?.start || !gradientRgb.stop) {
|
|
13
17
|
return;
|
|
14
18
|
}
|
|
15
|
-
gradientAmbientLight.addColorStop(
|
|
16
|
-
gradientAmbientLight.addColorStop(
|
|
19
|
+
gradientAmbientLight.addColorStop(gradientPos.min, getStyleFromRgb(gradientRgb.start));
|
|
20
|
+
gradientAmbientLight.addColorStop(gradientPos.max, getStyleFromRgb(gradientRgb.stop));
|
|
17
21
|
context.fillStyle = gradientAmbientLight;
|
|
18
22
|
context.fill();
|
|
19
23
|
}
|
|
@@ -26,7 +30,7 @@ export function drawParticleShadow(container, context, particle, mousePos) {
|
|
|
26
30
|
if (!shadowRgb) {
|
|
27
31
|
return;
|
|
28
32
|
}
|
|
29
|
-
const radius = particle.getRadius(), sides = particle.sides, full =
|
|
33
|
+
const radius = particle.getRadius(), sides = particle.sides, full = doublePI / sides, angle = -particle.rotation + quarterPI, factor = 1, dots = [];
|
|
30
34
|
for (let i = 0; i < sides; i++) {
|
|
31
35
|
dots.push({
|
|
32
36
|
x: pos.x + radius * Math.sin(angle + full * i) * factor,
|
|
@@ -36,16 +40,16 @@ export function drawParticleShadow(container, context, particle, mousePos) {
|
|
|
36
40
|
const points = [], shadowLength = shadowOptions.length;
|
|
37
41
|
for (const dot of dots) {
|
|
38
42
|
const dotAngle = Math.atan2(mousePos.y - dot.y, mousePos.x - dot.x), end = {
|
|
39
|
-
x: dot.x + shadowLength * Math.sin(-dotAngle -
|
|
40
|
-
y: dot.y + shadowLength * Math.cos(-dotAngle -
|
|
43
|
+
x: dot.x + shadowLength * Math.sin(-dotAngle - halfPI),
|
|
44
|
+
y: dot.y + shadowLength * Math.cos(-dotAngle - halfPI),
|
|
41
45
|
};
|
|
42
46
|
points.push({
|
|
43
47
|
end: end,
|
|
44
48
|
start: dot,
|
|
45
49
|
});
|
|
46
50
|
}
|
|
47
|
-
const shadowColor = getStyleFromRgb(shadowRgb), last = points.length -
|
|
48
|
-
for (let i = last, n = 0; i >=
|
|
51
|
+
const shadowColor = getStyleFromRgb(shadowRgb), lastOffset = 1, firstPos = 0, last = points.length - lastOffset;
|
|
52
|
+
for (let i = last, n = 0; i >= firstPos; n = i--) {
|
|
49
53
|
context.beginPath();
|
|
50
54
|
context.moveTo(points[i].start.x, points[i].start.y);
|
|
51
55
|
context.lineTo(points[n].start.x, points[n].start.y);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/interaction-light",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "tsParticles Light interaction",
|
|
5
5
|
"homepage": "https://particles.js.org",
|
|
6
6
|
"repository": {
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
"./package.json": "./package.json"
|
|
102
102
|
},
|
|
103
103
|
"dependencies": {
|
|
104
|
-
"@tsparticles/engine": "^3.0
|
|
104
|
+
"@tsparticles/engine": "^3.1.0"
|
|
105
105
|
},
|
|
106
106
|
"publishConfig": {
|
|
107
107
|
"access": "public"
|
package/report.html
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8"/>
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
6
|
-
<title>@tsparticles/interaction-light [
|
|
6
|
+
<title>@tsparticles/interaction-light [13 Jan 2024 at 23:00]</title>
|
|
7
7
|
<link rel="shortcut icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAABrVBMVEUAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+O1foceMD///+J0/qK1Pr7/v8Xdr/9///W8P4UdL7L7P0Scr2r4Pyj3vwad8D5/f/2/f+55f3E6f34+/2H0/ojfMKpzOd0rNgQcb3F3O/j9f7c8v6g3Pz0/P/w+v/q+P7n9v6T1/uQ1vuE0vqLut/y+v+Z2fvt+f+15Pzv9fuc2/vR7v2V2Pvd6/bg9P7I6/285/2y4/yp3/zp8vk8i8kqgMT7/P31+fyv4vxGkcz6/P6/6P3j7vfS5PNnpNUxhcbO7f7F6v3O4vHK3/DA2u631Ouy0eqXweKJud5wqthfoNMMbLvY8f73+v2dxeR8sNtTmdDx9/zX6PSjyeaCtd1YnNGX2PuQveCGt95Nls42h8dLlM3F4vBtAAAAM3RSTlMAAyOx0/sKBvik8opWGBMOAe3l1snDm2E9LSb06eHcu5JpHbarfHZCN9CBb08zzkdNS0kYaptYAAAFV0lEQVRYw92X51/aYBDHHS2O2qqttVbrqNq9m+TJIAYIShBkWwqIiCgoWvfeq7Z2/s29hyQNyUcR7LveGwVyXy6XH8/9rqxglLfUPLxVduUor3h0rfp2TYvpivk37929TkG037hffoX0+peVtZQc1589rigVUdXS/ABSAyEmGIO/1XfvldSK8vs3OqB6u3m0nxmIrvgB0dj7rr7Y9IbuF68hnfFaiHA/sxqm0wciIG43P60qKv9WXWc1RXGh/mFESFABTSBi0sNAKzqet17eCtOb3kZIDwxEEU0oAIJGYxNBDhBND29e0rtXXbcpuPmED9IhEAAQ/AXEaF8EPmnrrKsv0LvWR3fg5sWDNAFZOgAgaKvZDogHNU9MFwnnYROkc56RD5CjAbQX9Ow4g7upCsvYu55aSI/Nj0H1akgKQEUM94dwK65hYRmFU9MIcH/fqJYOZYcnuJSU/waKDgTOEVaVKhwrTRP5XzgSpAITYzom7UvkhFX5VutmxeNnWDjjswTKTyfgluNDGbUpWissXhF3s7mlSml+czWkg3D0l1nNjGNjz3myOQOa1KM/jOS6ebdbAVTCi4gljHSFrviza7tOgRWcS0MOUX9zdNgag5w7rRqA44Lzw0hr1WqES36dFliSJFlh2rXIae3FFcDDgKdxrUIDePr8jGcSClV1u7A9xeN0ModY/pHMxmR1EzRh8TJiwqsHmKW0l4FCEZI+jHio+JdPPE9qwQtTRxku2D8sIeRL2LnxWSllANCQGOIiqVHAz2ye2JR0DcH+HoxDkaADLjgxjKQ+AwCX/g0+DNgdG0ukYCONAe+dbc2IAc6fwt1ARoDSezNHxV2Cmzwv3O6lDMV55edBGwGK9n1+x2F8EDfAGCxug8MhpsMEcTEAWf3rx2vZhe/LAmtIn/6apE6PN0ULKgywD9mmdxbmFl3OvD5AS5fW5zLbv/YHmcsBTjf/afDz3MaZTVCfAP9z6/Bw6ycv8EUBWJIn9zYcoAWWlW9+OzO3vkTy8H+RANLmdrpOuYWdZYEXpo+TlCJrW5EARb7fF+bWdqf3hhyZI1nWJQHgznErZhbjoEsWqi8dQNoE294aldzFurwSABL2XXMf9+H1VQGke9exw5P/AnA5Pv5ngMul7LOvO922iwACu8WkCwLCafvM4CeWPxfA8lNHcWZSoi8EwMAIciKX2Z4SWCMAa3snCZ/G4EA8D6CMLNFsGQhkkz/gQNEBbPCbWsxGUpYVu3z8IyNAknwJkfPMEhLyrdi5RTyUVACkw4GSFRNWJNEW+fgPGwHD8/JxnRuLabN4CGNRkAE23na2+VmEAUmrYymSGjMAYqH84YUIyzgzs3XC7gNgH36Vcc4zKY9o9fgPBXUAiHHwVboBHGLiX6Zcjp1f2wu4tvzZKo0ecPnDtQYDQvJXaBeNzce45Fp28ZQLrEZVuFqgBwOalArKXnW1UzlnSusQKJqKYNuz4tOnI6sZG4zanpemv+7ySU2jbA9h6uhcgpfy6G2PahirDZ6zvq6zDduMVFTKvzw8wgyEdelwY9in3XkEPs3osJuwRQ4qTkfzifndg9Gfc4pdsu82+tTnHZTBa2EAMrqr2t43pguc8tNm7JQVQ2S0ukj2d22dhXYP0/veWtwKrCkNoNimAN5+Xr/oLrxswKbVJjteWrX7eR63o4j9q0GxnaBdWgGA5VStpanIjQmEhV0/nVt5VOFUvix6awJhPcAaTEShgrG+iGyvb5a0Ndb1YGHFPEwoqAinoaykaID1o1pdPNu7XsnCKQ3R+hwWIIhGvORcJUBYXe3Xa3vq/mF/N9V13ugufMkfXn+KHsRD0B8AAAAASUVORK5CYII=" type="image/x-icon" />
|
|
8
8
|
|
|
9
9
|
<script>
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
<body>
|
|
32
32
|
<div id="app"></div>
|
|
33
33
|
<script>
|
|
34
|
-
window.chartData = [{"label":"tsparticles.interaction.light.js","isAsset":true,"statSize":
|
|
34
|
+
window.chartData = [{"label":"tsparticles.interaction.light.js","isAsset":true,"statSize":7979,"parsedSize":11615,"gzipSize":2975,"groups":[{"label":"dist/browser","path":"./dist/browser","statSize":7937,"groups":[{"id":238,"label":"index.js + 7 modules (concatenated)","path":"./dist/browser/index.js + 7 modules (concatenated)","statSize":7937,"parsedSize":11615,"gzipSize":2975,"concatenated":true,"groups":[{"label":"dist/browser","path":"./dist/browser/index.js + 7 modules (concatenated)/dist/browser","statSize":7937,"groups":[{"id":null,"label":"index.js","path":"./dist/browser/index.js + 7 modules (concatenated)/dist/browser/index.js","statSize":792,"parsedSize":1159,"gzipSize":296,"inaccurateSizes":true},{"id":null,"label":"ExternalLighter.js","path":"./dist/browser/index.js + 7 modules (concatenated)/dist/browser/ExternalLighter.js","statSize":1678,"parsedSize":2455,"gzipSize":628,"inaccurateSizes":true},{"label":"Options/Classes","path":"./dist/browser/index.js + 7 modules (concatenated)/dist/browser/Options/Classes","statSize":1476,"groups":[{"id":null,"label":"Light.js","path":"./dist/browser/index.js + 7 modules (concatenated)/dist/browser/Options/Classes/Light.js","statSize":328,"parsedSize":479,"gzipSize":122,"inaccurateSizes":true},{"id":null,"label":"LightArea.js","path":"./dist/browser/index.js + 7 modules (concatenated)/dist/browser/Options/Classes/LightArea.js","statSize":336,"parsedSize":491,"gzipSize":125,"inaccurateSizes":true},{"id":null,"label":"LightGradient.js","path":"./dist/browser/index.js + 7 modules (concatenated)/dist/browser/Options/Classes/LightGradient.js","statSize":421,"parsedSize":616,"gzipSize":157,"inaccurateSizes":true},{"id":null,"label":"LightShadow.js","path":"./dist/browser/index.js + 7 modules (concatenated)/dist/browser/Options/Classes/LightShadow.js","statSize":391,"parsedSize":572,"gzipSize":146,"inaccurateSizes":true}],"parsedSize":2159,"gzipSize":553,"inaccurateSizes":true},{"id":null,"label":"ParticlesLighter.js","path":"./dist/browser/index.js + 7 modules (concatenated)/dist/browser/ParticlesLighter.js","statSize":1379,"parsedSize":2018,"gzipSize":516,"inaccurateSizes":true},{"id":null,"label":"Utils.js","path":"./dist/browser/index.js + 7 modules (concatenated)/dist/browser/Utils.js","statSize":2612,"parsedSize":3822,"gzipSize":979,"inaccurateSizes":true}],"parsedSize":11615,"gzipSize":2975,"inaccurateSizes":true}]}],"parsedSize":11615,"gzipSize":2975},{"label":"engine\",\"commonjs2\":\"@tsparticles/engine\",\"amd\":\"@tsparticles","path":"./engine\",\"commonjs2\":\"@tsparticles/engine\",\"amd\":\"@tsparticles","statSize":42,"groups":[{"id":533,"label":"engine\",\"root\":\"window\"}","path":"./engine\",\"commonjs2\":\"@tsparticles/engine\",\"amd\":\"@tsparticles/engine\",\"root\":\"window\"}","statSize":42}],"parsedSize":0,"gzipSize":0}],"isInitialByEntrypoint":{"tsparticles.interaction.light":true}}];
|
|
35
35
|
window.entrypoints = ["tsparticles.interaction.light","tsparticles.interaction.light.min"];
|
|
36
36
|
window.defaultSizes = "parsed";
|
|
37
37
|
</script>
|
|
@@ -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
|
-
* v3.0
|
|
7
|
+
* v3.1.0
|
|
8
8
|
*/
|
|
9
9
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
10
10
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
@@ -102,6 +102,17 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
102
102
|
var engine_root_window_ = __webpack_require__(533);
|
|
103
103
|
;// CONCATENATED MODULE: ./dist/browser/Utils.js
|
|
104
104
|
|
|
105
|
+
const gradientPos = {
|
|
106
|
+
max: 1,
|
|
107
|
+
min: 0
|
|
108
|
+
},
|
|
109
|
+
half = 0.5,
|
|
110
|
+
Utils_double = 2,
|
|
111
|
+
halfPI = Math.PI * half,
|
|
112
|
+
doublePI = Math.PI * Utils_double,
|
|
113
|
+
quarter = 0.25,
|
|
114
|
+
quarterPI = Math.PI * quarter,
|
|
115
|
+
arcStart = 0;
|
|
105
116
|
const lightMode = "light";
|
|
106
117
|
function drawLight(container, context, mousePos) {
|
|
107
118
|
const lightOptions = container.actualOptions.interactivity.modes.light?.area;
|
|
@@ -109,14 +120,14 @@ function drawLight(container, context, mousePos) {
|
|
|
109
120
|
return;
|
|
110
121
|
}
|
|
111
122
|
context.beginPath();
|
|
112
|
-
context.arc(mousePos.x, mousePos.y, lightOptions.radius,
|
|
113
|
-
const gradientAmbientLight = context.createRadialGradient(mousePos.x, mousePos.y,
|
|
123
|
+
context.arc(mousePos.x, mousePos.y, lightOptions.radius, arcStart, doublePI);
|
|
124
|
+
const gradientAmbientLight = context.createRadialGradient(mousePos.x, mousePos.y, arcStart, mousePos.x, mousePos.y, lightOptions.radius);
|
|
114
125
|
const gradientRgb = container.canvas.mouseLight;
|
|
115
|
-
if (!gradientRgb
|
|
126
|
+
if (!gradientRgb?.start || !gradientRgb.stop) {
|
|
116
127
|
return;
|
|
117
128
|
}
|
|
118
|
-
gradientAmbientLight.addColorStop(
|
|
119
|
-
gradientAmbientLight.addColorStop(
|
|
129
|
+
gradientAmbientLight.addColorStop(gradientPos.min, (0,engine_root_window_.getStyleFromRgb)(gradientRgb.start));
|
|
130
|
+
gradientAmbientLight.addColorStop(gradientPos.max, (0,engine_root_window_.getStyleFromRgb)(gradientRgb.stop));
|
|
120
131
|
context.fillStyle = gradientAmbientLight;
|
|
121
132
|
context.fill();
|
|
122
133
|
}
|
|
@@ -132,8 +143,8 @@ function drawParticleShadow(container, context, particle, mousePos) {
|
|
|
132
143
|
}
|
|
133
144
|
const radius = particle.getRadius(),
|
|
134
145
|
sides = particle.sides,
|
|
135
|
-
full =
|
|
136
|
-
angle = -particle.rotation +
|
|
146
|
+
full = doublePI / sides,
|
|
147
|
+
angle = -particle.rotation + quarterPI,
|
|
137
148
|
factor = 1,
|
|
138
149
|
dots = [];
|
|
139
150
|
for (let i = 0; i < sides; i++) {
|
|
@@ -147,8 +158,8 @@ function drawParticleShadow(container, context, particle, mousePos) {
|
|
|
147
158
|
for (const dot of dots) {
|
|
148
159
|
const dotAngle = Math.atan2(mousePos.y - dot.y, mousePos.x - dot.x),
|
|
149
160
|
end = {
|
|
150
|
-
x: dot.x + shadowLength * Math.sin(-dotAngle -
|
|
151
|
-
y: dot.y + shadowLength * Math.cos(-dotAngle -
|
|
161
|
+
x: dot.x + shadowLength * Math.sin(-dotAngle - halfPI),
|
|
162
|
+
y: dot.y + shadowLength * Math.cos(-dotAngle - halfPI)
|
|
152
163
|
};
|
|
153
164
|
points.push({
|
|
154
165
|
end: end,
|
|
@@ -156,8 +167,10 @@ function drawParticleShadow(container, context, particle, mousePos) {
|
|
|
156
167
|
});
|
|
157
168
|
}
|
|
158
169
|
const shadowColor = (0,engine_root_window_.getStyleFromRgb)(shadowRgb),
|
|
159
|
-
|
|
160
|
-
|
|
170
|
+
lastOffset = 1,
|
|
171
|
+
firstPos = 0,
|
|
172
|
+
last = points.length - lastOffset;
|
|
173
|
+
for (let i = last, n = 0; i >= firstPos; n = i--) {
|
|
161
174
|
context.beginPath();
|
|
162
175
|
context.moveTo(points[i].start.x, points[i].start.y);
|
|
163
176
|
context.lineTo(points[n].start.x, points[n].start.y);
|
|
@@ -259,6 +272,7 @@ class ExternalLighter extends engine_root_window_.ExternalInteractorBase {
|
|
|
259
272
|
container.canvas.draw(ctx => {
|
|
260
273
|
drawLight(container, ctx, mousePos);
|
|
261
274
|
});
|
|
275
|
+
await Promise.resolve();
|
|
262
276
|
}
|
|
263
277
|
isEnabled(particle) {
|
|
264
278
|
const container = this.container,
|
|
@@ -311,6 +325,7 @@ class ParticlesLighter extends engine_root_window_.ParticlesInteractorBase {
|
|
|
311
325
|
container.canvas.draw(ctx => {
|
|
312
326
|
drawParticleShadow(container, ctx, particle, mousePos);
|
|
313
327
|
});
|
|
328
|
+
await Promise.resolve();
|
|
314
329
|
}
|
|
315
330
|
isEnabled(particle) {
|
|
316
331
|
const container = this.container,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see tsparticles.interaction.light.min.js.LICENSE.txt */
|
|
2
|
-
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],e);else{var o="object"==typeof exports?e(require("@tsparticles/engine")):e(t.window);for(var i in o)("object"==typeof exports?exports:t)[i]=o[i]}}(this,(t=>(()=>{"use strict";var e={533:e=>{e.exports=t}},o={};function i(t){var r=o[t];if(void 0!==r)return r.exports;var s=o[t]={exports:{}};return e[t](s,s.exports,i),s.exports}i.d=(t,e)=>{for(var o in e)i.o(e,o)&&!i.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r={};return(()=>{i.r(r),i.d(r,{Light:()=>
|
|
2
|
+
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],e);else{var o="object"==typeof exports?e(require("@tsparticles/engine")):e(t.window);for(var i in o)("object"==typeof exports?exports:t)[i]=o[i]}}(this,(t=>(()=>{"use strict";var e={533:e=>{e.exports=t}},o={};function i(t){var r=o[t];if(void 0!==r)return r.exports;var s=o[t]={exports:{}};return e[t](s,s.exports,i),s.exports}i.d=(t,e)=>{for(var o in e)i.o(e,o)&&!i.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r={};return(()=>{i.r(r),i.d(r,{Light:()=>u,LightArea:()=>d,LightGradient:()=>l,LightShadow:()=>h,loadLightInteraction:()=>f});var t=i(533);const e=1,o=0,s=.5*Math.PI,n=2*Math.PI,a=.25*Math.PI,c="light";class l{constructor(){this.start=new t.OptionsColor,this.stop=new t.OptionsColor,this.start.value="#ffffff",this.stop.value="#000000"}load(e){e&&(this.start=t.OptionsColor.create(this.start,e.start),this.stop=t.OptionsColor.create(this.stop,e.stop))}}class d{constructor(){this.gradient=new l,this.radius=1e3}load(t){t&&(this.gradient.load(t.gradient),void 0!==t.radius&&(this.radius=t.radius))}}class h{constructor(){this.color=new t.OptionsColor,this.color.value="#000000",this.length=2e3}load(e){e&&(this.color=t.OptionsColor.create(this.color,e.color),void 0!==e.length&&(this.length=e.length))}}class u{constructor(){this.area=new d,this.shadow=new h}load(t){t&&(this.area.load(t.area),this.shadow.load(t.shadow))}}class p extends t.ExternalInteractorBase{constructor(t){super(t)}clear(){}init(){}async interact(){const i=this.container,r=i.actualOptions,s=i.interactivity;if(!r.interactivity.events.onHover.enable||"pointermove"!==s.status)return;const a=s.mouse.position;a&&(i.canvas.draw((r=>{!function(i,r,s){const a=i.actualOptions.interactivity.modes.light?.area;if(!a)return;r.beginPath(),r.arc(s.x,s.y,a.radius,0,n);const c=r.createRadialGradient(s.x,s.y,0,s.x,s.y,a.radius),l=i.canvas.mouseLight;l?.start&&l.stop&&(c.addColorStop(o,(0,t.getStyleFromRgb)(l.start)),c.addColorStop(e,(0,t.getStyleFromRgb)(l.stop)),r.fillStyle=c,r.fill())}(i,r,a)})),await Promise.resolve())}isEnabled(e){const o=this.container,i=o.interactivity.mouse,r=e?.interactivity??o.actualOptions.interactivity,s=r.events;if(!s.onHover.enable||!i.position)return!1;const n=(0,t.isInArray)(c,s.onHover.mode);if(n&&r.modes.light){const e=r.modes.light.area.gradient;o.canvas.mouseLight={start:(0,t.rangeColorToRgb)(e.start),stop:(0,t.rangeColorToRgb)(e.stop)}}return n}loadModeOptions(t,...e){t.light||(t.light=new u);for(const o of e)t.light.load(o?.light)}reset(){}}class g extends t.ParticlesInteractorBase{constructor(t){super(t)}clear(){}init(){}async interact(e){const o=this.container,i=o.actualOptions,r=o.interactivity;if(!i.interactivity.events.onHover.enable||"pointermove"!==r.status)return;const c=r.mouse.position;c&&(o.canvas.draw((i=>{!function(e,o,i,r){const c=i.getPosition(),l=e.actualOptions.interactivity.modes.light?.shadow;if(!l)return;const d=i.lightShadow;if(!d)return;const h=i.getRadius(),u=i.sides,p=n/u,g=-i.rotation+a,f=[];for(let t=0;t<u;t++)f.push({x:c.x+h*Math.sin(g+p*t)*1,y:c.y+h*Math.cos(g+p*t)*1});const y=[],v=l.length;for(const t of f){const e=Math.atan2(r.y-t.y,r.x-t.x),o={x:t.x+v*Math.sin(-e-s),y:t.y+v*Math.cos(-e-s)};y.push({end:o,start:t})}const m=(0,t.getStyleFromRgb)(d);for(let t=y.length-1,e=0;t>=0;e=t--)o.beginPath(),o.moveTo(y[t].start.x,y[t].start.y),o.lineTo(y[e].start.x,y[e].start.y),o.lineTo(y[e].end.x,y[e].end.y),o.lineTo(y[t].end.x,y[t].end.y),o.fillStyle=m,o.fill()}(o,i,e,c)})),await Promise.resolve())}isEnabled(e){const o=this.container,i=e.interactivity??o.actualOptions.interactivity,r=o.interactivity.mouse,s=i.events;if(!s.onHover.enable||!r.position)return!1;const n=(0,t.isInArray)(c,s.onHover.mode);if(n&&i.modes.light){const o=i.modes.light.shadow;e.lightShadow=(0,t.rangeColorToRgb)(o.color)}return n}reset(){}}async function f(t,e=!0){await t.addInteractor("externalLight",(t=>new p(t)),e),await t.addInteractor("particlesLight",(t=>new g(t)),e)}})(),r})()));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
/*! tsParticles Light Interaction v3.0
|
|
1
|
+
/*! tsParticles Light Interaction v3.1.0 by Matteo Bruni */
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ExternalInteractorBase, type IModes, type Modes, type RecursivePartial } from "@tsparticles/engine";
|
|
2
|
-
import type { ILightMode, LightMode } from "./Types.js";
|
|
3
|
-
import type { LightContainer, LightParticle } from "./Types.js";
|
|
2
|
+
import type { ILightMode, LightContainer, LightMode, LightParticle } from "./Types.js";
|
|
4
3
|
export declare class ExternalLighter extends ExternalInteractorBase<LightContainer> {
|
|
5
4
|
constructor(container: LightContainer);
|
|
6
5
|
clear(): void;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type IOptionLoader, OptionsColor, type RecursivePartial } from "@tsparticles/engine";
|
|
2
2
|
import type { ILightGradient } from "../Interfaces/ILightGradient.js";
|
|
3
|
-
import { OptionsColor } from "@tsparticles/engine";
|
|
4
3
|
export declare class LightGradient implements ILightGradient, IOptionLoader<ILightGradient> {
|
|
5
4
|
start: OptionsColor;
|
|
6
5
|
stop: OptionsColor;
|
package/types/Types.d.ts
CHANGED
|
@@ -2,12 +2,12 @@ import type { Container, IRgb, Particle } from "@tsparticles/engine";
|
|
|
2
2
|
import type { LightOptions, LightParticlesOptions } from "./Options/Classes/LightOptions.js";
|
|
3
3
|
import type { ILight } from "./Options/Interfaces/ILight.js";
|
|
4
4
|
import type { Light } from "./Options/Classes/Light.js";
|
|
5
|
-
export
|
|
5
|
+
export interface ILightMode {
|
|
6
6
|
light?: ILight;
|
|
7
|
-
}
|
|
8
|
-
export
|
|
7
|
+
}
|
|
8
|
+
export interface LightMode {
|
|
9
9
|
light?: Light;
|
|
10
|
-
}
|
|
10
|
+
}
|
|
11
11
|
export type LightContainer = Container & {
|
|
12
12
|
actualOptions: LightOptions;
|
|
13
13
|
canvas: {
|
package/umd/ExternalLighter.js
CHANGED
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
container.canvas.draw((ctx) => {
|
|
34
34
|
(0, Utils_js_1.drawLight)(container, ctx, mousePos);
|
|
35
35
|
});
|
|
36
|
+
await Promise.resolve();
|
|
36
37
|
}
|
|
37
38
|
isEnabled(particle) {
|
|
38
39
|
const container = this.container, mouse = container.interactivity.mouse, interactivity = particle?.interactivity ?? container.actualOptions.interactivity, events = interactivity.events;
|
package/umd/ParticlesLighter.js
CHANGED
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
container.canvas.draw((ctx) => {
|
|
33
33
|
(0, Utils_js_1.drawParticleShadow)(container, ctx, particle, mousePos);
|
|
34
34
|
});
|
|
35
|
+
await Promise.resolve();
|
|
35
36
|
}
|
|
36
37
|
isEnabled(particle) {
|
|
37
38
|
const container = this.container, interactivity = particle.interactivity ?? container.actualOptions.interactivity, mouse = container.interactivity.mouse, events = interactivity.events;
|
package/umd/Utils.js
CHANGED
|
@@ -11,6 +11,10 @@
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.drawParticleShadow = exports.drawLight = exports.lightMode = void 0;
|
|
13
13
|
const engine_1 = require("@tsparticles/engine");
|
|
14
|
+
const gradientPos = {
|
|
15
|
+
max: 1,
|
|
16
|
+
min: 0,
|
|
17
|
+
}, half = 0.5, double = 2, halfPI = Math.PI * half, doublePI = Math.PI * double, quarter = 0.25, quarterPI = Math.PI * quarter, arcStart = 0;
|
|
14
18
|
exports.lightMode = "light";
|
|
15
19
|
function drawLight(container, context, mousePos) {
|
|
16
20
|
const lightOptions = container.actualOptions.interactivity.modes.light?.area;
|
|
@@ -18,14 +22,14 @@
|
|
|
18
22
|
return;
|
|
19
23
|
}
|
|
20
24
|
context.beginPath();
|
|
21
|
-
context.arc(mousePos.x, mousePos.y, lightOptions.radius,
|
|
22
|
-
const gradientAmbientLight = context.createRadialGradient(mousePos.x, mousePos.y,
|
|
25
|
+
context.arc(mousePos.x, mousePos.y, lightOptions.radius, arcStart, doublePI);
|
|
26
|
+
const gradientAmbientLight = context.createRadialGradient(mousePos.x, mousePos.y, arcStart, mousePos.x, mousePos.y, lightOptions.radius);
|
|
23
27
|
const gradientRgb = container.canvas.mouseLight;
|
|
24
|
-
if (!gradientRgb
|
|
28
|
+
if (!gradientRgb?.start || !gradientRgb.stop) {
|
|
25
29
|
return;
|
|
26
30
|
}
|
|
27
|
-
gradientAmbientLight.addColorStop(
|
|
28
|
-
gradientAmbientLight.addColorStop(
|
|
31
|
+
gradientAmbientLight.addColorStop(gradientPos.min, (0, engine_1.getStyleFromRgb)(gradientRgb.start));
|
|
32
|
+
gradientAmbientLight.addColorStop(gradientPos.max, (0, engine_1.getStyleFromRgb)(gradientRgb.stop));
|
|
29
33
|
context.fillStyle = gradientAmbientLight;
|
|
30
34
|
context.fill();
|
|
31
35
|
}
|
|
@@ -39,7 +43,7 @@
|
|
|
39
43
|
if (!shadowRgb) {
|
|
40
44
|
return;
|
|
41
45
|
}
|
|
42
|
-
const radius = particle.getRadius(), sides = particle.sides, full =
|
|
46
|
+
const radius = particle.getRadius(), sides = particle.sides, full = doublePI / sides, angle = -particle.rotation + quarterPI, factor = 1, dots = [];
|
|
43
47
|
for (let i = 0; i < sides; i++) {
|
|
44
48
|
dots.push({
|
|
45
49
|
x: pos.x + radius * Math.sin(angle + full * i) * factor,
|
|
@@ -49,16 +53,16 @@
|
|
|
49
53
|
const points = [], shadowLength = shadowOptions.length;
|
|
50
54
|
for (const dot of dots) {
|
|
51
55
|
const dotAngle = Math.atan2(mousePos.y - dot.y, mousePos.x - dot.x), end = {
|
|
52
|
-
x: dot.x + shadowLength * Math.sin(-dotAngle -
|
|
53
|
-
y: dot.y + shadowLength * Math.cos(-dotAngle -
|
|
56
|
+
x: dot.x + shadowLength * Math.sin(-dotAngle - halfPI),
|
|
57
|
+
y: dot.y + shadowLength * Math.cos(-dotAngle - halfPI),
|
|
54
58
|
};
|
|
55
59
|
points.push({
|
|
56
60
|
end: end,
|
|
57
61
|
start: dot,
|
|
58
62
|
});
|
|
59
63
|
}
|
|
60
|
-
const shadowColor = (0, engine_1.getStyleFromRgb)(shadowRgb), last = points.length -
|
|
61
|
-
for (let i = last, n = 0; i >=
|
|
64
|
+
const shadowColor = (0, engine_1.getStyleFromRgb)(shadowRgb), lastOffset = 1, firstPos = 0, last = points.length - lastOffset;
|
|
65
|
+
for (let i = last, n = 0; i >= firstPos; n = i--) {
|
|
62
66
|
context.beginPath();
|
|
63
67
|
context.moveTo(points[i].start.x, points[i].start.y);
|
|
64
68
|
context.lineTo(points[n].start.x, points[n].start.y);
|