Files
Copilot f687bc95e9 Overhaul /bgcol: Oklch color space, full palette generation, save as new theme (#5162)
* Initial plan

* Overhaul /bgcol command: Oklab color space, dominant color extraction, full theme palette generation

- Create ThemeGenerator module in public/scripts/util/ with:
  - Oklab color space conversions (sRGB ↔ Oklab ↔ LCH)
  - Chroma-weighted dominant color extraction (vivid over muddy averages)
  - Color theory palette: complementary, analogous, triadic hue relationships
  - WCAG contrast ratio enforcement (≥3.5:1 for all text colors)
- Replace old setAvgBG with new implementation using ThemeGenerator
- Save generated theme as "Generated - <background name>" instead of overwriting
- Update command help string to reflect production-ready status

Co-authored-by: Cohee1207 <18619528+Cohee1207@users.noreply.github.com>

* Extract hue shift constants for clarity (code review feedback)

Co-authored-by: Cohee1207 <18619528+Cohee1207@users.noreply.github.com>

* Add name and bg arguments to /bgcol command

- Add `name` named argument to override the generated theme name
- Add `bg` named argument with enum provider listing available backgrounds
  from /api/backgrounds/all to override the current background

Co-authored-by: Cohee1207 <18619528+Cohee1207@users.noreply.github.com>

* Improve types, add enum provider, reduce transparency

* Adjust alpha channel for better readability

* Refactor ThemeGenerator to work directly in Oklch, removing intermediate Oklab conversions

Replaced srgbToOklab/oklabToSrgb + oklabToLCH/lchToOklab with direct
srgbToOklch/oklchToSrgb functions. All color manipulations now use
{L, C, h} directly without converting through {a, b} intermediates.
The ensureContrast function now takes (L, C, h) parameters instead of
an Oklab object.

Co-authored-by: Cohee1207 <18619528+Cohee1207@users.noreply.github.com>

* Add custom background URL check and enhance theme generation logic

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Cohee1207 <18619528+Cohee1207@users.noreply.github.com>
2026-02-15 16:39:55 +02:00
..