Skip to content

Instantly share code, notes, and snippets.

@wenijinew
Created September 18, 2023 18:48
Show Gist options
  • Save wenijinew/ab3e93afc90c1d9c7dc784ed5c30fdcb to your computer and use it in GitHub Desktop.
Save wenijinew/ab3e93afc90c1d9c7dc784ed5c30fdcb to your computer and use it in GitHub Desktop.
Generate Lighter Colors
def generate_lighter_colors(base_color, n_color):
"""Given base color, return 'n' color hex codes from base color to lightest
color."""
color_rgb = tuple(int(base_color[1:][i : i + 2], 16) for i in (0, 2, 4))
color_rgb_ligher = tuple(
[c for c in range(color, 255, (255 - color) // n_color)][0:n_color]
for color in color_rgb
)
lighter_colors = [
f"#{''.join(tuple(padding(hex(color_ligher[index]), 2) for color_ligher in color_rgb_ligher))}"
for index in range(0, n_color)
]
return lighter_colors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment