Skip to content

Commit

Permalink
Merge pull request Zingzy#40 from amaztony/main
Browse files Browse the repository at this point in the history
Fix color conversion issue
  • Loading branch information
Zingzy authored Dec 16, 2024
2 parents c6fa6c8 + 04f7051 commit 782cc63
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions hPyT/hPyT.py
Original file line number Diff line number Diff line change
Expand Up @@ -1261,10 +1261,10 @@ def convert_color(color: Union[Tuple[int, int, int], str]) -> int:

if isinstance(color, tuple) and len(color) == 3: # RGB format
r, g, b = color
return int(f"{b}{g}{r}", 16)
return (b << 16) | (g << 8) | r
elif isinstance(color, str) and color.startswith("#"): # HEX format
r, g, b = int(color[1:3], 16), int(color[3:5], 16), int(color[5:7], 16)
return (r << 16) | (g << 8) | b
return (b << 16) | (g << 8) | r
else:
raise ValueError("Invalid color format. Expected RGB tuple or HEX string.")

Expand Down

0 comments on commit 782cc63

Please sign in to comment.