UNPKG

1.81 kBJavaScriptView Raw
1import { setRangeValue } from "tsparticles-engine";
2export class FireworkOptions {
3 constructor() {
4 this.brightness = {
5 min: -30,
6 max: 30,
7 };
8 this.colors = ["#ff595e", "#ffca3a", "#8ac926", "#1982c4", "#6a4c93"];
9 this.gravity = 5;
10 this.minHeight = {
11 min: 10,
12 max: 30,
13 };
14 this.rate = 20;
15 this.saturation = {
16 min: -30,
17 max: 30,
18 };
19 this.sounds = true;
20 this.speed = { min: 5, max: 15 };
21 this.splitCount = {
22 min: 75,
23 max: 150,
24 };
25 }
26 load(data) {
27 if (!data) {
28 return;
29 }
30 if (data.colors !== undefined) {
31 if (data.colors instanceof Array) {
32 this.colors = [...data.colors];
33 }
34 else {
35 this.colors = data.colors;
36 }
37 }
38 if (data.brightness !== undefined) {
39 this.brightness = setRangeValue(data.brightness);
40 }
41 if (data.gravity !== undefined) {
42 this.gravity = setRangeValue(data.gravity);
43 }
44 if (data.minHeight !== undefined) {
45 this.minHeight = setRangeValue(data.minHeight);
46 }
47 if (data.rate !== undefined) {
48 this.rate = setRangeValue(data.rate);
49 }
50 if (data.saturation !== undefined) {
51 this.saturation = setRangeValue(data.saturation);
52 }
53 if (data.sounds !== undefined) {
54 this.sounds = data.sounds;
55 }
56 if (data.speed !== undefined) {
57 this.speed = setRangeValue(data.speed);
58 }
59 if (data.splitCount !== undefined) {
60 this.splitCount = setRangeValue(data.splitCount);
61 }
62 }
63}