@tsparticles/interaction-light 3.0.0-alpha.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/LICENSE +21 -0
- package/README.md +68 -0
- package/browser/ExternalLighter.js +50 -0
- package/browser/Options/Classes/Light.js +15 -0
- package/browser/Options/Classes/LightArea.js +16 -0
- package/browser/Options/Classes/LightGradient.js +16 -0
- package/browser/Options/Classes/LightOptions.js +1 -0
- package/browser/Options/Classes/LightShadow.js +17 -0
- package/browser/Options/Interfaces/ILight.js +1 -0
- package/browser/Options/Interfaces/ILightArea.js +1 -0
- package/browser/Options/Interfaces/ILightGradient.js +1 -0
- package/browser/Options/Interfaces/ILightShadow.js +1 -0
- package/browser/ParticlesLighter.js +37 -0
- package/browser/Types.js +1 -0
- package/browser/Utils.js +58 -0
- package/browser/index.js +14 -0
- package/cjs/ExternalLighter.js +65 -0
- package/cjs/Options/Classes/Light.js +19 -0
- package/cjs/Options/Classes/LightArea.js +20 -0
- package/cjs/Options/Classes/LightGradient.js +20 -0
- package/cjs/Options/Classes/LightOptions.js +2 -0
- package/cjs/Options/Classes/LightShadow.js +21 -0
- package/cjs/Options/Interfaces/ILight.js +2 -0
- package/cjs/Options/Interfaces/ILightArea.js +2 -0
- package/cjs/Options/Interfaces/ILightGradient.js +2 -0
- package/cjs/Options/Interfaces/ILightShadow.js +2 -0
- package/cjs/ParticlesLighter.js +52 -0
- package/cjs/Types.js +2 -0
- package/cjs/Utils.js +63 -0
- package/cjs/index.js +32 -0
- package/esm/ExternalLighter.js +50 -0
- package/esm/Options/Classes/Light.js +15 -0
- package/esm/Options/Classes/LightArea.js +16 -0
- package/esm/Options/Classes/LightGradient.js +16 -0
- package/esm/Options/Classes/LightOptions.js +1 -0
- package/esm/Options/Classes/LightShadow.js +17 -0
- package/esm/Options/Interfaces/ILight.js +1 -0
- package/esm/Options/Interfaces/ILightArea.js +1 -0
- package/esm/Options/Interfaces/ILightGradient.js +1 -0
- package/esm/Options/Interfaces/ILightShadow.js +1 -0
- package/esm/ParticlesLighter.js +37 -0
- package/esm/Types.js +1 -0
- package/esm/Utils.js +58 -0
- package/esm/index.js +14 -0
- package/package.json +92 -0
- package/report.html +39 -0
- package/tsparticles.interaction.light.js +350 -0
- package/tsparticles.interaction.light.min.js +2 -0
- package/tsparticles.interaction.light.min.js.LICENSE.txt +8 -0
- package/types/ExternalLighter.d.ts +13 -0
- package/types/Options/Classes/Light.d.ts +10 -0
- package/types/Options/Classes/LightArea.d.ts +9 -0
- package/types/Options/Classes/LightGradient.d.ts +9 -0
- package/types/Options/Classes/LightOptions.d.ts +12 -0
- package/types/Options/Classes/LightShadow.d.ts +9 -0
- package/types/Options/Interfaces/ILight.d.ts +6 -0
- package/types/Options/Interfaces/ILightArea.d.ts +5 -0
- package/types/Options/Interfaces/ILightGradient.d.ts +5 -0
- package/types/Options/Interfaces/ILightShadow.d.ts +5 -0
- package/types/ParticlesLighter.d.ts +10 -0
- package/types/Types.d.ts +26 -0
- package/types/Utils.d.ts +4 -0
- package/types/index.d.ts +10 -0
- package/umd/ExternalLighter.js +64 -0
- package/umd/Options/Classes/Light.js +29 -0
- package/umd/Options/Classes/LightArea.js +30 -0
- package/umd/Options/Classes/LightGradient.js +30 -0
- package/umd/Options/Classes/LightOptions.js +12 -0
- package/umd/Options/Classes/LightShadow.js +31 -0
- package/umd/Options/Interfaces/ILight.js +12 -0
- package/umd/Options/Interfaces/ILightArea.js +12 -0
- package/umd/Options/Interfaces/ILightGradient.js +12 -0
- package/umd/Options/Interfaces/ILightShadow.js +12 -0
- package/umd/ParticlesLighter.js +51 -0
- package/umd/Types.js +12 -0
- package/umd/Utils.js +73 -0
- package/umd/index.js +42 -0
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Author : Matteo Bruni
|
|
3
|
+
* MIT license: https://opensource.org/licenses/MIT
|
|
4
|
+
* Demo / Generator : https://particles.js.org/
|
|
5
|
+
* GitHub : https://www.github.com/matteobruni/tsparticles
|
|
6
|
+
* How to use? : Check the GitHub README
|
|
7
|
+
* v3.0.0-alpha.0
|
|
8
|
+
*/
|
|
9
|
+
(function webpackUniversalModuleDefinition(root, factory) {
|
|
10
|
+
if(typeof exports === 'object' && typeof module === 'object')
|
|
11
|
+
module.exports = factory(require("@tsparticles/engine"));
|
|
12
|
+
else if(typeof define === 'function' && define.amd)
|
|
13
|
+
define(["@tsparticles/engine"], factory);
|
|
14
|
+
else {
|
|
15
|
+
var a = typeof exports === 'object' ? factory(require("@tsparticles/engine")) : factory(root["window"]);
|
|
16
|
+
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
|
|
17
|
+
}
|
|
18
|
+
})(this, (__WEBPACK_EXTERNAL_MODULE__533__) => {
|
|
19
|
+
return /******/ (() => { // webpackBootstrap
|
|
20
|
+
/******/ "use strict";
|
|
21
|
+
/******/ var __webpack_modules__ = ({
|
|
22
|
+
|
|
23
|
+
/***/ 533:
|
|
24
|
+
/***/ ((module) => {
|
|
25
|
+
|
|
26
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE__533__;
|
|
27
|
+
|
|
28
|
+
/***/ })
|
|
29
|
+
|
|
30
|
+
/******/ });
|
|
31
|
+
/************************************************************************/
|
|
32
|
+
/******/ // The module cache
|
|
33
|
+
/******/ var __webpack_module_cache__ = {};
|
|
34
|
+
/******/
|
|
35
|
+
/******/ // The require function
|
|
36
|
+
/******/ function __webpack_require__(moduleId) {
|
|
37
|
+
/******/ // Check if module is in cache
|
|
38
|
+
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
39
|
+
/******/ if (cachedModule !== undefined) {
|
|
40
|
+
/******/ return cachedModule.exports;
|
|
41
|
+
/******/ }
|
|
42
|
+
/******/ // Create a new module (and put it into the cache)
|
|
43
|
+
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
44
|
+
/******/ // no module.id needed
|
|
45
|
+
/******/ // no module.loaded needed
|
|
46
|
+
/******/ exports: {}
|
|
47
|
+
/******/ };
|
|
48
|
+
/******/
|
|
49
|
+
/******/ // Execute the module function
|
|
50
|
+
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
51
|
+
/******/
|
|
52
|
+
/******/ // Return the exports of the module
|
|
53
|
+
/******/ return module.exports;
|
|
54
|
+
/******/ }
|
|
55
|
+
/******/
|
|
56
|
+
/************************************************************************/
|
|
57
|
+
/******/ /* webpack/runtime/define property getters */
|
|
58
|
+
/******/ (() => {
|
|
59
|
+
/******/ // define getter functions for harmony exports
|
|
60
|
+
/******/ __webpack_require__.d = (exports, definition) => {
|
|
61
|
+
/******/ for(var key in definition) {
|
|
62
|
+
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
63
|
+
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
64
|
+
/******/ }
|
|
65
|
+
/******/ }
|
|
66
|
+
/******/ };
|
|
67
|
+
/******/ })();
|
|
68
|
+
/******/
|
|
69
|
+
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
70
|
+
/******/ (() => {
|
|
71
|
+
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
72
|
+
/******/ })();
|
|
73
|
+
/******/
|
|
74
|
+
/******/ /* webpack/runtime/make namespace object */
|
|
75
|
+
/******/ (() => {
|
|
76
|
+
/******/ // define __esModule on exports
|
|
77
|
+
/******/ __webpack_require__.r = (exports) => {
|
|
78
|
+
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
79
|
+
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
80
|
+
/******/ }
|
|
81
|
+
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
82
|
+
/******/ };
|
|
83
|
+
/******/ })();
|
|
84
|
+
/******/
|
|
85
|
+
/************************************************************************/
|
|
86
|
+
var __webpack_exports__ = {};
|
|
87
|
+
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
|
|
88
|
+
(() => {
|
|
89
|
+
// ESM COMPAT FLAG
|
|
90
|
+
__webpack_require__.r(__webpack_exports__);
|
|
91
|
+
|
|
92
|
+
// EXPORTS
|
|
93
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
94
|
+
"Light": () => (/* reexport */ Light),
|
|
95
|
+
"LightArea": () => (/* reexport */ LightArea),
|
|
96
|
+
"LightGradient": () => (/* reexport */ LightGradient),
|
|
97
|
+
"LightShadow": () => (/* reexport */ LightShadow),
|
|
98
|
+
"loadLightInteraction": () => (/* binding */ loadLightInteraction)
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
// EXTERNAL MODULE: external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"}
|
|
102
|
+
var engine_root_window_ = __webpack_require__(533);
|
|
103
|
+
;// CONCATENATED MODULE: ./dist/browser/Options/Classes/LightGradient.js
|
|
104
|
+
|
|
105
|
+
class LightGradient {
|
|
106
|
+
constructor() {
|
|
107
|
+
this.start = new engine_root_window_.OptionsColor();
|
|
108
|
+
this.stop = new engine_root_window_.OptionsColor();
|
|
109
|
+
this.start.value = "#ffffff";
|
|
110
|
+
this.stop.value = "#000000";
|
|
111
|
+
}
|
|
112
|
+
load(data) {
|
|
113
|
+
if (!data) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
this.start = engine_root_window_.OptionsColor.create(this.start, data.start);
|
|
117
|
+
this.stop = engine_root_window_.OptionsColor.create(this.stop, data.stop);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
;// CONCATENATED MODULE: ./dist/browser/Options/Classes/LightArea.js
|
|
121
|
+
|
|
122
|
+
class LightArea {
|
|
123
|
+
constructor() {
|
|
124
|
+
this.gradient = new LightGradient();
|
|
125
|
+
this.radius = 1000;
|
|
126
|
+
}
|
|
127
|
+
load(data) {
|
|
128
|
+
if (!data) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
this.gradient.load(data.gradient);
|
|
132
|
+
if (data.radius !== undefined) {
|
|
133
|
+
this.radius = data.radius;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
;// CONCATENATED MODULE: ./dist/browser/Options/Classes/LightShadow.js
|
|
138
|
+
|
|
139
|
+
class LightShadow {
|
|
140
|
+
constructor() {
|
|
141
|
+
this.color = new engine_root_window_.OptionsColor();
|
|
142
|
+
this.color.value = "#000000";
|
|
143
|
+
this.length = 2000;
|
|
144
|
+
}
|
|
145
|
+
load(data) {
|
|
146
|
+
if (!data) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
this.color = engine_root_window_.OptionsColor.create(this.color, data.color);
|
|
150
|
+
if (data.length !== undefined) {
|
|
151
|
+
this.length = data.length;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Light.js
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
class Light {
|
|
159
|
+
constructor() {
|
|
160
|
+
this.area = new LightArea();
|
|
161
|
+
this.shadow = new LightShadow();
|
|
162
|
+
}
|
|
163
|
+
load(data) {
|
|
164
|
+
if (!data) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
this.area.load(data.area);
|
|
168
|
+
this.shadow.load(data.shadow);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
;// CONCATENATED MODULE: ./dist/browser/Utils.js
|
|
172
|
+
|
|
173
|
+
function drawLight(container, context, mousePos) {
|
|
174
|
+
var _a;
|
|
175
|
+
const lightOptions = (_a = container.actualOptions.interactivity.modes.light) === null || _a === void 0 ? void 0 : _a.area;
|
|
176
|
+
if (!lightOptions) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
context.beginPath();
|
|
180
|
+
context.arc(mousePos.x, mousePos.y, lightOptions.radius, 0, 2 * Math.PI);
|
|
181
|
+
const gradientAmbientLight = context.createRadialGradient(mousePos.x, mousePos.y, 0, mousePos.x, mousePos.y, lightOptions.radius);
|
|
182
|
+
const gradientRgb = container.canvas.mouseLight;
|
|
183
|
+
if (!gradientRgb || !gradientRgb.start || !gradientRgb.stop) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
gradientAmbientLight.addColorStop(0, (0,engine_root_window_.getStyleFromRgb)(gradientRgb.start));
|
|
187
|
+
gradientAmbientLight.addColorStop(1, (0,engine_root_window_.getStyleFromRgb)(gradientRgb.stop));
|
|
188
|
+
context.fillStyle = gradientAmbientLight;
|
|
189
|
+
context.fill();
|
|
190
|
+
}
|
|
191
|
+
function drawParticleShadow(container, context, particle, mousePos) {
|
|
192
|
+
var _a;
|
|
193
|
+
const pos = particle.getPosition(),
|
|
194
|
+
shadowOptions = (_a = container.actualOptions.interactivity.modes.light) === null || _a === void 0 ? void 0 : _a.shadow;
|
|
195
|
+
if (!shadowOptions) {
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
const shadowRgb = particle.lightShadow;
|
|
199
|
+
if (!shadowRgb) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
const radius = particle.getRadius(),
|
|
203
|
+
sides = particle.sides,
|
|
204
|
+
full = Math.PI * 2 / sides,
|
|
205
|
+
angle = -particle.rotation + Math.PI / 4,
|
|
206
|
+
factor = 1,
|
|
207
|
+
dots = [];
|
|
208
|
+
for (let i = 0; i < sides; i++) {
|
|
209
|
+
dots.push({
|
|
210
|
+
x: pos.x + radius * Math.sin(angle + full * i) * factor,
|
|
211
|
+
y: pos.y + radius * Math.cos(angle + full * i) * factor
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
const points = [],
|
|
215
|
+
shadowLength = shadowOptions.length;
|
|
216
|
+
for (const dot of dots) {
|
|
217
|
+
const dotAngle = Math.atan2(mousePos.y - dot.y, mousePos.x - dot.x),
|
|
218
|
+
endX = dot.x + shadowLength * Math.sin(-dotAngle - Math.PI / 2),
|
|
219
|
+
endY = dot.y + shadowLength * Math.cos(-dotAngle - Math.PI / 2);
|
|
220
|
+
points.push({
|
|
221
|
+
endX: endX,
|
|
222
|
+
endY: endY,
|
|
223
|
+
startX: dot.x,
|
|
224
|
+
startY: dot.y
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
const shadowColor = (0,engine_root_window_.getStyleFromRgb)(shadowRgb);
|
|
228
|
+
for (let i = points.length - 1; i >= 0; i--) {
|
|
229
|
+
const n = i === points.length - 1 ? 0 : i + 1;
|
|
230
|
+
context.beginPath();
|
|
231
|
+
context.moveTo(points[i].startX, points[i].startY);
|
|
232
|
+
context.lineTo(points[n].startX, points[n].startY);
|
|
233
|
+
context.lineTo(points[n].endX, points[n].endY);
|
|
234
|
+
context.lineTo(points[i].endX, points[i].endY);
|
|
235
|
+
context.fillStyle = shadowColor;
|
|
236
|
+
context.fill();
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
;// CONCATENATED MODULE: ./dist/browser/ExternalLighter.js
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
class ExternalLighter extends engine_root_window_.ExternalInteractorBase {
|
|
244
|
+
constructor(container) {
|
|
245
|
+
super(container);
|
|
246
|
+
}
|
|
247
|
+
clear() {}
|
|
248
|
+
init() {}
|
|
249
|
+
async interact() {
|
|
250
|
+
const container = this.container,
|
|
251
|
+
options = container.actualOptions;
|
|
252
|
+
if (options.interactivity.events.onHover.enable && container.interactivity.status === "pointermove") {
|
|
253
|
+
const mousePos = container.interactivity.mouse.position;
|
|
254
|
+
if (!mousePos) {
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
container.canvas.draw(ctx => {
|
|
258
|
+
drawLight(container, ctx, mousePos);
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
isEnabled(particle) {
|
|
263
|
+
var _a;
|
|
264
|
+
const container = this.container,
|
|
265
|
+
mouse = container.interactivity.mouse,
|
|
266
|
+
interactivity = (_a = particle === null || particle === void 0 ? void 0 : particle.interactivity) !== null && _a !== void 0 ? _a : container.actualOptions.interactivity,
|
|
267
|
+
events = interactivity.events;
|
|
268
|
+
if (!(events.onHover.enable && mouse.position)) {
|
|
269
|
+
return false;
|
|
270
|
+
}
|
|
271
|
+
const res = (0,engine_root_window_.isInArray)("light", events.onHover.mode);
|
|
272
|
+
if (res && interactivity.modes.light) {
|
|
273
|
+
const lightGradient = interactivity.modes.light.area.gradient;
|
|
274
|
+
container.canvas.mouseLight = {
|
|
275
|
+
start: (0,engine_root_window_.rangeColorToRgb)(lightGradient.start),
|
|
276
|
+
stop: (0,engine_root_window_.rangeColorToRgb)(lightGradient.stop)
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
return res;
|
|
280
|
+
}
|
|
281
|
+
loadModeOptions(options, ...sources) {
|
|
282
|
+
if (!options.light) {
|
|
283
|
+
options.light = new Light();
|
|
284
|
+
}
|
|
285
|
+
for (const source of sources) {
|
|
286
|
+
options.light.load(source === null || source === void 0 ? void 0 : source.light);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
reset() {}
|
|
290
|
+
}
|
|
291
|
+
;// CONCATENATED MODULE: ./dist/browser/ParticlesLighter.js
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
class ParticlesLighter extends engine_root_window_.ParticlesInteractorBase {
|
|
295
|
+
constructor(container) {
|
|
296
|
+
super(container);
|
|
297
|
+
}
|
|
298
|
+
clear() {}
|
|
299
|
+
init() {}
|
|
300
|
+
async interact(particle) {
|
|
301
|
+
const container = this.container,
|
|
302
|
+
options = container.actualOptions;
|
|
303
|
+
if (options.interactivity.events.onHover.enable && container.interactivity.status === "pointermove") {
|
|
304
|
+
const mousePos = this.container.interactivity.mouse.position;
|
|
305
|
+
if (mousePos) {
|
|
306
|
+
container.canvas.draw(ctx => {
|
|
307
|
+
drawParticleShadow(container, ctx, particle, mousePos);
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
isEnabled(particle) {
|
|
313
|
+
var _a;
|
|
314
|
+
const container = this.container,
|
|
315
|
+
interactivity = (_a = particle.interactivity) !== null && _a !== void 0 ? _a : container.actualOptions.interactivity,
|
|
316
|
+
mouse = container.interactivity.mouse,
|
|
317
|
+
events = interactivity.events;
|
|
318
|
+
if (!(events.onHover.enable && mouse.position)) {
|
|
319
|
+
return false;
|
|
320
|
+
}
|
|
321
|
+
const res = (0,engine_root_window_.isInArray)("light", events.onHover.mode);
|
|
322
|
+
if (res && interactivity.modes.light) {
|
|
323
|
+
const shadowOptions = interactivity.modes.light.shadow;
|
|
324
|
+
particle.lightShadow = (0,engine_root_window_.rangeColorToRgb)(shadowOptions.color);
|
|
325
|
+
}
|
|
326
|
+
return res;
|
|
327
|
+
}
|
|
328
|
+
reset() {}
|
|
329
|
+
}
|
|
330
|
+
;// CONCATENATED MODULE: ./dist/browser/index.js
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
function loadLightInteraction(engine) {
|
|
334
|
+
engine.addInteractor("externalLight", container => new ExternalLighter(container));
|
|
335
|
+
engine.addInteractor("particlesLight", container => new ParticlesLighter(container));
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
})();
|
|
346
|
+
|
|
347
|
+
/******/ return __webpack_exports__;
|
|
348
|
+
/******/ })()
|
|
349
|
+
;
|
|
350
|
+
});
|
|
@@ -0,0 +1,2 @@
|
|
|
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 n=o[t]={exports:{}};return e[t](n,n.exports,i),n.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:()=>s,LightArea:()=>o,LightGradient:()=>e,LightShadow:()=>n,loadLightInteraction:()=>c});var t=i(533);class e{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 o{constructor(){this.gradient=new e,this.radius=1e3}load(t){t&&(this.gradient.load(t.gradient),void 0!==t.radius&&(this.radius=t.radius))}}class n{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 s{constructor(){this.area=new o,this.shadow=new n}load(t){t&&(this.area.load(t.area),this.shadow.load(t.shadow))}}class a extends t.ExternalInteractorBase{constructor(t){super(t)}clear(){}init(){}async interact(){const e=this.container;if(e.actualOptions.interactivity.events.onHover.enable&&"pointermove"===e.interactivity.status){const o=e.interactivity.mouse.position;if(!o)return;e.canvas.draw((i=>{!function(e,o,i){var r;const n=null===(r=e.actualOptions.interactivity.modes.light)||void 0===r?void 0:r.area;if(!n)return;o.beginPath(),o.arc(i.x,i.y,n.radius,0,2*Math.PI);const s=o.createRadialGradient(i.x,i.y,0,i.x,i.y,n.radius),a=e.canvas.mouseLight;a&&a.start&&a.stop&&(s.addColorStop(0,(0,t.getStyleFromRgb)(a.start)),s.addColorStop(1,(0,t.getStyleFromRgb)(a.stop)),o.fillStyle=s,o.fill())}(e,i,o)}))}}isEnabled(e){var o;const i=this.container,r=i.interactivity.mouse,n=null!==(o=null==e?void 0:e.interactivity)&&void 0!==o?o:i.actualOptions.interactivity,s=n.events;if(!s.onHover.enable||!r.position)return!1;const a=(0,t.isInArray)("light",s.onHover.mode);if(a&&n.modes.light){const e=n.modes.light.area.gradient;i.canvas.mouseLight={start:(0,t.rangeColorToRgb)(e.start),stop:(0,t.rangeColorToRgb)(e.stop)}}return a}loadModeOptions(t,...e){t.light||(t.light=new s);for(const o of e)t.light.load(null==o?void 0:o.light)}reset(){}}class l extends t.ParticlesInteractorBase{constructor(t){super(t)}clear(){}init(){}async interact(e){const o=this.container;if(o.actualOptions.interactivity.events.onHover.enable&&"pointermove"===o.interactivity.status){const i=this.container.interactivity.mouse.position;i&&o.canvas.draw((r=>{!function(e,o,i,r){var n;const s=i.getPosition(),a=null===(n=e.actualOptions.interactivity.modes.light)||void 0===n?void 0:n.shadow;if(!a)return;const l=i.lightShadow;if(!l)return;const c=i.getRadius(),d=i.sides,h=2*Math.PI/d,u=-i.rotation+Math.PI/4,p=[];for(let t=0;t<d;t++)p.push({x:s.x+c*Math.sin(u+h*t)*1,y:s.y+c*Math.cos(u+h*t)*1});const v=[],g=a.length;for(const t of p){const e=Math.atan2(r.y-t.y,r.x-t.x),o=t.x+g*Math.sin(-e-Math.PI/2),i=t.y+g*Math.cos(-e-Math.PI/2);v.push({endX:o,endY:i,startX:t.x,startY:t.y})}const f=(0,t.getStyleFromRgb)(l);for(let t=v.length-1;t>=0;t--){const e=t===v.length-1?0:t+1;o.beginPath(),o.moveTo(v[t].startX,v[t].startY),o.lineTo(v[e].startX,v[e].startY),o.lineTo(v[e].endX,v[e].endY),o.lineTo(v[t].endX,v[t].endY),o.fillStyle=f,o.fill()}}(o,r,e,i)}))}}isEnabled(e){var o;const i=this.container,r=null!==(o=e.interactivity)&&void 0!==o?o:i.actualOptions.interactivity,n=i.interactivity.mouse,s=r.events;if(!s.onHover.enable||!n.position)return!1;const a=(0,t.isInArray)("light",s.onHover.mode);if(a&&r.modes.light){const o=r.modes.light.shadow;e.lightShadow=(0,t.rangeColorToRgb)(o.color)}return a}reset(){}}function c(t){t.addInteractor("externalLight",(t=>new a(t))),t.addInteractor("particlesLight",(t=>new l(t)))}})(),r})()));
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ExternalInteractorBase } from "@tsparticles/engine";
|
|
2
|
+
import type { ILightMode, LightMode } from "./Types";
|
|
3
|
+
import type { IModes, Modes, RecursivePartial } from "@tsparticles/engine";
|
|
4
|
+
import type { LightContainer, LightParticle } from "./Types";
|
|
5
|
+
export declare class ExternalLighter extends ExternalInteractorBase<LightContainer> {
|
|
6
|
+
constructor(container: LightContainer);
|
|
7
|
+
clear(): void;
|
|
8
|
+
init(): void;
|
|
9
|
+
interact(): Promise<void>;
|
|
10
|
+
isEnabled(particle?: LightParticle): boolean;
|
|
11
|
+
loadModeOptions(options: Modes & LightMode, ...sources: RecursivePartial<(IModes & ILightMode) | undefined>[]): void;
|
|
12
|
+
reset(): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { IOptionLoader, RecursivePartial } from "@tsparticles/engine";
|
|
2
|
+
import type { ILight } from "../Interfaces/ILight";
|
|
3
|
+
import { LightArea } from "./LightArea";
|
|
4
|
+
import { LightShadow } from "./LightShadow";
|
|
5
|
+
export declare class Light implements ILight, IOptionLoader<ILight> {
|
|
6
|
+
area: LightArea;
|
|
7
|
+
shadow: LightShadow;
|
|
8
|
+
constructor();
|
|
9
|
+
load(data?: RecursivePartial<ILight>): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { IOptionLoader, RecursivePartial } from "@tsparticles/engine";
|
|
2
|
+
import type { ILightArea } from "../Interfaces/ILightArea";
|
|
3
|
+
import { LightGradient } from "./LightGradient";
|
|
4
|
+
export declare class LightArea implements ILightArea, IOptionLoader<ILightArea> {
|
|
5
|
+
gradient: LightGradient;
|
|
6
|
+
radius: number;
|
|
7
|
+
constructor();
|
|
8
|
+
load(data?: RecursivePartial<ILightArea>): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { IOptionLoader, RecursivePartial } from "@tsparticles/engine";
|
|
2
|
+
import type { ILightGradient } from "../Interfaces/ILightGradient";
|
|
3
|
+
import { OptionsColor } from "@tsparticles/engine";
|
|
4
|
+
export declare class LightGradient implements ILightGradient, IOptionLoader<ILightGradient> {
|
|
5
|
+
start: OptionsColor;
|
|
6
|
+
stop: OptionsColor;
|
|
7
|
+
constructor();
|
|
8
|
+
load(data?: RecursivePartial<ILightGradient>): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Options, ParticlesOptions } from "@tsparticles/engine";
|
|
2
|
+
import type { LightMode } from "../../Types";
|
|
3
|
+
export type LightOptions = Options & {
|
|
4
|
+
interactivity: {
|
|
5
|
+
modes: LightMode;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
export type LightParticlesOptions = ParticlesOptions & {
|
|
9
|
+
interactivity: {
|
|
10
|
+
modes: LightMode;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { IOptionLoader, RecursivePartial } from "@tsparticles/engine";
|
|
2
|
+
import type { ILightShadow } from "../Interfaces/ILightShadow";
|
|
3
|
+
import { OptionsColor } from "@tsparticles/engine";
|
|
4
|
+
export declare class LightShadow implements ILightShadow, IOptionLoader<ILightShadow> {
|
|
5
|
+
color: OptionsColor;
|
|
6
|
+
length: number;
|
|
7
|
+
constructor();
|
|
8
|
+
load(data?: RecursivePartial<ILightShadow>): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ParticlesInteractorBase } from "@tsparticles/engine";
|
|
2
|
+
import type { LightContainer, LightParticle } from "./Types";
|
|
3
|
+
export declare class ParticlesLighter extends ParticlesInteractorBase<LightContainer> {
|
|
4
|
+
constructor(container: LightContainer);
|
|
5
|
+
clear(): void;
|
|
6
|
+
init(): void;
|
|
7
|
+
interact(particle: LightParticle): Promise<void>;
|
|
8
|
+
isEnabled(particle: LightParticle): boolean;
|
|
9
|
+
reset(): void;
|
|
10
|
+
}
|
package/types/Types.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Container, IRgb, Particle } from "@tsparticles/engine";
|
|
2
|
+
import type { LightOptions, LightParticlesOptions } from "./Options/Classes/LightOptions";
|
|
3
|
+
import type { ILight } from "./Options/Interfaces/ILight";
|
|
4
|
+
import type { Light } from "./Options/Classes/Light";
|
|
5
|
+
export type ILightMode = {
|
|
6
|
+
light?: ILight;
|
|
7
|
+
};
|
|
8
|
+
export type LightMode = {
|
|
9
|
+
light?: Light;
|
|
10
|
+
};
|
|
11
|
+
export type LightContainer = Container & {
|
|
12
|
+
actualOptions: LightOptions;
|
|
13
|
+
canvas: {
|
|
14
|
+
mouseLight?: {
|
|
15
|
+
start?: IRgb;
|
|
16
|
+
stop?: IRgb;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export type LightParticle = Particle & {
|
|
21
|
+
interactivity: {
|
|
22
|
+
modes: ILightMode;
|
|
23
|
+
};
|
|
24
|
+
lightShadow?: IRgb;
|
|
25
|
+
options: LightParticlesOptions;
|
|
26
|
+
};
|
package/types/Utils.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { LightContainer, LightParticle } from "./Types";
|
|
2
|
+
import type { ICoordinates } from "@tsparticles/engine";
|
|
3
|
+
export declare function drawLight(container: LightContainer, context: CanvasRenderingContext2D, mousePos: ICoordinates): void;
|
|
4
|
+
export declare function drawParticleShadow(container: LightContainer, context: CanvasRenderingContext2D, particle: LightParticle, mousePos: ICoordinates): void;
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Engine } from "@tsparticles/engine";
|
|
2
|
+
export declare function loadLightInteraction(engine: Engine): void;
|
|
3
|
+
export * from "./Options/Classes/Light";
|
|
4
|
+
export * from "./Options/Classes/LightArea";
|
|
5
|
+
export * from "./Options/Classes/LightGradient";
|
|
6
|
+
export * from "./Options/Classes/LightShadow";
|
|
7
|
+
export * from "./Options/Interfaces/ILight";
|
|
8
|
+
export * from "./Options/Interfaces/ILightArea";
|
|
9
|
+
export * from "./Options/Interfaces/ILightGradient";
|
|
10
|
+
export * from "./Options/Interfaces/ILightShadow";
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports", "@tsparticles/engine", "./Options/Classes/Light", "./Utils"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ExternalLighter = void 0;
|
|
13
|
+
const engine_1 = require("@tsparticles/engine");
|
|
14
|
+
const Light_1 = require("./Options/Classes/Light");
|
|
15
|
+
const Utils_1 = require("./Utils");
|
|
16
|
+
class ExternalLighter extends engine_1.ExternalInteractorBase {
|
|
17
|
+
constructor(container) {
|
|
18
|
+
super(container);
|
|
19
|
+
}
|
|
20
|
+
clear() {
|
|
21
|
+
}
|
|
22
|
+
init() {
|
|
23
|
+
}
|
|
24
|
+
async interact() {
|
|
25
|
+
const container = this.container, options = container.actualOptions;
|
|
26
|
+
if (options.interactivity.events.onHover.enable && container.interactivity.status === "pointermove") {
|
|
27
|
+
const mousePos = container.interactivity.mouse.position;
|
|
28
|
+
if (!mousePos) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
container.canvas.draw((ctx) => {
|
|
32
|
+
(0, Utils_1.drawLight)(container, ctx, mousePos);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
isEnabled(particle) {
|
|
37
|
+
var _a;
|
|
38
|
+
const container = this.container, mouse = container.interactivity.mouse, interactivity = (_a = particle === null || particle === void 0 ? void 0 : particle.interactivity) !== null && _a !== void 0 ? _a : container.actualOptions.interactivity, events = interactivity.events;
|
|
39
|
+
if (!(events.onHover.enable && mouse.position)) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
const res = (0, engine_1.isInArray)("light", events.onHover.mode);
|
|
43
|
+
if (res && interactivity.modes.light) {
|
|
44
|
+
const lightGradient = interactivity.modes.light.area.gradient;
|
|
45
|
+
container.canvas.mouseLight = {
|
|
46
|
+
start: (0, engine_1.rangeColorToRgb)(lightGradient.start),
|
|
47
|
+
stop: (0, engine_1.rangeColorToRgb)(lightGradient.stop),
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
return res;
|
|
51
|
+
}
|
|
52
|
+
loadModeOptions(options, ...sources) {
|
|
53
|
+
if (!options.light) {
|
|
54
|
+
options.light = new Light_1.Light();
|
|
55
|
+
}
|
|
56
|
+
for (const source of sources) {
|
|
57
|
+
options.light.load(source === null || source === void 0 ? void 0 : source.light);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
reset() {
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.ExternalLighter = ExternalLighter;
|
|
64
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports", "./LightArea", "./LightShadow"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Light = void 0;
|
|
13
|
+
const LightArea_1 = require("./LightArea");
|
|
14
|
+
const LightShadow_1 = require("./LightShadow");
|
|
15
|
+
class Light {
|
|
16
|
+
constructor() {
|
|
17
|
+
this.area = new LightArea_1.LightArea();
|
|
18
|
+
this.shadow = new LightShadow_1.LightShadow();
|
|
19
|
+
}
|
|
20
|
+
load(data) {
|
|
21
|
+
if (!data) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
this.area.load(data.area);
|
|
25
|
+
this.shadow.load(data.shadow);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.Light = Light;
|
|
29
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports", "./LightGradient"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.LightArea = void 0;
|
|
13
|
+
const LightGradient_1 = require("./LightGradient");
|
|
14
|
+
class LightArea {
|
|
15
|
+
constructor() {
|
|
16
|
+
this.gradient = new LightGradient_1.LightGradient();
|
|
17
|
+
this.radius = 1000;
|
|
18
|
+
}
|
|
19
|
+
load(data) {
|
|
20
|
+
if (!data) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
this.gradient.load(data.gradient);
|
|
24
|
+
if (data.radius !== undefined) {
|
|
25
|
+
this.radius = data.radius;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.LightArea = LightArea;
|
|
30
|
+
});
|