browserHelpers.py 文件源码

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

项目:gcMapExplorer 作者: rjdkmr 项目源码 文件源码
def segmentDataColorMapToColorInfo(colormap):
    """ make a colormap information dictionary from
    segmented Data colormap object.

    Structure of ouput colorInfo dictionary

    colorInfo ----- 'name'
        |
        ?------ 'colors'
                    |
                    ?------ values -> color
                    |
                    ?------ values -> color
                    |
                    :
                    ?------ values -> color

    """
    colorInfo = dict()
    colorInfo['name'] = colormap.name
    colorInfo['colors'] = dict()
    for i in range(len(colormap._segmentdata['blue'])):
        value = colormap._segmentdata['blue'][i][0]
        r = colormap._segmentdata['red'][i][1]
        g = colormap._segmentdata['green'][i][1]
        b = colormap._segmentdata['blue'][i][1]
        a = colormap._segmentdata['alpha'][i][1]
        colorInfo['colors'][value] = mplColors.rgb2hex((r, g, b, a))

    return colorInfo
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号