def get_color_info_html(self, color_string):
"""
return formatted info for *color_string, taken from color xmls (default + themes + core).
"""
color_info = ""
for item in self.get_colors():
if item["name"] == color_string:
color_hex = "#" + item["content"][2:]
cont_color = utils.get_contrast_color(color_hex)
alpha_percent = round(int(item["content"][:2], 16) / (16 * 16) * 100)
color_info += '%s <a href="test" style="background-color:%s;color:%s">%s</a> %d %% alpha<br>' % (os.path.basename(item["file"]), color_hex, cont_color, item["content"], alpha_percent)
if color_info:
return color_info
if all(c in string.hexdigits for c in color_string) and len(color_string) == 8:
color_hex = "#" + color_string[2:]
cont_color = utils.get_contrast_color(color_hex)
alpha_percent = round(int(color_string[:2], 16) / (16 * 16) * 100)
return '<a href="test" style="background-color:%s;color:%s">%d %% alpha</a>' % (color_hex, cont_color, alpha_percent)
评论列表
文章目录