Mercurial > code > home > repos > light-bridge
diff color.py @ 9:9f427d8073c3
redo data model; add ui colors
author | drewp@bigasterisk.com |
---|---|
date | Sun, 28 Jan 2024 16:53:08 -0800 |
parents | 181a86533286 |
children | ab80e8826441 |
line wrap: on
line diff
--- a/color.py Sun Jan 28 16:51:36 2024 -0800 +++ b/color.py Sun Jan 28 16:53:08 2024 -0800 @@ -37,3 +37,11 @@ def hex(self): r, g, b = int(self.r * 255), int(self.g * 255), int(self.b * 255) return '#%02x%02x%02x' % (r, g, b) + + @classmethod + def fromHex(cls, h: str): + return cls( + r=int(h[1:3], 16) / 255, + g=int(h[3:5], 16) / 255, + b=int(h[5:7], 16) / 255, + )