diff --git a/light9/web/light9-color-picker.html b/light9/web/light9-color-picker.ts
rename from light9/web/light9-color-picker.html
rename to light9/web/light9-color-picker.ts
--- a/light9/web/light9-color-picker.html
+++ b/light9/web/light9-color-picker.ts
@@ -1,339 +1,338 @@
-
-
+import debug from "debug";
+import { css, html, LitElement, PropertyValues } from "lit";
+import { customElement, property } from "lit/decorators.js";
+import { Literal, NamedNode } from "n3";
+import { SyncedGraph } from "../web/SyncedGraph";
+import { ControlValue } from "./Effect";
+import { GraphToControls } from "./GraphToControls";
+import { DeviceAttrRow } from "./Light9DeviceControl";
+import { Choice } from "./Light9Listbox";
+import { SubEvent } from "sub-events";
+
+//
+const log = debug("control");
-
-
-
-
-
-
-
+@customElement("light9-color-picker-float")
+export class Light9ColorPickerFloat extends LitElement {
+ static styles = [
+ css`
+ :host {
+ z-index: 10;
+ position: fixed;
+ width: 400px;
+ height: 200px;
+ border: 10px solid #000;
+ box-shadow: 8px 11px 40px 0px rgba(0, 0, 0, 0.74);
+ /* This display (and border-color) are replaced later. */
+ display: none;
+ }
+ #largeCrosshair {
+ position: absolute;
+ left: -60px;
+ top: -62px;
+ pointer-events: none;
+ }
+ #largeCrosshair {
+ background: url(/colorpick_crosshair_large.svg);
+ width: 1000px;
+ height: 1000px;
+ }
+ #largeRainbowComp {
+ display: inline-block;
+ overflow: hidden;
+ position: relative;
+ }
+ #largeRainbowComp {
+ position: absolute;
+ left: 0x;
+ top: 0;
+ }
+ #largeRainbow {
+ background: url(/colorpick_rainbow_large.png);
+ width: 400px;
+ height: 200px;
+ user-select: none;
+ }
+ `,
+ ];
+ render() {
+ return html`
+
+ `;
+ }
+ // more methods get added by Light9ColorPicker
+}
+
+class RainbowCanvas {
+ constructor(url, size) {
+ this.size = size;
+ var elem = document.createElement("canvas");
+ elem.width = size[0];
+ elem.height = size[1];
+ this.ctx = elem.getContext("2d");
+
+ this.colorPos = {}; // color: pos
+ this._loaded = false;
+ this._loadWatchers = []; // callbacks
-
-
-
-
-
- V:
-
-
-
-
-
-
-
-
-
-
-
+ // special case: it's useless to adjust the hue/sat of black
+ if (this.value == 0) {
+ this.value = 255;
+ }
+ }
+ onOutOfBoundsMove(ev) {
+ const largeX = ev.offsetX - this.$.large.offsetLeft;
+ const largeY = ev.offsetY - this.$.large.offsetTop;
+ this.setLargePoint([this.clamp(largeX, 0, 400 - 1), this.clamp(largeY, 0, 200 - 1)]);
+ }
+ clamp(x, lo, hi) {
+ return Math.max(lo, Math.min(hi, x));
+ }
+}