template-processor: add rgb(a)_csv formats

This is the format e.g. KDE saves colors in.
This commit is contained in:
Mia Herkt
2026-04-05 00:08:37 +02:00
parent 8db923d66f
commit d97918f3ac
+3 -1
View File
@@ -87,7 +87,7 @@ class VariableScope:
# --- Known color format types ---
KNOWN_FORMATS = frozenset({
"hex", "hex_stripped", "rgb", "rgba", "hsl", "hsla",
"hex", "hex_stripped", "rgb", "rgb_csv", "rgba", "hsl", "hsla",
"red", "green", "blue", "alpha", "hue", "saturation", "lightness",
})
@@ -661,6 +661,8 @@ class TemplateRenderer:
return color.to_hex().lstrip('#')
elif format_type == "rgb":
return f"rgb({color.r}, {color.g}, {color.b})"
elif format_type == "rgb_csv":
return f"{color.r},{color.g},{color.b}"
elif format_type == "rgba":
alpha = getattr(color, 'alpha', 1.0)
return f"rgba({color.r}, {color.g}, {color.b}, {alpha})"