UNPKG

@tsparticles/editor

Version:

tsParticles Configuration Editor

94 lines (93 loc) 3.94 kB
(function (factory) { if (typeof module === "object" && typeof module.exports === "object") { var v = factory(require, exports); if (v !== undefined) module.exports = v; } else if (typeof define === "function" && define.amd) { define(["require", "exports", "object-gui", "../../../../EditorBase"], factory); } })(function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RollOptionsEditor = void 0; const object_gui_1 = require("object-gui"); const EditorBase_1 = require("../../../../EditorBase"); class RollOptionsEditor extends EditorBase_1.EditorBase { constructor(particles) { super(particles); } addToGroup(parent) { this.group = parent.addGroup("roll", "Roll"); this.options = this.group.data; this.addDarken(); this.addEnlighten(); this.addProperties(); } addDarken() { const group = this.group.addGroup("darken", "Darken"); group.addProperty("enable", "Enable", object_gui_1.EditorType.boolean).change(() => { void this.particles().refresh(); }); group.addProperty("value", "Value", object_gui_1.EditorType.number).change(() => { void this.particles().refresh(); }); } addEnlighten() { const group = this.group.addGroup("enlighten", "Enlighten"); group.addProperty("enable", "Enable", object_gui_1.EditorType.boolean).change(() => { void this.particles().refresh(); }); group.addProperty("value", "Value", object_gui_1.EditorType.number).change(() => { void this.particles().refresh(); }); } addProperties() { const optionsFunc = this.options, options = optionsFunc(), getColor = () => { if (typeof options.backColor === "string") { return options.backColor; } else { if (options.backColor instanceof Array) { return options.backColor[0]; } else { return options.backColor?.value; } } }, color = getColor(); this.group.addProperty("backColor", "Back Color", object_gui_1.EditorType.color, color, false).change((value) => { const options = optionsFunc(); if (typeof value === "string") { if (typeof options.backColor === "string") { options.backColor = value; } else { if (options.backColor === undefined) { options.backColor = { value: value, }; } else { if (options.backColor instanceof Array) { options.backColor = { value: value, }; } else { options.backColor.value = value; } } } } void this.particles().refresh(); }); this.group.addProperty("enable", "Enable", object_gui_1.EditorType.boolean).change(() => { void this.particles().refresh(); }); this.group.addProperty("speed", "Speed", object_gui_1.EditorType.number).change(() => { void this.particles().refresh(); }); } } exports.RollOptionsEditor = RollOptionsEditor; });