PmwColor.py 文件源码

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

项目:ecel 作者: ARL-UTEP-OC 项目源码 文件源码
def name2rgb(root, colorName, asInt = 0):
    if colorName[0] == '#':
        # Extract rgb information from the color name itself, assuming
        # it is either #rgb, #rrggbb, #rrrgggbbb, or #rrrrggggbbbb
        # This is useful, since tk may return incorrect rgb values if
        # the colormap is full - it will return the rbg values of the
        # closest color available.
        colorName = colorName[1:]
        digits = len(colorName) / 3
        factor = 16 ** (4 - digits)
        rgb = (
            string.atoi(colorName[0:digits], 16) * factor,
            string.atoi(colorName[digits:digits * 2], 16) * factor,
            string.atoi(colorName[digits * 2:digits * 3], 16) * factor,
        )
    else:
        # We have no choice but to ask Tk what the rgb values are.
        rgb = root.winfo_rgb(colorName)

    if not asInt:
        rgb = (rgb[0] / _MAX_RGB, rgb[1] / _MAX_RGB, rgb[2] / _MAX_RGB)
    return rgb
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号