add range slider component
This commit is contained in:
18
src/util/color.py
Normal file
18
src/util/color.py
Normal file
@@ -0,0 +1,18 @@
|
||||
import re
|
||||
|
||||
from PySide6.QtGui import QColor
|
||||
|
||||
|
||||
def is_hex_color(color: str):
|
||||
return re.match("[0-9a-f]{6}", 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)
|
||||
elif color in QColor().colorNames():
|
||||
return QColor(color)
|
||||
return QColor(255, 255, 255)
|
||||
Reference in New Issue
Block a user