Iterate on color schemes.

Improve descision of proper contrast
This commit is contained in:
Magnus Hoff 2018-07-19 08:53:05 +02:00
parent d905c1aa62
commit d3a50b0bc0
2 changed files with 29 additions and 18 deletions

View file

@ -48,9 +48,9 @@
} }
.theme-cyan { .theme-cyan {
--theme-main: #00BCD4; --theme-main: #0097A7;
--theme-text: white; --theme-text: white;
--theme-input: #4DD0E1; --theme-input: #00BCD4;
--theme-link: #90CAF9; --theme-link: #90CAF9;
} }
@ -69,37 +69,37 @@
} }
.theme-light-green { .theme-light-green {
--theme-main: #8BC34A; --theme-main: #689F38;
--theme-text: white; --theme-text: white;
--theme-input: #AED581; --theme-input: #8BC34A;
--theme-link: #90CAF9; --theme-link: #90CAF9;
} }
.theme-lime { .theme-lime {
--theme-main: #AFB42B; --theme-main: #D4E157;
--theme-text: white; --theme-text: black;
--theme-input: #CDDC39; --theme-input: #E6EE9C;
--theme-link: #90CAF9; --theme-link: #1976D2;
} }
.theme-yellow { .theme-yellow {
--theme-main: #FBC02D; --theme-main: #FFEE58;
--theme-text: black; --theme-text: black;
--theme-input: #FFEB3B; --theme-input: #FFF59D;
--theme-link: #1976D2; --theme-link: #1976D2;
} }
.theme-amber { .theme-amber {
--theme-main: #FFC107; --theme-main: #FFCA28;
--theme-text: black; --theme-text: black;
--theme-input: #FFD54F; --theme-input: #FFE082;
--theme-link: #1976D2; --theme-link: #1976D2;
} }
.theme-orange { .theme-orange {
--theme-main: #FF9800; --theme-main: #F57C00;
--theme-text: white; --theme-text: white;
--theme-input: #FFB74D; --theme-input: #FF9800;
--theme-link: #90CAF9; --theme-link: #90CAF9;
} }
@ -131,3 +131,4 @@
--theme-link: #90CAF9; --theme-link: #90CAF9;
} }

View file

@ -22,17 +22,25 @@ def luma(rgb):
return (0.2126*r + 0.7152*g + 0.0722*b) return (0.2126*r + 0.7152*g + 0.0722*b)
def prep(x): def prep(x):
cols = [x['colors'][5], x['colors'][7]] cols = x['colors']
rgb = [hex_to_rgb(c[1:]) for c in cols] rgb = [hex_to_rgb(c[1:]) for c in cols]
brightness = [luma(c) for c in rgb] brightness = [luma(c) for c in rgb]
main_index = 0 if brightness[0] < 0.6 else 1 dark_main = True
dark_main = brightness[main_index] < 0.5 main_index = 5
if brightness[main_index] >= 0.4:
main_index = 7
if brightness[main_index] >= 0.4:
dark_main = False
main_index = 4
if brightness[main_index] < 0.6:
main_index = 3
return { return {
"name": x['shade'].lower().replace(' ', '-'), "name": x['shade'].lower().replace(' ', '-'),
"main": cols[main_index], "main": cols[main_index],
"input": x['colors'][3 if main_index == 0 else 5], "input": x['colors'][main_index - 2],
"text": "white" if dark_main else "black", "text": "white" if dark_main else "black",
"link": blues[2] if dark_main else blues[7], "link": blues[2] if dark_main else blues[7],
} }
@ -54,4 +62,6 @@ print(
) )
) )
print()
# print("[" + ', '.join('"'+x['name']+'"' for x in themes) + "]") # print("[" + ', '.join('"'+x['name']+'"' for x in themes) + "]")