From c2c3ed14909b4ddcbcc381f0294863582a47512b Mon Sep 17 00:00:00 2001 From: saur0x <86295845+saur0x@users.noreply.github.com> Date: Sun, 1 Aug 2021 07:45:00 +0530 Subject: [PATCH] Patched hex color when hex is a single digit --- tkdesigner/figma/frame.py | 4 ++-- tkdesigner/figma/vector_elements.py | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/tkdesigner/figma/frame.py b/tkdesigner/figma/frame.py index c31bd592..43162c4d 100644 --- a/tkdesigner/figma/frame.py +++ b/tkdesigner/figma/frame.py @@ -104,8 +104,8 @@ def color(self) -> str: """ try: color = self.node["fills"][0]["color"] - rgba = [int(color.get(i, 0) * 255) for i in "rgba"] - return f"#{rgba[0]:0X}{rgba[1]:0X}{rgba[2]:0X}" + r, g, b, *_ = [int(color.get(i, 0) * 255) for i in "rgba"] + return f"#{r:02X}{g:02X}{b:02X}" except Exception: return "#FFFFFF" diff --git a/tkdesigner/figma/vector_elements.py b/tkdesigner/figma/vector_elements.py index 086df009..f579a953 100644 --- a/tkdesigner/figma/vector_elements.py +++ b/tkdesigner/figma/vector_elements.py @@ -5,12 +5,13 @@ class Vector(Node): def __init__(self, node): super().__init__(node) - def color(self): + def color(self) -> str: + """Returns HEX form of element RGB color (str) + """ try: color = self.node["fills"][0]["color"] - rgba = [int(color.get(i, 0) * 255) for i in "rgba"] - # return tuple(rgba) - return f"#{rgba[0]:0X}{rgba[1]:0X}{rgba[2]:0X}" + r, g, b, *_ = [int(color.get(i, 0) * 255) for i in "rgba"] + return f"#{r:02X}{g:02X}{b:02X}" except Exception: return "#FFFFFF"