Skip to content

Instantly share code, notes, and snippets.

@wenijinew
Created September 18, 2023 18:57
Show Gist options
  • Save wenijinew/929fc8e5cc51170a578523b8e2497c60 to your computer and use it in GitHub Desktop.
Save wenijinew/929fc8e5cc51170a578523b8e2497c60 to your computer and use it in GitHub Desktop.
Generate arbitray Nadic Colors
def generate_xadic_colors(hex_color, n_colors=7, plot=False, verbose=False):
""" "Convert."""
hls_color = hex2hls(hex_color)
triadic_colors = []
for offset in range(0, 360, 360 // n_colors):
triadic_colors.append(
((hls_color[0] + offset / 360) % 1.0, hls_color[1], hls_color[2])
)
_colors = [hls2hex(hls_color) for hls_color in triadic_colors][0:n_colors]
if verbose:
logger.info(_colors)
if plot:
plt.figure(figsize=(18, 1))
for i, color in enumerate(_colors):
plt.bar(i, 10, 0.8, color=color)
plt.show()
return _colors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment