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.

54 lines (53 loc) 1.82 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Emitter = void 0; const Enums_1 = require("../../../../Enums"); const EmitterRate_1 = require("./EmitterRate"); const EmitterLife_1 = require("./EmitterLife"); const Utils_1 = require("../../../../Utils"); const EmitterSize_1 = require("./EmitterSize"); const AnimatableColor_1 = require("../../../../Options/Classes/Particles/AnimatableColor"); class Emitter { constructor() { this.autoPlay = true; this.direction = Enums_1.MoveDirection.none; this.life = new EmitterLife_1.EmitterLife(); this.rate = new EmitterRate_1.EmitterRate(); } load(data) { if (data === undefined) { return; } if (data.autoPlay !== undefined) { this.autoPlay = data.autoPlay; } if (data.size !== undefined) { if (this.size === undefined) { this.size = new EmitterSize_1.EmitterSize(); } this.size.load(data.size); } if (data.direction !== undefined) { this.direction = data.direction; } this.life.load(data.life); this.name = data.name; if (data.particles !== undefined) { this.particles = Utils_1.Utils.deepExtend({}, data.particles); } this.rate.load(data.rate); if (data.position !== undefined) { this.position = { x: data.position.x, y: data.position.y, }; } if (data.spawnColor !== undefined) { if (this.spawnColor === undefined) { this.spawnColor = new AnimatableColor_1.AnimatableColor(); } this.spawnColor.load(data.spawnColor); } } } exports.Emitter = Emitter;