UNPKG

@tsparticles/editor

Version:

tsParticles Configuration Editor

46 lines (45 loc) 1.61 kB
import { EditorType } from "object-gui"; import { EditorBase } from "../../../EditorBase"; export class BackgroundOptionsEditor extends EditorBase { constructor(particles) { super(particles); } addToGroup(parent) { this.group = parent.addGroup("background", "Background"); this.options = this.group.data; this.addColor(); this.addProperties(); } addColor() { const options = this.options().color; this.group.addProperty("color", "Color", EditorType.color, options.value, false).change((value) => { const options = this.options().color; if (typeof value === "string") { options.value = value; } this.notifyEditorChanged(); }); } addProperties() { this.group.addProperty("image", "Image", EditorType.string).change(() => { void this.particles().refresh(); }); this.group .addProperty("opacity", "Opacity", EditorType.number) .change(() => { void this.particles().refresh(); }) .step(0.01) .min(0) .max(1); this.group.addProperty("position", "Position", EditorType.string).change(() => { void this.particles().refresh(); }); this.group.addProperty("repeat", "Repeat", EditorType.string).change(() => { void this.particles().refresh(); }); this.group.addProperty("size", "Size", EditorType.string).change(() => { void this.particles().refresh(); }); } }