UNPKG

@tsparticles/editor

Version:

tsParticles Configuration Editor

45 lines (44 loc) 1.66 kB
import { EditorType } from "object-gui"; import { EditorBase } from "../../../../EditorBase"; export class ShadowOptionsEditor extends EditorBase { constructor(particles) { super(particles); } addToGroup(parent) { this.group = parent.addGroup("shadow", "Shadow"); this.options = this.group.data; this.addOffset(); this.addProperties(); } addOffset() { const group = this.group.addGroup("offset", "Offset"); group.addProperty("x", "X", EditorType.number).change(() => { void this.particles().refresh(); }); group.addProperty("y", "Y", EditorType.number).change(() => { void this.particles().refresh(); }); } addProperties() { const optionsFunc = () => this.options(); const options = optionsFunc(); const color = typeof options.color === "string" ? options.color : options.color?.value; this.group.addProperty("blur", "Blur", EditorType.number).change(() => { void this.particles().refresh(); }); this.group.addProperty("color", "Color", EditorType.color, color, false).change((value) => { if (typeof value === "string") { if (typeof options.color === "string") { options.color = value; } else { options.color.value = value; } } void this.particles().refresh(); }); this.group.addProperty("enable", "Enable", EditorType.boolean).change(() => { void this.particles().refresh(); }); } }