From 03dc9be5238fe7945e475da230ca297b35ce48df Mon Sep 17 00:00:00 2001 From: miruka Date: Mon, 22 Apr 2019 10:04:16 -0400 Subject: [PATCH] Improve hueFromString() More diversed output, without using hashing function. --- harmonyqml/backend/backend.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/harmonyqml/backend/backend.py b/harmonyqml/backend/backend.py index 518dc8e2..4504e614 100644 --- a/harmonyqml/backend/backend.py +++ b/harmonyqml/backend/backend.py @@ -1,7 +1,6 @@ # Copyright 2019 miruka # This file is part of harmonyqml, licensed under GPLv3. -import hashlib from concurrent.futures import ThreadPoolExecutor from typing import Dict, Sequence, Set @@ -75,9 +74,8 @@ class Backend(QObject): @pyqtSlot(str, result=float) def hueFromString(self, string: str) -> float: - # pylint:disable=no-self-use - md5 = hashlib.md5(bytes(string, "utf-8")).hexdigest() - return float("0.%s" % int(md5[-10:], 16)) + # pylint:disable=no-self-use + return sum((ord(char) * 99 for char in string)) % 360 / 360 @pyqtSlot(str)