scheme: impl random + fix single schemes

This commit is contained in:
2 * r + 2 * t
2025-06-12 16:00:43 +10:00
parent 194826efaa
commit 672ef4a2d9
6 changed files with 10 additions and 1 deletions
+1
View File
@@ -15,6 +15,7 @@ class Command:
if self.args.random: if self.args.random:
scheme.set_random() scheme.set_random()
apply_colours(scheme.colours, scheme.mode)
elif self.args.name or self.args.flavour or self.args.mode: elif self.args.name or self.args.flavour or self.args.mode:
if self.args.name: if self.args.name:
scheme.name = self.args.name scheme.name = self.args.name
+1 -1
View File
@@ -187,6 +187,6 @@ def gen_scheme(scheme, primary: Hct, colours: list[Hct]) -> dict[str, str]:
colours["success"] = harmonize(base[8], primary) colours["success"] = harmonize(base[8], primary)
# For debugging # For debugging
print("\n".join(["{}: \x1b[48;2;{};{};{}m \x1b[0m".format(n, *c.to_rgba()[:3]) for n, c in colours.items()])) # print("\n".join(["{}: \x1b[48;2;{};{};{}m \x1b[0m".format(n, *c.to_rgba()[:3]) for n, c in colours.items()]))
return {k: hex(v.to_int())[4:] for k, v in colours.items()} return {k: hex(v.to_int())[4:] for k, v in colours.items()}
+8
View File
@@ -1,4 +1,5 @@
import json import json
import random
from pathlib import Path from pathlib import Path
from caelestia.utils.material import get_colours_for_image from caelestia.utils.material import get_colours_for_image
@@ -106,6 +107,13 @@ class Scheme:
f, f,
) )
def set_random(self) -> None:
self._name = random.choice(get_scheme_names())
self._flavour = random.choice(get_scheme_flavours())
self._mode = random.choice(get_scheme_modes())
self._update_colours()
self.save()
def _check_flavour(self) -> None: def _check_flavour(self) -> None:
global scheme_flavours global scheme_flavours
scheme_flavours = None scheme_flavours = None