UNPKG

tsparticles

Version:

Easily create highly customizable particle 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.

99 lines (98 loc) 3.84 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ParticlesOptions = void 0; const Links_1 = require("./Links/Links"); const Move_1 = require("./Move/Move"); const ParticlesNumber_1 = require("./Number/ParticlesNumber"); const Opacity_1 = require("./Opacity/Opacity"); const Shape_1 = require("./Shape/Shape"); const Size_1 = require("./Size/Size"); const Rotate_1 = require("./Rotate/Rotate"); const Shadow_1 = require("./Shadow"); const Stroke_1 = require("./Stroke"); const Collisions_1 = require("./Collisions/Collisions"); const Twinkle_1 = require("./Twinkle/Twinkle"); const AnimatableColor_1 = require("./AnimatableColor"); const Life_1 = require("./Life/Life"); const Bounce_1 = require("./Bounce/Bounce"); const Destroy_1 = require("./Destroy/Destroy"); class ParticlesOptions { constructor() { this.bounce = new Bounce_1.Bounce(); this.collisions = new Collisions_1.Collisions(); this.color = new AnimatableColor_1.AnimatableColor(); this.destroy = new Destroy_1.Destroy(); this.life = new Life_1.Life(); this.links = new Links_1.Links(); this.move = new Move_1.Move(); this.number = new ParticlesNumber_1.ParticlesNumber(); this.opacity = new Opacity_1.Opacity(); this.reduceDuplicates = false; this.rotate = new Rotate_1.Rotate(); this.shadow = new Shadow_1.Shadow(); this.shape = new Shape_1.Shape(); this.size = new Size_1.Size(); this.stroke = new Stroke_1.Stroke(); this.twinkle = new Twinkle_1.Twinkle(); } get line_linked() { return this.links; } set line_linked(value) { this.links = value; } get lineLinked() { return this.links; } set lineLinked(value) { this.links = value; } load(data) { var _a, _b, _c, _d, _e, _f, _g; if (data === undefined) { return; } this.bounce.load(data.bounce); this.color = AnimatableColor_1.AnimatableColor.create(this.color, data.color); this.destroy.load(data.destroy); this.life.load(data.life); const links = (_b = (_a = data.links) !== null && _a !== void 0 ? _a : data.lineLinked) !== null && _b !== void 0 ? _b : data.line_linked; if (links !== undefined) { this.links.load(links); } this.move.load(data.move); this.number.load(data.number); this.opacity.load(data.opacity); if (data.reduceDuplicates !== undefined) { this.reduceDuplicates = data.reduceDuplicates; } this.rotate.load(data.rotate); this.shape.load(data.shape); this.size.load(data.size); this.shadow.load(data.shadow); this.twinkle.load(data.twinkle); const collisions = (_d = (_c = data.move) === null || _c === void 0 ? void 0 : _c.collisions) !== null && _d !== void 0 ? _d : (_e = data.move) === null || _e === void 0 ? void 0 : _e.bounce; if (collisions !== undefined) { this.collisions.enable = collisions; } this.collisions.load(data.collisions); const strokeToLoad = (_f = data.stroke) !== null && _f !== void 0 ? _f : (_g = data.shape) === null || _g === void 0 ? void 0 : _g.stroke; if (strokeToLoad === undefined) { return; } if (strokeToLoad instanceof Array) { this.stroke = strokeToLoad.map((s) => { const tmp = new Stroke_1.Stroke(); tmp.load(s); return tmp; }); } else { if (this.stroke instanceof Array) { this.stroke = new Stroke_1.Stroke(); } this.stroke.load(strokeToLoad); } } } exports.ParticlesOptions = ParticlesOptions;