File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -188,11 +188,19 @@ def _calc_new_hex_from_theme_hex_and_tint(theme_hex, color_tint):
188188 color_obj .luminance = _calc_lum_from_tint (color_tint , color_obj .luminance )
189189 return color_obj .hex_l [1 :]
190190
191- def _calc_lum_from_tint (color_tint , current_lum ):
192- # based on http://ciintelligence.blogspot.co.il/2012/02/converting-excel-theme-color-and-tint.html
193- if not color_tint :
191+ def _calc_lum_from_tint (color_tint : Optional [float ], current_lum : float ) -> float :
192+ """"
193+ Based on https://ciintelligence.blogspot.co.il/2012/02/converting-excel-theme-color-and-tint.html
194+ """
195+ if color_tint is None :
194196 return current_lum
195- return current_lum * (1.0 + color_tint )
197+
198+ current_lum *= 255
199+
200+ if color_tint < 0 :
201+ return current_lum * (1.0 + color_tint ) / 255
202+
203+ return (current_lum * (1.0 - color_tint ) + (255 - 255 * (1.0 - color_tint ))) / 255
196204
197205 bg_color = openpyxl_style .fill .fgColor .rgb
198206
You can’t perform that action at this time.
0 commit comments