From 1b52c5d89bb4bee0969fc9aca615afcf9c283f4a Mon Sep 17 00:00:00 2001 From: chflame163 Date: Fri, 20 Dec 2024 14:29:25 +0800 Subject: [PATCH] support for short format hexcolor strings of imagefunc.py --- py/imagefunc.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/py/imagefunc.py b/py/imagefunc.py index 6319d6e..7e3533e 100644 --- a/py/imagefunc.py +++ b/py/imagefunc.py @@ -1862,6 +1862,8 @@ def Hex_to_RGB(inhex:str) -> tuple: if not inhex.startswith('#'): raise ValueError(f'Invalid Hex Code in {inhex}') else: + if len(inhex) == 4: + inhex = "#" + "".join([char * 2 for char in inhex[1:]]) rval = inhex[1:3] gval = inhex[3:5] bval = inhex[5:] @@ -1876,6 +1878,8 @@ def Hex_to_HSV_255level(inhex:str) -> list: if not inhex.startswith('#'): raise ValueError(f'Invalid Hex Code in {inhex}') else: + if len(inhex) == 4: + inhex = "#" + "".join([char * 2 for char in inhex[1:]]) rval = inhex[1:3] gval = inhex[3:5] bval = inhex[5:]