-
-
Notifications
You must be signed in to change notification settings - Fork 799
/
Effect.ts
54 lines (45 loc) · 1.52 KB
/
Effect.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import type { IEffect } from "../../../Interfaces/Particles/Effect/IEffect.js";
import type { IOptionLoader } from "../../../Interfaces/IOptionLoader.js";
import type { IShapeValues } from "../../../../Core/Interfaces/IShapeValues.js";
import type { RecursivePartial } from "../../../../Types/RecursivePartial.js";
import type { ShapeData } from "../../../../Types/ShapeData.js";
import type { SingleOrMultiple } from "../../../../Types/SingleOrMultiple.js";
import { deepExtend } from "../../../../Utils/Utils.js";
/**
* [[include:Options/Particles/Effect.md]]
*/
export class Effect implements IEffect, IOptionLoader<IEffect> {
close;
fill;
options: ShapeData;
type: SingleOrMultiple<string>;
constructor() {
this.close = true;
this.fill = true;
this.options = {};
this.type = [];
}
load(data?: RecursivePartial<IEffect>): void {
if (!data) {
return;
}
const options = data.options;
if (options !== undefined) {
for (const effect in options) {
const item = options[effect];
if (item) {
this.options[effect] = deepExtend(this.options[effect] ?? {}, item) as IShapeValues[];
}
}
}
if (data.close !== undefined) {
this.close = data.close;
}
if (data.fill !== undefined) {
this.fill = data.fill;
}
if (data.type !== undefined) {
this.type = data.type;
}
}
}