color.py 文件源码

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

项目:uchroma 作者: cyanogen 项目源码 文件源码
def luminance(color: ColorType) -> float:
        """
        Calculate the relative luminance (as defined by WCAG 2.0) of
        the given color.

        :param color: a color
        :return: the calculated relative luminance between 0.0 and 10
        """
        rgb = color.rgb
        vals = []
        for c in rgb:
            if c <= 0.03928:
                c /= 12.92
            else:
                c = math.pow((c + 0.055) / 1.055, 2.4)
            vals.append(c)
        L = 0.2126 * vals[0] + 0.7152 * vals[1] + 0.0722 * vals[2]
        return L
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号