import { html } from "lit" import ColorHandlerElement from "../element/ColorHandlerElement" import Configuration from "../Configuration" import LinearColorEntity from "../entity/LinearColorEntity" import Utility from "../Utility" import WindowTemplate from "./WindowTemplate" /** @typedef {import("../element/WindowElement").default} WindowElement */ export default class ColorPickerWindowTemplate extends WindowTemplate { static windowName = html`Color Picker` /** @type {LinearColorEntity} */ #color get color() { return this.#color } /** @param {LinearColorEntity} value */ set color(value) { if (value.toNumber() == this.color?.toNumber()) { return } this.element.requestUpdate("color", this.#color) this.#color = value } connectedCallback() { super.connectedCallback() this.color = this.element.windowOptions.getPinColor() } /** @param {Map} changedProperties */ firstUpdated(changedProperties) { const wheelHandler = new ColorHandlerElement() const spectrumHandler = new ColorHandlerElement() wheelHandler.template.setLocationChangeCallback(([x, y]) => { const [r, theta] = Utility.getPolarCoordinates([x, y]) this.color = LinearColorEntity.fromWheelLocation(x, y) }) this.element.querySelector(".ueb-color-picker-wheel").appendChild(new ColorHandlerElement()) } renderContent() { return html`