implement fill color option for boxes, start wx integration

This commit is contained in:
louisnw
2024-05-16 11:25:42 +01:00
parent f8c0a5754d
commit 906571e4fb
13 changed files with 175 additions and 137 deletions

View File

@ -22,7 +22,9 @@ export class ColorPicker {
private _opacityLabel: HTMLDivElement;
private rgba: number[] | undefined;
constructor(saveDrawings: Function) {
constructor(saveDrawings: Function,
private colorOption: string,
) {
this.saveDrawings = saveDrawings
this._div = document.createElement('div');
@ -114,12 +116,12 @@ export class ColorPicker {
updateColor() {
if (!Drawing.lastHoveredObject || !this.rgba) return;
const oColor = `rgba(${this.rgba[0]}, ${this.rgba[1]}, ${this.rgba[2]}, ${this.opacity})`
Drawing.lastHoveredObject.applyOptions({lineColor: oColor})
Drawing.lastHoveredObject.applyOptions({[this.colorOption]: oColor})
this.saveDrawings()
}
openMenu(rect: DOMRect) {
if (!Drawing.lastHoveredObject) return;
this.rgba = ColorPicker.extractRGBA(Drawing.lastHoveredObject._options.lineColor)
this.rgba = ColorPicker.extractRGBA(Drawing.lastHoveredObject._options[this.colorOption])
this.opacity = this.rgba[3];
this._updateOpacitySlider();
this._div.style.top = (rect.top-30)+'px'