@tsparticles/editor
Version:
tsParticles Configuration Editor
141 lines (140 loc) • 4.6 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.BackgroundMaskOptionsEditor = void 0;
const object_gui_1 = require("object-gui");
const EditorBase_1 = require("../../../EditorBase");
class BackgroundMaskOptionsEditor extends EditorBase_1.EditorBase {
constructor(particles) {
super(particles);
}
addToGroup(parent) {
this.group = parent.addGroup("backgroundMask", "Background Mask");
this.options = this.group.data;
this.addCover();
this.addProperties();
}
addCover() {
const coverGroup = this.group.addGroup("cover", "Cover"), options = coverGroup.data, colorValue = options().color, color = typeof colorValue === "string" ? colorValue : colorValue?.value;
coverGroup.addProperty("color", "Color", object_gui_1.EditorType.color, color, false).change((value) => {
if (typeof value === "string") {
options().color = value;
}
else {
options().color = { value: value };
}
void this.particles().refresh();
});
coverGroup.addProperty("image", "Image", object_gui_1.EditorType.string).change(() => {
void this.particles().refresh();
});
coverGroup
.addProperty("opacity", "Opacity", object_gui_1.EditorType.number)
.change(() => {
void this.particles().refresh();
})
.step(0.01)
.min(0)
.max(1);
}
addProperties() {
this.group
.addProperty("composite", "Composite", object_gui_1.EditorType.select)
.change(() => {
void this.particles().refresh();
})
.addItems([
{
value: "source-over",
},
{
value: "source-in",
},
{
value: "source-out",
},
{
value: "source-atop",
},
{
value: "destination-over",
},
{
value: "destination-in",
},
{
value: "destination-out",
},
{
value: "destination-atop",
},
{
value: "lighter",
},
{
value: "copy",
},
{
value: "xor",
},
{
value: "multiply",
},
{
value: "screen",
},
{
value: "overlay",
},
{
value: "darken",
},
{
value: "lighten",
},
{
value: "color-dodge",
},
{
value: "color-burn",
},
{
value: "hard-light",
},
{
value: "soft-light",
},
{
value: "difference",
},
{
value: "exclusion",
},
{
value: "hue",
},
{
value: "saturation",
},
{
value: "color",
},
{
value: "luminosity",
},
]);
this.group.addProperty("enable", "Enable", object_gui_1.EditorType.boolean).change(() => {
void this.particles().refresh();
});
}
}
exports.BackgroundMaskOptionsEditor = BackgroundMaskOptionsEditor;
});