开发者

Python: reduce lightness of a RGB color

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜