add positions of hits to the range slider

This commit is contained in:
2024-03-28 20:21:07 +01:00
parent 76f7baecf3
commit 6538e85f37
5 changed files with 65 additions and 4 deletions

View File

@@ -7,12 +7,22 @@ def is_hex_color(color: str):
return re.match("[0-9a-f]{6}", color, flags=re.IGNORECASE)
def is_hex_color_with_alpha(color: str):
return re.match("[0-9a-f]{8}", color, flags=re.IGNORECASE)
def to_qcolor(color: str):
if is_hex_color(color):
red = int(color[0:2], 16)
green = int(color[2:4], 16)
blue = int(color[4:6], 16)
return QColor(red, green, blue)
if is_hex_color_with_alpha(color):
red = int(color[0:2], 16)
green = int(color[2:4], 16)
blue = int(color[4:6], 16)
alpha = int(color[6:8], 16)
return QColor(red, green, blue, alpha)
elif color in QColor().colorNames():
return QColor(color)
return QColor(255, 255, 255)