forked from LiveCarta/BookConverter
RGB processing
This commit is contained in:
@@ -103,13 +103,12 @@ def str2hex(s: str):
|
||||
return rgb_percent_to_hex((r, g, b))
|
||||
|
||||
if 'rgb' in s:
|
||||
match = re.search(r'rgba*\(((\d+), *(\d+), *(\d+), (\d\.\d+)*)\)', s)
|
||||
if match:
|
||||
r, g, b = int(match.group(2)), int(match.group(3)), int(match.group(4))
|
||||
if match.group(5):
|
||||
alpha = float(match.group(5))
|
||||
r, g, b = rgba2rgb(r, g, b, alpha)
|
||||
return rgb_to_hex((r, g, b))
|
||||
rgba = re.findall('([0-9] *\.?[0-9]+)', s)
|
||||
r, g, b = int(rgba[0]), int(rgba[1]), int(rgba[2])
|
||||
if len(rgba) == 4:
|
||||
alpha = float(rgba[3])
|
||||
r, g, b = rgba2rgb(r, g, b, alpha)
|
||||
return rgb_to_hex((r, g, b))
|
||||
|
||||
if 'hsl' in s:
|
||||
# hsl(hue in {0,360}, saturation [0, 100%], lightness [0, 100%])
|
||||
|
||||
Reference in New Issue
Block a user