Color Scheme Generator
Generate complementary, triadic, and analogous color schemes from a base color.
Palette
#4F46E5
#DDE548
Frequently Asked Questions
Code Implementation
import colorsys
def hex_to_hsl(hex_color):
hex_color = hex_color.lstrip('#')
r, g, b = [int(hex_color[i:i+2], 16)/255 for i in (0,2,4)]
h, l, s = colorsys.rgb_to_hls(r, g, b)
return int(h*360), int(s*100), int(l*100)
def hsl_to_hex(h, s, l):
r, g, b = colorsys.hls_to_rgb(h/360, l/100, s/100)
return '#{:02x}{:02x}{:02x}'.format(int(r*255), int(g*255), int(b*255))
def complementary(hex_color):
h, s, l = hex_to_hsl(hex_color)
return [hex_color, hsl_to_hex((h + 180) % 360, s, l)]
print(complementary('#6366f1'))Comments & Feedback
Comments are powered by Giscus. Sign in with GitHub to leave a comment.