UNPKG

tsparticles

Version:

Easily create highly customizable particle, confetti and fireworks animations and use them as animated backgrounds for your website. Ready to use components available also for React, Vue.js (2.x and 3.x), Angular, Svelte, jQuery, Preact, Riot.js, Inferno.

71 lines 2.58 kB
(function webpackUniversalModuleDefinition(root, factory) { if (typeof exports === "object" && typeof module === "object") module.exports = factory(); else if (typeof define === "function" && define.amd) define([], factory); else { var a = factory(); for (var i in a) (typeof exports === "object" ? exports : root)[i] = a[i]; } })(window, (function() { return function() { "use strict"; var __webpack_require__ = {}; !function() { __webpack_require__.d = function(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] }); } } }; }(); !function() { __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }; }(); !function() { __webpack_require__.r = function(exports) { if (typeof Symbol !== "undefined" && Symbol.toStringTag) { Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); } Object.defineProperty(exports, "__esModule", { value: true }); }; }(); var __webpack_exports__ = {}; __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { loadStarShape: function() { return loadStarShape; } }); class StarDrawer { getSidesCount(particle) { var _a, _b; const star = particle.shapeData; return (_b = (_a = star === null || star === void 0 ? void 0 : star.sides) !== null && _a !== void 0 ? _a : star === null || star === void 0 ? void 0 : star.nb_sides) !== null && _b !== void 0 ? _b : 5; } draw(context, particle, radius) { var _a; const star = particle.shapeData; const sides = this.getSidesCount(particle); const inset = (_a = star === null || star === void 0 ? void 0 : star.inset) !== null && _a !== void 0 ? _a : 2; context.moveTo(0, 0 - radius); for (let i = 0; i < sides; i++) { context.rotate(Math.PI / sides); context.lineTo(0, 0 - radius * inset); context.rotate(Math.PI / sides); context.lineTo(0, 0 - radius); } } } async function loadStarShape(engine) { await engine.addShape("star", new StarDrawer); } return __webpack_exports__; }(); }));