@tsparticles/editor
Version:
tsParticles Configuration Editor
60 lines (59 loc) • 2.46 kB
JavaScript
(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.BackgroundOptionsEditor = void 0;
const object_gui_1 = require("object-gui");
const EditorBase_1 = require("../../../EditorBase");
class BackgroundOptionsEditor extends EditorBase_1.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", object_gui_1.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", object_gui_1.EditorType.string).change(() => {
void this.particles().refresh();
});
this.group
.addProperty("opacity", "Opacity", object_gui_1.EditorType.number)
.change(() => {
void this.particles().refresh();
})
.step(0.01)
.min(0)
.max(1);
this.group.addProperty("position", "Position", object_gui_1.EditorType.string).change(() => {
void this.particles().refresh();
});
this.group.addProperty("repeat", "Repeat", object_gui_1.EditorType.string).change(() => {
void this.particles().refresh();
});
this.group.addProperty("size", "Size", object_gui_1.EditorType.string).change(() => {
void this.particles().refresh();
});
}
}
exports.BackgroundOptionsEditor = BackgroundOptionsEditor;
});