2023-02-17 11:06:01 +01:00

243 lines
8.8 KiB
JavaScript

/*!
* Author : Matteo Bruni
* MIT license: https://opensource.org/licenses/MIT
* Demo / Generator : https://particles.js.org/
* GitHub : https://www.github.com/matteobruni/tsparticles
* How to use? : Check the GitHub README
* v2.8.0
*/
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory(require("tsparticles-engine"));
else if(typeof define === 'function' && define.amd)
define(["tsparticles-engine"], factory);
else {
var a = typeof exports === 'object' ? factory(require("tsparticles-engine")) : factory(root["window"]);
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
}
})(this, (__WEBPACK_EXTERNAL_MODULE__961__) => {
return /******/ (() => { // webpackBootstrap
/******/ "use strict";
/******/ var __webpack_modules__ = ({
/***/ 961:
/***/ ((module) => {
module.exports = __WEBPACK_EXTERNAL_MODULE__961__;
/***/ })
/******/ });
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ var cachedModule = __webpack_module_cache__[moduleId];
/******/ if (cachedModule !== undefined) {
/******/ return cachedModule.exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = __webpack_module_cache__[moduleId] = {
/******/ // no module.id needed
/******/ // no module.loaded needed
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/************************************************************************/
/******/ /* webpack/runtime/define property getters */
/******/ (() => {
/******/ // define getter functions for harmony exports
/******/ __webpack_require__.d = (exports, definition) => {
/******/ for(var key in definition) {
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ }
/******/ }
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
/******/ (() => {
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
/******/ })();
/******/
/******/ /* webpack/runtime/make namespace object */
/******/ (() => {
/******/ // define __esModule on exports
/******/ __webpack_require__.r = (exports) => {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/ })();
/******/
/************************************************************************/
var __webpack_exports__ = {};
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
(() => {
// ESM COMPAT FLAG
__webpack_require__.r(__webpack_exports__);
// EXPORTS
__webpack_require__.d(__webpack_exports__, {
"loadRollUpdater": () => (/* binding */ loadRollUpdater)
});
// EXTERNAL MODULE: external {"commonjs":"tsparticles-engine","commonjs2":"tsparticles-engine","amd":"tsparticles-engine","root":"window"}
var external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_ = __webpack_require__(961);
;// CONCATENATED MODULE: ./dist/browser/Options/Classes/RollLight.js
class RollLight {
constructor() {
this.enable = false;
this.value = 0;
}
load(data) {
if (!data) {
return;
}
if (data.enable !== undefined) {
this.enable = data.enable;
}
if (data.value !== undefined) {
this.value = (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.setRangeValue)(data.value);
}
}
}
;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Roll.js
class Roll {
constructor() {
this.darken = new RollLight();
this.enable = false;
this.enlighten = new RollLight();
this.mode = "vertical";
this.speed = 25;
}
load(data) {
if (!data) {
return;
}
if (data.backColor !== undefined) {
this.backColor = external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.OptionsColor.create(this.backColor, data.backColor);
}
this.darken.load(data.darken);
if (data.enable !== undefined) {
this.enable = data.enable;
}
this.enlighten.load(data.enlighten);
if (data.mode !== undefined) {
this.mode = data.mode;
}
if (data.speed !== undefined) {
this.speed = (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.setRangeValue)(data.speed);
}
}
}
;// CONCATENATED MODULE: ./dist/browser/RollUpdater.js
function updateRoll(particle, delta) {
const roll = particle.options.roll;
if (!particle.roll || !(roll === null || roll === void 0 ? void 0 : roll.enable)) {
return;
}
const speed = particle.roll.speed * delta.factor,
max = 2 * Math.PI;
particle.roll.angle += speed;
if (particle.roll.angle > max) {
particle.roll.angle -= max;
}
}
class RollUpdater {
getTransformValues(particle) {
var _a;
const roll = ((_a = particle.roll) === null || _a === void 0 ? void 0 : _a.enable) && particle.roll,
rollHorizontal = roll && roll.horizontal,
rollVertical = roll && roll.vertical;
return {
a: rollHorizontal ? Math.cos(roll.angle) : undefined,
d: rollVertical ? Math.sin(roll.angle) : undefined
};
}
init(particle) {
const rollOpt = particle.options.roll;
if (rollOpt === null || rollOpt === void 0 ? void 0 : rollOpt.enable) {
particle.roll = {
enable: rollOpt.enable,
horizontal: rollOpt.mode === "horizontal" || rollOpt.mode === "both",
vertical: rollOpt.mode === "vertical" || rollOpt.mode === "both",
angle: (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.getRandom)() * Math.PI * 2,
speed: (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.getRangeValue)(rollOpt.speed) / 360
};
if (rollOpt.backColor) {
particle.backColor = (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.rangeColorToHsl)(rollOpt.backColor);
} else if (rollOpt.darken.enable && rollOpt.enlighten.enable) {
const alterType = (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.getRandom)() >= 0.5 ? "darken" : "enlighten";
particle.roll.alter = {
type: alterType,
value: (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.getRangeValue)(alterType === "darken" ? rollOpt.darken.value : rollOpt.enlighten.value)
};
} else if (rollOpt.darken.enable) {
particle.roll.alter = {
type: "darken",
value: (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.getRangeValue)(rollOpt.darken.value)
};
} else if (rollOpt.enlighten.enable) {
particle.roll.alter = {
type: "enlighten",
value: (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.getRangeValue)(rollOpt.enlighten.value)
};
}
} else {
particle.roll = {
enable: false,
horizontal: false,
vertical: false,
angle: 0,
speed: 0
};
}
}
isEnabled(particle) {
const roll = particle.options.roll;
return !particle.destroyed && !particle.spawning && !!(roll === null || roll === void 0 ? void 0 : roll.enable);
}
loadOptions(options, ...sources) {
if (!options.roll) {
options.roll = new Roll();
}
for (const source of sources) {
options.roll.load(source === null || source === void 0 ? void 0 : source.roll);
}
}
update(particle, delta) {
if (!this.isEnabled(particle)) {
return;
}
updateRoll(particle, delta);
}
}
;// CONCATENATED MODULE: ./dist/browser/index.js
async function loadRollUpdater(engine) {
await engine.addParticleUpdater("roll", () => new RollUpdater());
}
})();
/******/ return __webpack_exports__;
/******/ })()
;
});