summaryrefslogtreecommitdiff
path: root/src/caelestia/utils/colour.py
diff options
context:
space:
mode:
authorElio Torquet <92248577+elioTrqt@users.noreply.github.com>2025-08-04 01:14:10 -0400
committerGitHub <noreply@github.com>2025-08-04 15:14:10 +1000
commit06a710249011550b128b07d6245685659067512a (patch)
treeac95217b9b0d6662b31a714e2e50355d119490be /src/caelestia/utils/colour.py
parentshell: fix log when no log rules (diff)
downloadcaelestia-cli-06a710249011550b128b07d6245685659067512a.tar.gz
caelestia-cli-06a710249011550b128b07d6245685659067512a.tar.bz2
caelestia-cli-06a710249011550b128b07d6245685659067512a.zip
theme: add template system (#36)
* user template system * fix when templates dir doesnt exist Also color -> colour --------- Co-authored-by: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>
Diffstat (limited to 'src/caelestia/utils/colour.py')
-rw-r--r--src/caelestia/utils/colour.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/caelestia/utils/colour.py b/src/caelestia/utils/colour.py
new file mode 100644
index 0000000..a86c205
--- /dev/null
+++ b/src/caelestia/utils/colour.py
@@ -0,0 +1,28 @@
+class Colour:
+ _rgb_vals: tuple[int, ...]
+ _hex_vals: tuple[str, ...]
+
+ def __init__(self, hex: str):
+ hex = hex.ljust(8, "f")
+ self._hex_vals = tuple(hex[i : i + 2] for i in range(0, 7, 2))
+ self._rgb_vals = tuple(int(h, 16) for h in self._hex_vals)
+
+ @property
+ def hex(self) -> str:
+ return "".join(self._hex_vals[:-1])
+
+ @property
+ def hexalpha(self) -> str:
+ return "".join(self._hex_vals)
+
+ @property
+ def rgb(self) -> str:
+ return f"rgb({','.join(map(str, self._rgb_vals[:-1]))})"
+
+ @property
+ def rgbalpha(self) -> str:
+ return f"rgba({','.join(map(str, self._rgb_vals))})"
+
+
+def get_dynamic_colours(colours: dict[str, str]) -> dict[str, Colour]:
+ return {name: Colour(code) for name, code in colours.items()}