@tsparticles/editor
Version:
tsParticles Configuration Editor
64 lines (63 loc) • 2.63 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.TwinkleOptionsEditor = void 0;
const object_gui_1 = require("object-gui");
const EditorBase_1 = require("../../../../EditorBase");
class TwinkleOptionsEditor extends EditorBase_1.EditorBase {
constructor(particles) {
super(particles);
}
addToGroup(parent, options) {
this.group = parent.addGroup("twinkle", "Twinkle", true, options);
this.options = this.group.data;
this.addTwinkle();
}
addTwinkle() {
this.addTwinkleValues(this.group.addGroup("lines", "Lines"));
this.addTwinkleValues(this.group.addGroup("particles", "Particles"));
}
addTwinkleValues(group) {
const optionsFunc = () => group.data();
const options = optionsFunc();
const color = typeof options.color === "string" ? options.color : options.color?.value;
group.addProperty("color", "Color", object_gui_1.EditorType.color, color, false).change((value) => {
const options = optionsFunc();
if (typeof value === "string") {
if (typeof options.color === "string") {
options.color = value;
}
else {
options.color = {
value,
};
}
}
void this.particles().refresh();
});
group.addProperty("enable", "Enable", object_gui_1.EditorType.boolean).change(() => {
void this.particles().refresh();
});
group.addProperty("frequency", "Frequency", object_gui_1.EditorType.number).change(() => {
void this.particles().refresh();
});
group
.addProperty("opacity", "Opacity", object_gui_1.EditorType.number)
.change(() => {
void this.particles().refresh();
})
.step(0.01)
.min(0)
.max(1);
}
}
exports.TwinkleOptionsEditor = TwinkleOptionsEditor;
});