Improve hueFromString()
More diversed output, without using hashing function.
This commit is contained in:
		@@ -1,7 +1,6 @@
 | 
				
			|||||||
# Copyright 2019 miruka
 | 
					# Copyright 2019 miruka
 | 
				
			||||||
# This file is part of harmonyqml, licensed under GPLv3.
 | 
					# This file is part of harmonyqml, licensed under GPLv3.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import hashlib
 | 
					 | 
				
			||||||
from concurrent.futures import ThreadPoolExecutor
 | 
					from concurrent.futures import ThreadPoolExecutor
 | 
				
			||||||
from typing import Dict, Sequence, Set
 | 
					from typing import Dict, Sequence, Set
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -75,9 +74,8 @@ class Backend(QObject):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @pyqtSlot(str, result=float)
 | 
					    @pyqtSlot(str, result=float)
 | 
				
			||||||
    def hueFromString(self, string: str) -> float:
 | 
					    def hueFromString(self, string: str) -> float:
 | 
				
			||||||
      # pylint:disable=no-self-use
 | 
					        # pylint:disable=no-self-use
 | 
				
			||||||
        md5 = hashlib.md5(bytes(string, "utf-8")).hexdigest()
 | 
					        return sum((ord(char) * 99 for char in string)) % 360 / 360
 | 
				
			||||||
        return float("0.%s" % int(md5[-10:], 16))
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @pyqtSlot(str)
 | 
					    @pyqtSlot(str)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user