This commit is contained in:
Auric Vente 2024-07-19 04:40:54 -06:00
parent 0e2dfa7a3a
commit a8be025870
2 changed files with 5 additions and 2 deletions

View File

@ -76,7 +76,7 @@ class Ants:
ant.created = now
ant.updated = now
ant.name = Utils.random_name()
ant.color = Utils.random_color()
ant.color = Utils.random_color(ant.name)
Ants.ants.append(ant)
image_path = Config.hatched_image_path

View File

@ -68,7 +68,10 @@ class Utils:
print(text) # noqa: T201
@staticmethod
def random_color() -> tuple[int, int, int]:
def random_color(seed: str) -> tuple[int, int, int]:
seed_int = hash(seed)
random.seed(seed_int)
h, s, l = (
random.random(),
0.5 + random.random() / 2.0,