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