Skip to content

Commit

Permalink
fix(color): ensure color=str assignment publishes correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
mwfarb committed Oct 29, 2024
1 parent 09d1ecc commit e335b4f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions arena/attributes/color.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def __init__(self, red=0, green=0, blue=0):
else:
c = (128, 128, 128)
else:
c = tuple(int(color[c: c + 2], 16) for c in (0, 2, 4))
c = tuple(int(color[c:c + 2], 16) for c in (0, 2, 4))
self.red, self.green, self.blue = c

if isinstance(red, float):
Expand All @@ -43,4 +43,7 @@ def __init__(self, red=0, green=0, blue=0):

@property
def hex(self):
return "#{:02x}{:02x}{:02x}".format(self.red, self.green, self.blue)
if isinstance(self.red, str):
return self.red
else:
return f"#{''.join(f'{i:02x}' for i in [self.red, self.green, self.blue])}"

0 comments on commit e335b4f

Please # to comment.