@tsparticles/interaction-light 3.0.3 → 3.2.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/338.min.js +2 -0
- package/338.min.js.LICENSE.txt +1 -0
- package/388.min.js +2 -0
- package/388.min.js.LICENSE.txt +1 -0
- package/browser/ExternalLighter.js +1 -0
- package/browser/ParticlesLighter.js +1 -0
- package/browser/Utils.js +14 -10
- package/browser/index.js +8 -4
- package/cjs/ExternalLighter.js +1 -0
- package/cjs/ParticlesLighter.js +1 -0
- package/cjs/Utils.js +14 -10
- package/cjs/index.js +20 -4
- package/dist_browser_ExternalLighter_js.js +40 -0
- package/dist_browser_ParticlesLighter_js.js +40 -0
- package/esm/ExternalLighter.js +1 -0
- package/esm/ParticlesLighter.js +1 -0
- package/esm/Utils.js +14 -10
- package/esm/index.js +8 -4
- package/package.json +2 -2
- package/report.html +3 -3
- package/tsparticles.interaction.light.js +281 -267
- 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
- package/umd/index.js +22 -5
|
@@ -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);
|
package/umd/index.js
CHANGED
|
@@ -9,6 +9,18 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
9
9
|
if (k2 === undefined) k2 = k;
|
|
10
10
|
o[k2] = m[k];
|
|
11
11
|
}));
|
|
12
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
13
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
14
|
+
}) : function(o, v) {
|
|
15
|
+
o["default"] = v;
|
|
16
|
+
});
|
|
17
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
18
|
+
if (mod && mod.__esModule) return mod;
|
|
19
|
+
var result = {};
|
|
20
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
21
|
+
__setModuleDefault(result, mod);
|
|
22
|
+
return result;
|
|
23
|
+
};
|
|
12
24
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
13
25
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
14
26
|
};
|
|
@@ -18,17 +30,22 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
18
30
|
if (v !== undefined) module.exports = v;
|
|
19
31
|
}
|
|
20
32
|
else if (typeof define === "function" && define.amd) {
|
|
21
|
-
define(["require", "exports", "./
|
|
33
|
+
define(["require", "exports", "./Options/Classes/Light.js", "./Options/Classes/LightArea.js", "./Options/Classes/LightGradient.js", "./Options/Classes/LightShadow.js", "./Options/Interfaces/ILight.js", "./Options/Interfaces/ILightArea.js", "./Options/Interfaces/ILightGradient.js", "./Options/Interfaces/ILightShadow.js"], factory);
|
|
22
34
|
}
|
|
23
35
|
})(function (require, exports) {
|
|
24
36
|
"use strict";
|
|
37
|
+
var __syncRequire = typeof module === "object" && typeof module.exports === "object";
|
|
25
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
39
|
exports.loadLightInteraction = void 0;
|
|
27
|
-
const ExternalLighter_js_1 = require("./ExternalLighter.js");
|
|
28
|
-
const ParticlesLighter_js_1 = require("./ParticlesLighter.js");
|
|
29
40
|
async function loadLightInteraction(engine, refresh = true) {
|
|
30
|
-
await engine.addInteractor("externalLight", (container) =>
|
|
31
|
-
|
|
41
|
+
await engine.addInteractor("externalLight", async (container) => {
|
|
42
|
+
const { ExternalLighter } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./ExternalLighter.js"))) : new Promise((resolve_1, reject_1) => { require(["./ExternalLighter.js"], resolve_1, reject_1); }).then(__importStar));
|
|
43
|
+
return new ExternalLighter(container);
|
|
44
|
+
}, refresh);
|
|
45
|
+
await engine.addInteractor("particlesLight", async (container) => {
|
|
46
|
+
const { ParticlesLighter } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./ParticlesLighter.js"))) : new Promise((resolve_2, reject_2) => { require(["./ParticlesLighter.js"], resolve_2, reject_2); }).then(__importStar));
|
|
47
|
+
return new ParticlesLighter(container);
|
|
48
|
+
}, refresh);
|
|
32
49
|
}
|
|
33
50
|
exports.loadLightInteraction = loadLightInteraction;
|
|
34
51
|
__exportStar(require("./Options/Classes/Light.js"), exports);
|