vitrine

display: NewThemeAt, a theme at a chosen hue

commit a92ee56422622d10f16796b457a68ae7bda3ae84 · parent 1f54fea43d · browse this tree
Ximianth, 2026-10-30 17:24:17 UTC

The hash diversifies nicely but cannot be argued with; embedders whose users
overrule the draw pick the hue directly.  The per-scheme lightness tuning
still applies, so a chosen hue keeps the hashed ones' contrast guarantees.
diff --git a/display/theme.go b/display/theme.go
index 6e20953..d65cc11 100644
--- a/display/theme.go
+++ b/display/theme.go
@@ -19,9 +19,16 @@ type Theme struct {
 }
 
 func NewTheme(seed string) Theme {
-	hue := ThemeHue(seed)
+	return NewThemeAt(seed, ThemeHue(seed))
+}
+
+// NewThemeAt builds a theme at an explicitly chosen hue, for embedders whose users
+// overrule the seed's draw (the hash diversifies nicely, but it cannot be argued with).
+// The per-scheme lightness tuning still applies, so a chosen hue keeps the same
+// contrast guarantees as a hashed one.
+func NewThemeAt(name string, hue int) Theme {
 	return Theme{
-		Name: seed,
+		Name: name,
 		CSS: []byte(fmt.Sprintf(
 			":root { --accent: hsl(%d 70%% %d%%); }\n"+
 				"@media (prefers-color-scheme: dark) { :root { --accent: hsl(%d 70%% %d%%); } }\n",