def get_contrast_color(col):
"""
gets contrast color for *col (used to ensure readability)
"""
(hue, l, saturation) = colorsys.rgb_to_hls(int(col[1:3], 16) / 255.0,
int(col[3:5], 16) / 255.0,
int(col[5:7], 16) / 255.0)
lightness = 1 - l
if abs(lightness - l) < .15:
lightness = .15
(red, green, blue) = colorsys.hls_to_rgb(hue, lightness, saturation)
return to_hex(int(red * 255), int(green * 255), int(blue * 255)) # true complementary
评论列表
文章目录