Completed color value editor component.

This commit is contained in:
Jay
2025-08-03 15:24:25 -04:00
parent 33f6a7e0c2
commit c27a5258d3
10 changed files with 613 additions and 36 deletions
+19
View File
@@ -1,3 +1,7 @@
import type { RefObject } from "react";
import type { CartesianSpace } from "./types";
export function minmax(number: number, min: number, max: number) {
return Math.min(max, Math.max(min, number));
}
@@ -25,3 +29,18 @@ export function extractEventCoordinates(event: MouseEvent | TouchEvent): {
clientY: event.clientY,
};
}
export function setMeasurements(
ref: RefObject<HTMLElement | null>,
setOrigin: (newOrigin: CartesianSpace) => void,
setDimensions: (newDimensions: CartesianSpace) => void,
) {
const el = ref.current;
if (el) {
const rect = el.getBoundingClientRect();
setOrigin({ x: rect.left, y: rect.top });
setDimensions({ x: rect.width, y: rect.height });
}
}