Skip to content

Commit 1bbfd6c

Browse files
committed
saturate colors for piwal light theme
1 parent a93b992 commit 1bbfd6c

File tree

2 files changed

+51
-23
lines changed

2 files changed

+51
-23
lines changed

color_utils.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,16 @@ def lighteen_color(hex_color, min, blend):
210210
# print(f"result after blend: {o}")
211211
return o
212212

213+
def scale_saturation(hex_color, amount):
214+
r, g, b = hex2rgb(hex_color)
215+
# convert rgb to hls
216+
h, s, v = colorsys.rgb_to_hsv(r, g, b)
217+
# manipulate value and convert back to rgb
218+
r, g, b = colorsys.hsv_to_rgb(h, amount, v)
219+
o_hex = rgb2hex(int(r), int(g), int(b))
220+
# print(f"scale_lightness color: {hex_color} * amount: {amount} = {o_hex}")
221+
return o_hex
222+
213223
# Tests
214224
if __name__ == '__main__':
215225
# Test color blend

schemeconfigs.py

Lines changed: 41 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from color_utils import blendColors, color_luminance, hex2rgb, hex2alpha, sort_colors_luminance, blend2contrast, lighteen_color
1+
from color_utils import blendColors, contrast_ratio, hex2rgb, hex2alpha, scale_saturation, sort_colors_luminance, blend2contrast, lighteen_color
22
from utils import range_check, tup2str
33
class ThemeConfig:
44
def __init__(self, colors, wallpaper_data, light_blend_multiplier=1, dark_blend_multiplier=1, toolbar_opacity=100):
@@ -83,7 +83,7 @@ def __init__(self, colors, wallpaper_data, light_blend_multiplier=1, dark_blend_
8383
for x in range(7):
8484
str_x = str(x)
8585
if (len(pywal_colors_dark) <= 7):
86-
if str_x in colors_best.keys(): #and color_luminance(colors_best[str_x])[1] > .15
86+
if str_x in colors_best.keys():
8787
c = lighteen_color(colors_best[str_x],.2,tones_neutral[99])
8888
pywal_colors_dark += (blend2contrast(c, pywal_colors_dark[0], tones_neutral[99], 4.5, .01, True),)
8989
else:
@@ -109,43 +109,61 @@ def __init__(self, colors, wallpaper_data, light_blend_multiplier=1, dark_blend_
109109
tones_neutral[99], sorted_colors[n], .85),)
110110

111111

112-
tone = 38
112+
tone = 50
113113
pywal_colors_light = (extras['SurfaceLight'],)
114114
pywal_colors_light_intense = (blendColors(
115-
tones_neutral[20], colors_light['secondary'], .6*lbm),)
115+
tones_neutral[20], colors_light['secondary'], .8*lbm),)
116116
pywal_colors_light_faint = (blendColors(
117-
tones_neutral[55], colors_light['secondary'], .6*lbm),)
117+
tones_neutral[55], colors_light['secondary'], .8*lbm),)
118+
119+
# for x in range(7):
120+
# str_x = str(x)
121+
# if str_x in colors_best.keys()and color_luminance(colors_best[str_x])[1] > .15: #and contrast_ratio(pywal_colors_light[0],colors_best[str_x]) > .8
122+
# pywal_colors_light += (blend2contrast(colors_best[str_x], pywal_colors_light[0], tones_neutral[20], 4.5, .01, False),)
123+
# else:
124+
# pywal_colors_light += (blend2contrast(tones_primary[tone], pywal_colors_light[0], tones_neutral[20], 4.5, .01, False),)
125+
# pywal_colors_light += (blend2contrast(tones_tertiary[tone], pywal_colors_light[0], tones_neutral[20], 4.5, .01, False),)
126+
# if tone < 91:
127+
# tone += 8
118128

119-
for x in range(best_colors_count):
129+
for x in range(7):
120130
str_x = str(x)
121-
if str_x in colors_best.keys()and color_luminance(colors_best[str_x])[1] > .15: #and contrast_ratio(pywal_colors_light[0],colors_best[str_x]) > .8
122-
pywal_colors_light += (blend2contrast(colors_best[str_x], pywal_colors_light[0], tones_neutral[20], 4.5, .01, False),)
131+
if (len(pywal_colors_light) <= 7):
132+
if str_x in colors_best.keys():
133+
c = scale_saturation(colors_best[str_x],1)
134+
pywal_colors_light += (blend2contrast(c, pywal_colors_light[0], tones_neutral[20], 3, .01, False),)
135+
else:
136+
if (len(pywal_colors_light) <= 7):
137+
c = scale_saturation(tones_primary[tone],1)
138+
pywal_colors_light += (blend2contrast(c, pywal_colors_light[0], tones_neutral[20], 3, .01, False),)
139+
if (len(pywal_colors_light) <= 7):
140+
c = scale_saturation(tones_tertiary[tone],1)
141+
pywal_colors_light += (blend2contrast(c, pywal_colors_light[0], tones_neutral[20], 3, .01, False),)
142+
if tone < 91:
143+
tone += 8
123144
else:
124-
pywal_colors_light += (blend2contrast(tones_primary[tone], pywal_colors_light[0], tones_neutral[20], 4.5, .01, False),)
125-
pywal_colors_light += (blend2contrast(tones_tertiary[tone], pywal_colors_light[0], tones_neutral[20], 4.5, .01, False),)
126-
if tone < 91:
127-
tone += 8
145+
break
128146

129147
all = pywal_colors_light
130148
pywal_colors_light = (pywal_colors_light[0],)
131-
sorted_colors = sort_colors_luminance(sort_colors_luminance(all,reverse=True)[-7:])
149+
sorted_colors = sort_colors_luminance(all,True)[-7:]
132150

133151
for n in range(len(sorted_colors)):
134152
pywal_colors_light_intense += (sorted_colors[n],)
135153
pywal_colors_light += (blendColors(
136-
tones_neutral[40], sorted_colors[n], .75*lbm),)
154+
tones_neutral[30], sorted_colors[n], .8*lbm),)
137155
pywal_colors_light_faint += (blendColors(
138-
tones_neutral[40], sorted_colors[n], .6*lbm),)
156+
tones_neutral[60], sorted_colors[n], .8*lbm),)
139157

140158

141-
''' print("CONTRAST CHECK DARK")
142-
for color in pywal_colors_dark:
143-
c = contrast_ratio(color, pywal_colors_dark[0])
144-
print(f"{color} - {c}")
145-
print("CONTRAST CHECK LIGHT")
146-
for color in pywal_colors_light:
147-
c = contrast_ratio(pywal_colors_light[0],color)
148-
print(f"{color} - {c}") '''
159+
# print("CONTRAST CHECK DARK")
160+
# for color in pywal_colors_dark:
161+
# c = contrast_ratio(color, pywal_colors_dark[0])
162+
# print(f"{color} - {c}")
163+
# print("CONTRAST CHECK LIGHT")
164+
# for color in pywal_colors_light:
165+
# c = contrast_ratio(pywal_colors_light[0],color)
166+
# print(f"{color} - {c}")
149167

150168
self._light_scheme = f"""[ColorEffects:Disabled]
151169
Color={extras['SurfaceLight1']}

0 commit comments

Comments
 (0)