Replaced random color generator
This commit is contained in:
parent
fd051d4664
commit
a63f3ed47b
1 changed files with 18 additions and 5 deletions
23
c4ctrl.py
23
c4ctrl.py
|
@ -604,14 +604,27 @@ class ColorScheme:
|
|||
return topic.lower().rfind("/master") == len(topic)-7 # 7 = len("/master")
|
||||
|
||||
def _random_color(self):
|
||||
"""Returns a random 6 char hex color."""
|
||||
from random import randint
|
||||
"""Returns a 3*4 bit pseudo random color in 6 char hex notation."""
|
||||
from random import randint, sample
|
||||
chls = [15]
|
||||
chls.append(randint(0,15))
|
||||
chls.append(randint(0,7) - chls[1])
|
||||
if chls[2] < 0: chls[2] = 0
|
||||
|
||||
color = ""
|
||||
for i in range(6):
|
||||
# Dont return smaller values than 11
|
||||
color = color + hex(randint(1, 15))[2:]
|
||||
for ch in sample(chls, k=3):
|
||||
color += hex(ch)[2:]*2
|
||||
return color
|
||||
|
||||
#def _random_color(self):
|
||||
# """Returns a random 6 char hex color."""
|
||||
# from random import randint
|
||||
# color = ""
|
||||
# for i in range(6):
|
||||
# # Dont return smaller values than 11
|
||||
# color = color + hex(randint(1, 15))[2:]
|
||||
# return color
|
||||
|
||||
def color_for(self, topic):
|
||||
"""Returns the color (hex) this ColorScheme provides for the given topic."""
|
||||
if self.mapping:
|
||||
|
|
Loading…
Reference in a new issue