def parse_rgba(col):
"""
Parses color specified by #RRGGBBAA string.
'#' and 'AA' is optional.
"""
# Because GTK can parse everything but theese :(
alpha = "FF"
if not col.startswith("#"):
col = "#" + col
if len(col) > 7:
col, alpha = col[0:7], col[7:]
rgba = Gdk.RGBA()
if not rgba.parse(col):
log.warning("Failed to parse RGBA color: %s", col)
rgba.alpha = float(int(alpha, 16)) / 255.0
return rgba
评论列表
文章目录