Improved omitting bg colors

pull/201/head
M66B 4 years ago
parent 4928d02dd3
commit df447bb94d

@ -619,14 +619,12 @@ public class HtmlHelper {
if (color != null && view) if (color != null && view)
color = adjustColor(dark, textColorPrimary, color); color = adjustColor(dark, textColorPrimary, color);
} else { } else if (bg == Color.TRANSPARENT) {
// Check background/foreground luminance // Background color was suppressed because "no color"
if (color != null) { if (color != null) {
double lbg = ColorUtils.calculateLuminance(bg); double lum = ColorUtils.calculateLuminance(color);
double lfg = ColorUtils.calculateLuminance(color); if (dark ? lum < MIN_LUMINANCE : lum > 1 - MIN_LUMINANCE)
if (Math.abs(lbg - lfg) < 0.1) { color = textColorPrimary;
color = (lbg < 0.5 ? Color.WHITE : Color.BLACK);
}
} }
} }
@ -634,7 +632,7 @@ public class HtmlHelper {
element.attr("x-color", "true"); element.attr("x-color", "true");
} else /* background */ { } else /* background */ {
if (color != null && !hasColor(color)) if (color != null && !hasColor(color))
continue; color = Color.TRANSPARENT;
if (color != null) if (color != null)
element.attr("x-background", encodeWebColor(color)); element.attr("x-background", encodeWebColor(color));

Loading…
Cancel
Save