@tsparticles/updater-twinkle 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 +70 -0
- package/browser/Options/Classes/Twinkle.js +14 -0
- package/browser/Options/Classes/TwinkleValues.js +25 -0
- package/browser/Options/Interfaces/ITwinkle.js +1 -0
- package/browser/Options/Interfaces/ITwinkleValues.js +1 -0
- package/browser/TwinkleUpdater.js +33 -0
- package/browser/index.js +4 -0
- package/cjs/Options/Classes/Twinkle.js +18 -0
- package/cjs/Options/Classes/TwinkleValues.js +29 -0
- package/cjs/Options/Interfaces/ITwinkle.js +2 -0
- package/cjs/Options/Interfaces/ITwinkleValues.js +2 -0
- package/cjs/TwinkleUpdater.js +37 -0
- package/cjs/index.js +19 -0
- package/esm/Options/Classes/Twinkle.js +14 -0
- package/esm/Options/Classes/TwinkleValues.js +25 -0
- package/esm/Options/Interfaces/ITwinkle.js +1 -0
- package/esm/Options/Interfaces/ITwinkleValues.js +1 -0
- package/esm/TwinkleUpdater.js +33 -0
- package/esm/index.js +4 -0
- package/package.json +82 -0
- package/report.html +39 -0
- package/tsparticles.updater.twinkle.js +192 -0
- package/tsparticles.updater.twinkle.min.js +2 -0
- package/tsparticles.updater.twinkle.min.js.LICENSE.txt +8 -0
- package/types/Options/Classes/Twinkle.d.ts +9 -0
- package/types/Options/Classes/TwinkleValues.d.ts +11 -0
- package/types/Options/Interfaces/ITwinkle.d.ts +5 -0
- package/types/Options/Interfaces/ITwinkleValues.d.ts +7 -0
- package/types/TwinkleUpdater.d.ts +20 -0
- package/types/index.d.ts +2 -0
- package/umd/Options/Classes/Twinkle.js +28 -0
- package/umd/Options/Classes/TwinkleValues.js +39 -0
- package/umd/Options/Interfaces/ITwinkle.js +12 -0
- package/umd/Options/Interfaces/ITwinkleValues.js +12 -0
- package/umd/TwinkleUpdater.js +47 -0
- package/umd/index.js +18 -0
|
@@ -0,0 +1,192 @@
|
|
|
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
|
+
"loadTwinkleUpdater": () => (/* binding */ loadTwinkleUpdater)
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
// EXTERNAL MODULE: external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"}
|
|
98
|
+
var engine_root_window_ = __webpack_require__(533);
|
|
99
|
+
;// CONCATENATED MODULE: ./dist/browser/Options/Classes/TwinkleValues.js
|
|
100
|
+
|
|
101
|
+
class TwinkleValues {
|
|
102
|
+
constructor() {
|
|
103
|
+
this.enable = false;
|
|
104
|
+
this.frequency = 0.05;
|
|
105
|
+
this.opacity = 1;
|
|
106
|
+
}
|
|
107
|
+
load(data) {
|
|
108
|
+
if (!data) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
if (data.color !== undefined) {
|
|
112
|
+
this.color = engine_root_window_.OptionsColor.create(this.color, data.color);
|
|
113
|
+
}
|
|
114
|
+
if (data.enable !== undefined) {
|
|
115
|
+
this.enable = data.enable;
|
|
116
|
+
}
|
|
117
|
+
if (data.frequency !== undefined) {
|
|
118
|
+
this.frequency = data.frequency;
|
|
119
|
+
}
|
|
120
|
+
if (data.opacity !== undefined) {
|
|
121
|
+
this.opacity = (0,engine_root_window_.setRangeValue)(data.opacity);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Twinkle.js
|
|
126
|
+
|
|
127
|
+
class Twinkle {
|
|
128
|
+
constructor() {
|
|
129
|
+
this.lines = new TwinkleValues();
|
|
130
|
+
this.particles = new TwinkleValues();
|
|
131
|
+
}
|
|
132
|
+
load(data) {
|
|
133
|
+
if (!data) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
this.lines.load(data.lines);
|
|
137
|
+
this.particles.load(data.particles);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
;// CONCATENATED MODULE: ./dist/browser/TwinkleUpdater.js
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
class TwinkleUpdater {
|
|
144
|
+
getColorStyles(particle, context, radius, opacity) {
|
|
145
|
+
const pOptions = particle.options,
|
|
146
|
+
twinkleOptions = pOptions.twinkle;
|
|
147
|
+
if (!twinkleOptions) {
|
|
148
|
+
return {};
|
|
149
|
+
}
|
|
150
|
+
const twinkle = twinkleOptions.particles,
|
|
151
|
+
twinkling = twinkle.enable && (0,engine_root_window_.getRandom)() < twinkle.frequency,
|
|
152
|
+
zIndexOptions = particle.options.zIndex,
|
|
153
|
+
zOpacityFactor = (1 - particle.zIndexFactor) ** zIndexOptions.opacityRate,
|
|
154
|
+
twinklingOpacity = twinkling ? (0,engine_root_window_.getRangeValue)(twinkle.opacity) * zOpacityFactor : opacity,
|
|
155
|
+
twinkleRgb = (0,engine_root_window_.rangeColorToHsl)(twinkle.color),
|
|
156
|
+
twinkleStyle = twinkleRgb ? (0,engine_root_window_.getStyleFromHsl)(twinkleRgb, twinklingOpacity) : undefined,
|
|
157
|
+
res = {},
|
|
158
|
+
needsTwinkle = twinkling && twinkleStyle;
|
|
159
|
+
res.fill = needsTwinkle ? twinkleStyle : undefined;
|
|
160
|
+
res.stroke = needsTwinkle ? twinkleStyle : undefined;
|
|
161
|
+
return res;
|
|
162
|
+
}
|
|
163
|
+
init() {}
|
|
164
|
+
isEnabled(particle) {
|
|
165
|
+
const pOptions = particle.options,
|
|
166
|
+
twinkleOptions = pOptions.twinkle;
|
|
167
|
+
if (!twinkleOptions) {
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
return twinkleOptions.particles.enable;
|
|
171
|
+
}
|
|
172
|
+
loadOptions(options, ...sources) {
|
|
173
|
+
if (!options.twinkle) {
|
|
174
|
+
options.twinkle = new Twinkle();
|
|
175
|
+
}
|
|
176
|
+
for (const source of sources) {
|
|
177
|
+
options.twinkle.load(source === null || source === void 0 ? void 0 : source.twinkle);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
update() {}
|
|
181
|
+
}
|
|
182
|
+
;// CONCATENATED MODULE: ./dist/browser/index.js
|
|
183
|
+
|
|
184
|
+
async function loadTwinkleUpdater(engine) {
|
|
185
|
+
await engine.addParticleUpdater("twinkle", () => new TwinkleUpdater());
|
|
186
|
+
}
|
|
187
|
+
})();
|
|
188
|
+
|
|
189
|
+
/******/ return __webpack_exports__;
|
|
190
|
+
/******/ })()
|
|
191
|
+
;
|
|
192
|
+
});
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see tsparticles.updater.twinkle.min.js.LICENSE.txt */
|
|
2
|
+
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],t);else{var o="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var r in o)("object"==typeof exports?exports:e)[r]=o[r]}}(this,(e=>(()=>{"use strict";var t={533:t=>{t.exports=e}},o={};function r(e){var i=o[e];if(void 0!==i)return i.exports;var n=o[e]={exports:{}};return t[e](n,n.exports,r),n.exports}r.d=(e,t)=>{for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};return(()=>{r.r(i),r.d(i,{loadTwinkleUpdater:()=>l});var e=r(533);class t{constructor(){this.enable=!1,this.frequency=.05,this.opacity=1}load(t){t&&(void 0!==t.color&&(this.color=e.OptionsColor.create(this.color,t.color)),void 0!==t.enable&&(this.enable=t.enable),void 0!==t.frequency&&(this.frequency=t.frequency),void 0!==t.opacity&&(this.opacity=(0,e.setRangeValue)(t.opacity)))}}class o{constructor(){this.lines=new t,this.particles=new t}load(e){e&&(this.lines.load(e.lines),this.particles.load(e.particles))}}class n{getColorStyles(t,o,r,i){const n=t.options.twinkle;if(!n)return{};const l=n.particles,s=l.enable&&(0,e.getRandom)()<l.frequency,a=t.options.zIndex,c=(1-t.zIndexFactor)**a.opacityRate,p=s?(0,e.getRangeValue)(l.opacity)*c:i,d=(0,e.rangeColorToHsl)(l.color),u=d?(0,e.getStyleFromHsl)(d,p):void 0,f={},y=s&&u;return f.fill=y?u:void 0,f.stroke=y?u:void 0,f}init(){}isEnabled(e){const t=e.options.twinkle;return!!t&&t.particles.enable}loadOptions(e,...t){e.twinkle||(e.twinkle=new o);for(const o of t)e.twinkle.load(null==o?void 0:o.twinkle)}update(){}}async function l(e){await e.addParticleUpdater("twinkle",(()=>new n))}})(),i})()));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { IOptionLoader, RecursivePartial } from "@tsparticles/engine";
|
|
2
|
+
import type { ITwinkle } from "../Interfaces/ITwinkle";
|
|
3
|
+
import { TwinkleValues } from "./TwinkleValues";
|
|
4
|
+
export declare class Twinkle implements ITwinkle, IOptionLoader<ITwinkle> {
|
|
5
|
+
lines: TwinkleValues;
|
|
6
|
+
particles: TwinkleValues;
|
|
7
|
+
constructor();
|
|
8
|
+
load(data?: RecursivePartial<ITwinkle>): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { IOptionLoader, RangeValue, RecursivePartial } from "@tsparticles/engine";
|
|
2
|
+
import { OptionsColor } from "@tsparticles/engine";
|
|
3
|
+
import type { ITwinkleValues } from "../Interfaces/ITwinkleValues";
|
|
4
|
+
export declare class TwinkleValues implements ITwinkleValues, IOptionLoader<ITwinkleValues> {
|
|
5
|
+
color?: OptionsColor;
|
|
6
|
+
enable: boolean;
|
|
7
|
+
frequency: number;
|
|
8
|
+
opacity: RangeValue;
|
|
9
|
+
constructor();
|
|
10
|
+
load(data?: RecursivePartial<ITwinkleValues>): void;
|
|
11
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { IParticleColorStyle, IParticleUpdater, IParticlesOptions, Particle, ParticlesOptions, RecursivePartial } from "@tsparticles/engine";
|
|
2
|
+
import type { ITwinkle } from "./Options/Interfaces/ITwinkle";
|
|
3
|
+
import { Twinkle } from "./Options/Classes/Twinkle";
|
|
4
|
+
type TwinkeParticle = Particle & {
|
|
5
|
+
options: TwinkleParticlesOptions;
|
|
6
|
+
};
|
|
7
|
+
type ITwinkleParticlesOptions = IParticlesOptions & {
|
|
8
|
+
twinkle?: ITwinkle;
|
|
9
|
+
};
|
|
10
|
+
type TwinkleParticlesOptions = ParticlesOptions & {
|
|
11
|
+
twinkle?: Twinkle;
|
|
12
|
+
};
|
|
13
|
+
export declare class TwinkleUpdater implements IParticleUpdater {
|
|
14
|
+
getColorStyles(particle: Particle, context: CanvasRenderingContext2D, radius: number, opacity: number): IParticleColorStyle;
|
|
15
|
+
init(): void;
|
|
16
|
+
isEnabled(particle: TwinkeParticle): boolean;
|
|
17
|
+
loadOptions(options: TwinkleParticlesOptions, ...sources: (RecursivePartial<ITwinkleParticlesOptions> | undefined)[]): void;
|
|
18
|
+
update(): void;
|
|
19
|
+
}
|
|
20
|
+
export {};
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
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", "./TwinkleValues"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Twinkle = void 0;
|
|
13
|
+
const TwinkleValues_1 = require("./TwinkleValues");
|
|
14
|
+
class Twinkle {
|
|
15
|
+
constructor() {
|
|
16
|
+
this.lines = new TwinkleValues_1.TwinkleValues();
|
|
17
|
+
this.particles = new TwinkleValues_1.TwinkleValues();
|
|
18
|
+
}
|
|
19
|
+
load(data) {
|
|
20
|
+
if (!data) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
this.lines.load(data.lines);
|
|
24
|
+
this.particles.load(data.particles);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.Twinkle = Twinkle;
|
|
28
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
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"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.TwinkleValues = void 0;
|
|
13
|
+
const engine_1 = require("@tsparticles/engine");
|
|
14
|
+
class TwinkleValues {
|
|
15
|
+
constructor() {
|
|
16
|
+
this.enable = false;
|
|
17
|
+
this.frequency = 0.05;
|
|
18
|
+
this.opacity = 1;
|
|
19
|
+
}
|
|
20
|
+
load(data) {
|
|
21
|
+
if (!data) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (data.color !== undefined) {
|
|
25
|
+
this.color = engine_1.OptionsColor.create(this.color, data.color);
|
|
26
|
+
}
|
|
27
|
+
if (data.enable !== undefined) {
|
|
28
|
+
this.enable = data.enable;
|
|
29
|
+
}
|
|
30
|
+
if (data.frequency !== undefined) {
|
|
31
|
+
this.frequency = data.frequency;
|
|
32
|
+
}
|
|
33
|
+
if (data.opacity !== undefined) {
|
|
34
|
+
this.opacity = (0, engine_1.setRangeValue)(data.opacity);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.TwinkleValues = TwinkleValues;
|
|
39
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
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"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
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"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
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/Twinkle"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.TwinkleUpdater = void 0;
|
|
13
|
+
const engine_1 = require("@tsparticles/engine");
|
|
14
|
+
const Twinkle_1 = require("./Options/Classes/Twinkle");
|
|
15
|
+
class TwinkleUpdater {
|
|
16
|
+
getColorStyles(particle, context, radius, opacity) {
|
|
17
|
+
const pOptions = particle.options, twinkleOptions = pOptions.twinkle;
|
|
18
|
+
if (!twinkleOptions) {
|
|
19
|
+
return {};
|
|
20
|
+
}
|
|
21
|
+
const twinkle = twinkleOptions.particles, twinkling = twinkle.enable && (0, engine_1.getRandom)() < twinkle.frequency, zIndexOptions = particle.options.zIndex, zOpacityFactor = (1 - particle.zIndexFactor) ** zIndexOptions.opacityRate, twinklingOpacity = twinkling ? (0, engine_1.getRangeValue)(twinkle.opacity) * zOpacityFactor : opacity, twinkleRgb = (0, engine_1.rangeColorToHsl)(twinkle.color), twinkleStyle = twinkleRgb ? (0, engine_1.getStyleFromHsl)(twinkleRgb, twinklingOpacity) : undefined, res = {}, needsTwinkle = twinkling && twinkleStyle;
|
|
22
|
+
res.fill = needsTwinkle ? twinkleStyle : undefined;
|
|
23
|
+
res.stroke = needsTwinkle ? twinkleStyle : undefined;
|
|
24
|
+
return res;
|
|
25
|
+
}
|
|
26
|
+
init() {
|
|
27
|
+
}
|
|
28
|
+
isEnabled(particle) {
|
|
29
|
+
const pOptions = particle.options, twinkleOptions = pOptions.twinkle;
|
|
30
|
+
if (!twinkleOptions) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
return twinkleOptions.particles.enable;
|
|
34
|
+
}
|
|
35
|
+
loadOptions(options, ...sources) {
|
|
36
|
+
if (!options.twinkle) {
|
|
37
|
+
options.twinkle = new Twinkle_1.Twinkle();
|
|
38
|
+
}
|
|
39
|
+
for (const source of sources) {
|
|
40
|
+
options.twinkle.load(source === null || source === void 0 ? void 0 : source.twinkle);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
update() {
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.TwinkleUpdater = TwinkleUpdater;
|
|
47
|
+
});
|
package/umd/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
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", "./TwinkleUpdater"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.loadTwinkleUpdater = void 0;
|
|
13
|
+
const TwinkleUpdater_1 = require("./TwinkleUpdater");
|
|
14
|
+
async function loadTwinkleUpdater(engine) {
|
|
15
|
+
await engine.addParticleUpdater("twinkle", () => new TwinkleUpdater_1.TwinkleUpdater());
|
|
16
|
+
}
|
|
17
|
+
exports.loadTwinkleUpdater = loadTwinkleUpdater;
|
|
18
|
+
});
|