1
- from color_utils import blendColors , contrast_ratio , hex2rgb , hex2alpha , scale_saturation , sort_colors_luminance , blend2contrast , lighteen_color
1
+ from color_utils import blendColors , contrast_ratio , hex2rgb , hex2alpha , scale_lightness , scale_saturation , sort_colors_luminance , blend2contrast , lighteen_color
2
2
from utils import range_check , tup2str
3
3
class ThemeConfig :
4
4
def __init__ (self , colors , wallpaper_data , light_blend_multiplier = 1 , dark_blend_multiplier = 1 , toolbar_opacity = 100 ):
5
5
if toolbar_opacity == None :
6
6
toolbar_opacity = 100
7
7
colors_best = colors ['bestColors' ]
8
8
tones_primary = colors ['palettes' ]['primaryTones' ]
9
+ tones_secondary = colors ['palettes' ]['secondaryTones' ]
9
10
tones_neutral = colors ['palettes' ]['neutralTones' ]
10
11
tones_tertiary = colors ['palettes' ]['tertiaryTones' ]
11
12
colors_light = colors ['schemes' ]['light' ]
@@ -26,17 +27,15 @@ def __init__(self, colors, wallpaper_data, light_blend_multiplier=1, dark_blend_
26
27
27
28
# Blend some extra colors by factor left(0.0) to right(1.0)
28
29
self ._extras = {
29
- "SurfaceLight" : blendColors (colors_light ['surface' ], colors_light ['primary' ], 0.05 * lbm ),
30
- "SurfaceDark" : blendColors (tones_neutral [5 ], colors_dark ['primary' ], 0.08 * dbm ),
30
+ "SurfaceLight" : blendColors (colors_light ['background' ], tones_primary [70 ], 0.13 * lbm ),
31
+ "SurfaceLight1" : blendColors (colors_light ['background' ], tones_primary [70 ], .18 * lbm ),
32
+ "SurfaceLight2" : blendColors (colors_light ['background' ], tones_primary [70 ], .23 * lbm ),
33
+ "SurfaceLight3" : blendColors (colors_light ['background' ], tones_primary [70 ], .20 * lbm ),
31
34
32
- "SurfaceLight1" : blendColors (colors_light ['background' ], colors_light ['primary' ], .08 * lbm ),
33
- "SurfaceDark1" : blendColors (colors_dark ['background' ], colors_dark ['primary' ], .05 * dbm ),
34
-
35
- "SurfaceLight2" : blendColors (colors_light ['background' ], colors_light ['primary' ], .11 * lbm ),
36
- "SurfaceDark2" : blendColors (colors_dark ['background' ], colors_dark ['primary' ], .08 * dbm ),
37
-
38
- "SurfaceLight3" : blendColors (colors_light ['background' ], colors_light ['primary' ], .16 * lbm ),
39
- "SurfaceDark3" : blendColors (colors_dark ['background' ], colors_dark ['primary' ], .08 * dbm ),
35
+ "SurfaceDark" : blendColors (tones_neutral [5 ], tones_primary [40 ], 0.08 * dbm ),
36
+ "SurfaceDark1" : blendColors (colors_dark ['background' ], tones_primary [40 ], .05 * dbm ),
37
+ "SurfaceDark2" : blendColors (colors_dark ['background' ], tones_primary [40 ], .08 * dbm ),
38
+ "SurfaceDark3" : blendColors (colors_dark ['background' ], tones_primary [40 ], .11 * dbm ),
40
39
41
40
"LinkOnPrimaryLight" : blendColors (colors_light ['onPrimary' ], base_text_states ['Link' ], .5 ),
42
41
"LinkVisitedOnPrimaryLight" : blendColors (colors_light ['onPrimary' ], base_text_states ['Visited' ], .8 ),
@@ -61,13 +60,19 @@ def __init__(self, colors, wallpaper_data, light_blend_multiplier=1, dark_blend_
61
60
"NegativeOnSurfaceDark" : blendColors (colors_dark ['onSurface' ], base_text_states ['Negative' ], .8 ),
62
61
"PositiveOnSurfaceDark" : blendColors (colors_dark ['onSurface' ], base_text_states ['Positive' ], .8 ),
63
62
"NeutralOnSurfaceDark" : blendColors (colors_dark ['onSurface' ], base_text_states ['Neutral' ], .8 ),
64
-
65
- "LightSelectionAlt" : blendColors (colors_light ['surface' ], colors_light ['secondary' ], .02 * lbm ),
66
- "DarkSelectionAlt" : blendColors (colors_dark ['background' ], colors_dark ['secondary' ], .3 * dbm ),
67
-
68
63
"LightSelectionAltActive" : blendColors (colors_light ['background' ], colors_light ['secondary' ], .5 ),
69
64
"DarkSelectionAltActive" : blendColors (colors_dark ['background' ], colors_dark ['secondary' ], .5 ),
70
65
}
66
+ self ._extras .update (
67
+ {
68
+ "DarkSelectionAlt" : blendColors (tones_secondary [30 ], self ._extras ['SurfaceDark3' ], .05 * dbm ),
69
+ "LightSelectionAlt" : blendColors (self ._extras ['SurfaceLight3' ], tones_primary [30 ], .05 * lbm ),
70
+
71
+ "DarkSelectionHover" : blendColors (tones_secondary [50 ], self ._extras ['SurfaceDark3' ], .1 * dbm ),
72
+ "LightSelectionHover" : blendColors (self ._extras ['SurfaceLight3' ], tones_primary [50 ], .1 * lbm ),
73
+ }
74
+ )
75
+
71
76
extras = self ._extras
72
77
73
78
best_colors_count = len (colors_best )
@@ -112,33 +117,25 @@ def __init__(self, colors, wallpaper_data, light_blend_multiplier=1, dark_blend_
112
117
tone = 50
113
118
pywal_colors_light = (extras ['SurfaceLight' ],)
114
119
pywal_colors_light_intense = (blendColors (
115
- tones_neutral [20 ], colors_light ['secondary' ], .8 * lbm ),)
120
+ tones_neutral [50 ], colors_light ['secondary' ], .8 * lbm ),)
116
121
pywal_colors_light_faint = (blendColors (
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
122
+ tones_neutral [75 ], colors_light ['secondary' ], .8 * lbm ),)
128
123
124
+
129
125
for x in range (7 ):
130
126
str_x = str (x )
131
127
if (len (pywal_colors_light ) <= 7 ):
132
128
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 ),)
129
+ c = scale_saturation (colors_best [str_x ],1 )
130
+ c = lighteen_color (c ,.2 ,tones_neutral [99 ])
131
+ pywal_colors_light += (blend2contrast (c , pywal_colors_light [0 ], tones_neutral [10 ], 4.5 , .01 , False ),)
135
132
else :
136
133
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 ),)
134
+ c = scale_saturation (tones_primary [tone ],1 )
135
+ pywal_colors_light += (blend2contrast (c , pywal_colors_light [0 ], tones_neutral [10 ], 4.5 , .01 , False ),)
139
136
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 ),)
137
+ c = scale_saturation (tones_tertiary [tone ],1 )
138
+ pywal_colors_light += (blend2contrast (c , pywal_colors_light [0 ], tones_neutral [10 ], 4.5 , .01 , False ),)
142
139
if tone < 91 :
143
140
tone += 8
144
141
else :
@@ -149,11 +146,14 @@ def __init__(self, colors, wallpaper_data, light_blend_multiplier=1, dark_blend_
149
146
sorted_colors = sort_colors_luminance (all ,True )[- 7 :]
150
147
151
148
for n in range (len (sorted_colors )):
152
- pywal_colors_light_intense += (sorted_colors [n ],)
153
149
pywal_colors_light += (blendColors (
154
- tones_neutral [30 ], sorted_colors [n ], .8 * lbm ),)
150
+ tones_neutral [38 ], sorted_colors [n ], .8 * lbm ),)
151
+
152
+ pywal_colors_light_intense += (blendColors (
153
+ tones_neutral [33 ], sorted_colors [n ], .8 * lbm ),)
154
+
155
155
pywal_colors_light_faint += (blendColors (
156
- tones_neutral [60 ], sorted_colors [n ], .8 * lbm ),)
156
+ tones_neutral [23 ], sorted_colors [n ], .8 * lbm ),)
157
157
158
158
159
159
# print("CONTRAST CHECK DARK")
@@ -176,7 +176,7 @@ def __init__(self, colors, wallpaper_data, light_blend_multiplier=1, dark_blend_
176
176
IntensityEffect=2
177
177
178
178
[ColorEffects:Inactive]
179
- ChangeSelectionColor=false
179
+ ChangeSelectionColor=true
180
180
Color={ colors_light ['surfaceVariant' ]}
181
181
ColorAmount=0.025
182
182
ColorEffect=2
@@ -275,7 +275,7 @@ def __init__(self, colors, wallpaper_data, light_blend_multiplier=1, dark_blend_
275
275
BackgroundNormal={ extras ['SurfaceLight' ]}
276
276
DecorationFocus={ colors_light ['primary' ]}
277
277
#-----------------------------------------------
278
- DecorationHover={ colors_light [ 'primary ' ]}
278
+ DecorationHover={ extras [ 'LightSelectionHover ' ]}
279
279
ForegroundActive={ colors_light ['inverseSurface' ]}
280
280
ForegroundInactive={ colors_light ['outline' ]}
281
281
ForegroundLink={ extras ['LinkOnSurfaceDark' ]}
@@ -327,7 +327,7 @@ def __init__(self, colors, wallpaper_data, light_blend_multiplier=1, dark_blend_
327
327
IntensityEffect=2
328
328
329
329
[ColorEffects:Inactive]
330
- ChangeSelectionColor=false
330
+ ChangeSelectionColor=true
331
331
Color=Color={ colors_dark ['surfaceVariant' ]}
332
332
ColorAmount=0.025
333
333
ColorEffect=2
@@ -428,7 +428,7 @@ def __init__(self, colors, wallpaper_data, light_blend_multiplier=1, dark_blend_
428
428
BackgroundNormal={ extras ['SurfaceDark' ]}
429
429
DecorationFocus={ colors_dark ['primary' ]}
430
430
#-----------------------------------------------
431
- DecorationHover={ colors_dark ['primary ' ]}
431
+ DecorationHover={ colors_dark ['inversePrimary ' ]}
432
432
ForegroundActive={ colors_dark ['inverseSurface' ]}
433
433
ForegroundInactive={ colors_dark ['outline' ]}
434
434
ForegroundLink={ extras ['LinkOnSurfaceDark' ]}
0 commit comments