Is there a simple way to change the lightness of a color given as RGB string?
E.g.
in_RGB = '#FF0000' -开发者_运维百科-> out_RGB = '#CC0000'
It's not that hard to convert a hex string to an RGB 3-tuple.
Once you've done that, you can use the colorsys
module (or if you prefer to implement it yourself, the equations here) to convert from RGB to HSL, then do the manipulation you want, and then convert back from HSL to RGB.
Then just convert back to hex, add the #
sign again, and you're good to go.
精彩评论