UNPKG

@tsparticles/editor

Version:

tsParticles Configuration Editor

52 lines (51 loc) 1.72 kB
import { EditorType } from "object-gui"; import { ColorOptionsEditor } from "../Color/ColorOptionsEditor"; import { EditorBase } from "../../../../EditorBase"; export class StrokeOptionsEditor extends 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(this.particles); colorOptions.addToGroup(group, optionsFunc); group .addProperty("opacity", "Opacity", EditorType.number) .change(() => { void this.particles().refresh(); }) .step(0.01) .min(0) .max(1); group.addProperty("width", "Width", EditorType.number).change(() => { void this.particles().refresh(); }); } }