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

190 lines
6.4 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__, {
"loadGenericPolygonShape": () => (/* binding */ loadGenericPolygonShape),
"loadPolygonShape": () => (/* binding */ loadPolygonShape),
"loadTriangleShape": () => (/* binding */ loadTriangleShape)
});
// 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/PolygonDrawerBase.js
class PolygonDrawerBase {
draw(context, particle, radius) {
const start = this.getCenter(particle, radius),
side = this.getSidesData(particle, radius),
sideCount = side.count.numerator * side.count.denominator,
decimalSides = side.count.numerator / side.count.denominator,
interiorAngleDegrees = 180 * (decimalSides - 2) / decimalSides,
interiorAngle = Math.PI - Math.PI * interiorAngleDegrees / 180;
if (!context) {
return;
}
context.beginPath();
context.translate(start.x, start.y);
context.moveTo(0, 0);
for (let i = 0; i < sideCount; i++) {
context.lineTo(side.length, 0);
context.translate(side.length, 0);
context.rotate(interiorAngle);
}
}
getSidesCount(particle) {
var _a, _b;
const polygon = particle.shapeData,
sides = Math.round((0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.getRangeValue)((_b = (_a = polygon === null || polygon === void 0 ? void 0 : polygon.sides) !== null && _a !== void 0 ? _a : polygon === null || polygon === void 0 ? void 0 : polygon.nb_sides) !== null && _b !== void 0 ? _b : 5));
return sides;
}
}
;// CONCATENATED MODULE: ./dist/browser/PolygonDrawer.js
class PolygonDrawer extends PolygonDrawerBase {
getCenter(particle, radius) {
return {
x: -radius / (particle.sides / 3.5),
y: -radius / (2.66 / 3.5)
};
}
getSidesData(particle, radius) {
const sides = particle.sides;
return {
count: {
denominator: 1,
numerator: sides
},
length: radius * 2.66 / (sides / 3)
};
}
}
;// CONCATENATED MODULE: ./dist/browser/TriangleDrawer.js
class TriangleDrawer extends PolygonDrawerBase {
getCenter(particle, radius) {
return {
x: -radius,
y: radius / 1.66
};
}
getSidesCount() {
return 3;
}
getSidesData(particle, radius) {
return {
count: {
denominator: 2,
numerator: 3
},
length: radius * 2
};
}
}
;// CONCATENATED MODULE: ./dist/browser/index.js
async function loadGenericPolygonShape(engine) {
await engine.addShape("polygon", new PolygonDrawer());
}
async function loadTriangleShape(engine) {
await engine.addShape("triangle", new TriangleDrawer());
}
async function loadPolygonShape(engine) {
await loadGenericPolygonShape(engine);
await loadTriangleShape(engine);
}
})();
/******/ return __webpack_exports__;
/******/ })()
;
});