From ec42e0f6c7e9452d79898a096eca2710b23a9d60 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Fri, 22 May 2026 17:03:24 -0500 Subject: chore(themes): regenerate dupre palette preview from palette.el The committed palette PNG had drifted from the theme. It labeled steel as "cyan", invented magenta colors the palette never had, and left out blue+2. There was no generator, so the preview and the source diverged silently. I added gen-palette-preview.py, which parses the (name "#hex") pairs straight out of dupre-palette.el and emits the preview HTML grouped one row per color family. I regenerated the HTML and the PNG from it, so all 32 colors show with square swatches at 2x, columns aligned, and nothing drifts from palette.el again. --- themes/dupre-color-palette.html | 248 ++++++++++++---------------------------- themes/dupre-palette.png | Bin 138572 -> 46570 bytes themes/gen-palette-preview.py | 83 ++++++++++++++ 3 files changed, 156 insertions(+), 175 deletions(-) create mode 100755 themes/gen-palette-preview.py diff --git a/themes/dupre-color-palette.html b/themes/dupre-color-palette.html index 9bbbb951..f3d6ae31 100644 --- a/themes/dupre-color-palette.html +++ b/themes/dupre-color-palette.html @@ -1,183 +1,81 @@ - - - Color Palette - + + Dupre Theme Color Palette + -

Color Palette Comparison

-
-
-
-
bg
#151311
-
-
-
-
bg+1
#252321
-
-
-
-
bg+2
#474544
-
-
-
-
gray-2
#58574e
-
-
-
-
gray-1
#6c6a60
-
-
-
-
gray
#969385
-
-
-
-
gray+1
#b4b1a2
-
-
-
-
gray+2
#d0cbc0
-
-
-
-
steel
#8a9496
-
-
-
-
steel+1
#acb0b3
-
-
-
-
steel+2
#c0c7ca
-
-
-
-
blue
#67809c
-
-
-
-
blue+1
#b2c3cc
-
-
-
-
blue+2
#d9e2ff
-
-
-
-
green-2
#646d14
-
-
-
-
green-1
#869038
-
-
-
-
green
#a4ac64
-
-
-
-
green+1
#ccc768
-
-
-
-
red-3
#3f1c0f
-
-
-
-
red-2
#7c2a09
-
-
-
-
red-1
#a7502d
-
-
-
-
red
#d47c59
-
-
-
-
red+1
#edb08f
-
-
-
-
red+2
#edbca2
-
-
-
-
yellow-2
#875f00
-
-
-
-
yellow-1
#ffd700
-
-
-
-
yellow
#d7af5f
-
-
-
-
yellow+1
#ffd75f
-
-
-
-
yellow+2
#f9ee98
-
-
-
-
intense-red
#ff2a00
-
-
-
-
fg
#f0fef0
-
+

Dupre Theme Color Palette

+
+
bg
+
bg
#151311
+
bg+0
#151311
+
bg+1
#252321
+
bg+2
#474544
+
+
+
gray
+
gray-2
#58574e
+
gray-1
#6c6a60
+
gray
#969385
+
gray+1
#b4b1a2
+
gray+2
#d0cbc0
+
+
+
steel
+
steel
#8a9496
+
steel+1
#acb0b3
+
steel+2
#c0c7ca
+
+
+
blue
+
blue
#67809c
+
blue+1
#b2c3cc
+
blue+2
#d9e2ff
+
+
+
green
+
green-2
#646d14
+
green-1
#869038
+
green
#a4ac64
+
green+1
#ccc768
+
+
+
red
+
red-3
#3f1c0f
+
red-2
#7c2a09
+
red-1
#a7502d
+
red
#d47c59
+
red+1
#edb08f
+
red+2
#edbca2
+
+
+
yellow
+
yellow-2
#875f00
+
yellow-1
#ffd700
+
yellow
#d7af5f
+
yellow+1
#ffd75f
+
yellow+2
#f9ee98
+
+
+
intense-red
+
intense-red
#ff2a00
+
+
+
fg
+
fg
#f0fef0
diff --git a/themes/dupre-palette.png b/themes/dupre-palette.png index d0e78b5f..94bd084c 100644 Binary files a/themes/dupre-palette.png and b/themes/dupre-palette.png differ diff --git a/themes/gen-palette-preview.py b/themes/gen-palette-preview.py new file mode 100755 index 00000000..0b15f10b --- /dev/null +++ b/themes/gen-palette-preview.py @@ -0,0 +1,83 @@ +#!/usr/bin/env python3 +"""Generate the Dupre palette preview HTML from dupre-palette.el. + +Reads the (name "#hex") pairs straight from the palette source so the preview +can't drift from the theme. Groups colors into one row per family (by name +prefix, e.g. gray-2/gray/gray+1 share the "gray" row), with fixed-width +swatches so columns line up across rows. + +Regenerate the PNG from the HTML afterwards: + + google-chrome-stable --headless=new --screenshot=themes/dupre-palette.png \\ + --window-size=975,1520 --hide-scrollbars --default-background-color=151311FF \\ + "file://$PWD/themes/dupre-color-palette.html" +""" +import re +from pathlib import Path + +HERE = Path(__file__).resolve().parent +SRC = HERE / "dupre-palette.el" +OUT = HERE / "dupre-color-palette.html" + +text = open(SRC).read() +# Only the dupre-palette defconst has (name "#hex") pairs; semantic mappings are +# (name colorname) with no hex, so this regex selects exactly the base palette. +pairs = re.findall(r'\(([a-z0-9]+(?:[+\-]\d+)?(?:-[a-z]+)?)\s+"(#[0-9a-fA-F]{6})"\)', text) + +def family(name): + m = re.match(r'^([a-z]+(?:-[a-z]+)??)(?:[+\-]\d+)?$', name) + return m.group(1) if m else name + +# Group consecutive same-family entries (palette.el already orders them so). +rows, cur_fam, cur = [], None, [] +for name, hexv in pairs: + fam = family(name) + if fam != cur_fam: + if cur: + rows.append((cur_fam, cur)) + cur_fam, cur = fam, [] + cur.append((name, hexv)) +if cur: + rows.append((cur_fam, cur)) + +def swatch(name, hexv): + return (f'
' + f'
' + f'
{name}
' + f'
{hexv}
') + +body = [] +for fam, items in rows: + body.append('
') + body.append(f'
{fam}
') + body.extend(swatch(n, h) for n, h in items) + body.append('
') + +html = f""" + + + + Dupre Theme Color Palette + + + +

Dupre Theme Color Palette

+{chr(10).join(body)} + + +""" + +open(OUT, "w").write(html) +print(f"wrote {OUT}: {len(pairs)} colors in {len(rows)} family rows") +print("families:", ", ".join(f for f, _ in rows)) -- cgit v1.2.3