refactor: clamp\storage dry

This commit is contained in:
2026-10-09 22:09:02 +05:00
parent d58f6c90be
commit 07c6475c21
15 changed files with 68 additions and 77 deletions
+1 -4
View File
@@ -1,6 +1,7 @@
import { ToolError } from "./errors";
import type { PixelImage } from "./types";
import { createPixelImage } from "./types";
import { clamp01 } from "./math";
export type Rgb = { r: number; g: number; b: number };
export type Hsl = { h: number; s: number; l: number };
@@ -180,10 +181,6 @@ export function sortPalette(hexes: string[], key: SortKey): string[] {
.map((s) => s.h);
}
function clamp01(v: number): number {
return Math.min(1, Math.max(0, v));
}
/** Horizontal equal swatch columns (strip) or a grid of ~square cells (grid). */
export function renderSwatches(
colors: string[],