From c6ac429ef6907ecf6281d5b553ce0313b872e72e Mon Sep 17 00:00:00 2001 From: chflame163 Date: Fri, 20 Dec 2024 14:29:41 +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 fc53a17..f2c9f11 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:]