Skip to content

Commit 1d0ce7e

Browse files
committedAug 29, 2016
Simplify structure of colorization function
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
1 parent fe3628e commit 1d0ce7e

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed
 

‎nikola/utils.py

+11-14
Original file line numberDiff line numberDiff line change
@@ -1827,20 +1827,17 @@ def hash_str(string, pos):
18271827
def degreediff(dega, degb):
18281828
return min(abs(dega - degb), abs((degb - dega) + 360))
18291829

1830-
def husl_similar_from_base(string, base_color):
1831-
if husl is None:
1832-
req_missing(['husl'], 'Use color mixing (section colors)',
1833-
optional=True)
1834-
return base_color
1835-
h, s, l = husl.hex_to_husl(base_color)
1836-
old_h = h
1837-
idx = 0
1838-
while degreediff(old_h, h) < 27 and idx < 16:
1839-
h = 360.0 * (float(hash_str(string, idx)) / 255)
1840-
idx += 1
1841-
return husl.husl_to_hex(h, s, l)
1842-
1843-
return husl_similar_from_base(string, base_color)
1830+
if husl is None:
1831+
req_missing(['husl'], 'Use color mixing (section colors)',
1832+
optional=True)
1833+
return base_color
1834+
h, s, l = husl.hex_to_husl(base_color)
1835+
old_h = h
1836+
idx = 0
1837+
while degreediff(old_h, h) < 27 and idx < 16:
1838+
h = 360.0 * (float(hash_str(string, idx)) / 255)
1839+
idx += 1
1840+
return husl.husl_to_hex(h, s, l)
18441841

18451842

18461843
def color_hsl_adjust_hex(hexstr, adjust_h=None, adjust_s=None, adjust_l=None):

0 commit comments

Comments
 (0)
Please sign in to comment.