UNPKG

@tsparticles/fireworks

Version:

tsParticles fireworks bundle — easily create spectacular fireworks and fountain particle effects with built-in presets. Ready to use components available for React, Vue.js (2.x and 3.x), Angular, Svelte, jQuery, Preact, Riot.js, Inferno.

94 lines (93 loc) 2.42 kB
import { isArray, isNull, loadProperty, loadRangeProperty, } from "@tsparticles/engine"; export class FireworkOptions { background; brightness; colors; gravity; minHeight; rate; saturation; sounds; speed; splitCount; constructor() { this.background = "none"; this.brightness = { min: -30, max: 30, }; this.colors = [ "#FF0000", "#FF2A00", "#FF5500", "#FF8000", "#FFAA00", "#FFD400", "#FFFF00", "#D4FF00", "#AAFF00", "#80FF00", "#55FF00", "#2AFF00", "#00FF00", "#00FF2A", "#00FF55", "#00FF80", "#00FFAA", "#00FFD4", "#00FFFF", "#00D4FF", "#00AAFF", "#0080FF", "#0055FF", "#002AFF", "#0000FF", "#2A00FF", "#5500FF", "#8000FF", "#AA00FF", "#D400FF", "#FF00FF", "#FF00D4", "#FF00AA", "#FF0080", "#FF0055", "#FF002A", ]; this.gravity = 30; this.minHeight = { min: 10, max: 30, }; this.rate = 10; this.saturation = { min: -30, max: 30, }; this.sounds = true; this.speed = { min: 20, max: 40 }; this.splitCount = 100; } load(data) { if (isNull(data)) { return; } if (data.colors !== undefined) { if (isArray(data.colors)) { this.colors = [...data.colors]; } else { this.colors = data.colors; } } loadProperty(this, "background", data.background); loadRangeProperty(this, "brightness", data.brightness); loadRangeProperty(this, "gravity", data.gravity); loadRangeProperty(this, "minHeight", data.minHeight); loadRangeProperty(this, "rate", data.rate); loadRangeProperty(this, "saturation", data.saturation); loadProperty(this, "sounds", data.sounds); loadRangeProperty(this, "speed", data.speed); loadRangeProperty(this, "splitCount", data.splitCount); } }