Skip to content

Instantly share code, notes, and snippets.

@wakita
Last active April 7, 2023 06:23
Show Gist options
  • Save wakita/4bf8c1a96b7e24225c3e084a78ea3d47 to your computer and use it in GitHub Desktop.
Save wakita/4bf8c1a96b7e24225c3e084a78ea3d47 to your computer and use it in GitHub Desktop.
CIELch → RGB: 三色
<div background-color="0xFFCDE4">
Red
</div>
# pip install colormath
from colormath.color_objects import LCHabColor, sRGBColor
from colormath.color_conversions import convert_color
def hexlch(l, c, h):
rgb = convert_color(LCHabColor(l, c, h), sRGBColor).get_value_tuple()
return ''.join([f'{min(int(x * 256), 255):02X}' for x in rgb])
for t in [0, 120, 240]:
print(hexlch(90, 30, t))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment