@tsparticles/editor
Version:
tsParticles Configuration Editor
66 lines (65 loc) • 2.59 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", "../Color/ColorOptionsEditor", "../../../../EditorBase"], factory);
}
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.StrokeOptionsEditor = void 0;
const object_gui_1 = require("object-gui");
const ColorOptionsEditor_1 = require("../Color/ColorOptionsEditor");
const EditorBase_1 = require("../../../../EditorBase");
class StrokeOptionsEditor extends EditorBase_1.EditorBase {
constructor(particles) {
super(particles);
}
addToGroup(parent) {
this.group = parent.addGroup("stroke", "Stroke");
this.options = this.group.data;
if (this.options() instanceof Array) {
for (let i = 0; i < this.options.length; i++) {
const group = this.group.addGroup(i.toString(10), `Stroke_${i + 1}`, true, this.options);
this.addStroke(group);
}
}
else {
this.addStroke(this.group);
}
}
addStroke(group) {
const optionsFunc = group.data;
const options = optionsFunc();
if (options.color === undefined) {
options.color = {
value: "",
animation: {
count: 0,
enable: false,
offset: { max: 0, min: 0 },
speed: 0,
decay: 0,
sync: false,
},
};
}
const colorOptions = new ColorOptionsEditor_1.ColorOptionsEditor(this.particles);
colorOptions.addToGroup(group, optionsFunc);
group
.addProperty("opacity", "Opacity", object_gui_1.EditorType.number)
.change(() => {
void this.particles().refresh();
})
.step(0.01)
.min(0)
.max(1);
group.addProperty("width", "Width", object_gui_1.EditorType.number).change(() => {
void this.particles().refresh();
});
}
}
exports.StrokeOptionsEditor = StrokeOptionsEditor;
});