Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有一种简单的方法来改变以 RGB 字符串形式给出的颜色的亮度?
例如
in_RGB = '#FF0000' --> out_RGB = '#CC0000'
将十六进制字符串转换为 RGB 三元组并不难。
完成此操作后,您可以使用该colorsys模块(或者如果您更喜欢自己实现它,这里的方程式)从 RGB 转换为 HSL,然后进行所需的操作,然后再从 HSL 转换回 RGB。
colorsys
然后只需转换回十六进制,#再次添加符号,就可以了。
#