Improve hueFromString()

More diversed output, without using hashing function.
This commit is contained in:
miruka 2019-04-22 10:04:16 -04:00
parent f6ae315fb2
commit 03dc9be523

View File

@ -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
@ -76,8 +75,7 @@ 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))
return sum((ord(char) * 99 for char in string)) % 360 / 360
@pyqtSlot(str)