colorgram.py icon indicating copy to clipboard operation
colorgram.py copied to clipboard

hex property for Color objects

Open ewen-lbh opened this issue 5 years ago • 2 comments

I'd like to have an extra .hex property in the Color object, that contains a string representing the hexadecimal color code. eg.

>>> print(my_color.hex)
'#0A1FB5'

ewen-lbh avatar Jun 24 '19 11:06 ewen-lbh

I first thought I needed this too, but then remembered that CSS supports RGB colors too. So converting a Color object to one usable in CSS is just:

css_color = f"rgb({color.rgb.r}, {color.rgb.g}, {color.rgb.b})"

EmilStenstrom avatar Jan 05 '20 16:01 EmilStenstrom

I would second this, but also include HSB/HSV, HCL, HCB/HCV, YCbCr, YCoCg, and others. Who wanna do a pull request? This should be easy as PIE

DonaldTsang avatar Jan 08 '21 12:01 DonaldTsang