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
评论列表
文章目录