utils.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:KodiDevKit 作者: phil65 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号