add stronger guarantee of readability/contrast for palette background/text color pairs
This commit is contained in:
parent
31d1d5fecb
commit
c45c79b5d6
1 changed files with 10 additions and 2 deletions
|
|
@ -612,11 +612,19 @@ fn mix(a: Color, b: Color, factor: f32) -> Color {
|
||||||
|
|
||||||
fn readable(background: Color, text: Color) -> Color {
|
fn readable(background: Color, text: Color) -> Color {
|
||||||
if is_readable(background, text) {
|
if is_readable(background, text) {
|
||||||
text
|
return text;
|
||||||
} else if is_dark(background) {
|
}
|
||||||
|
|
||||||
|
let fallback = if is_dark(background) {
|
||||||
Color::WHITE
|
Color::WHITE
|
||||||
} else {
|
} else {
|
||||||
Color::BLACK
|
Color::BLACK
|
||||||
|
};
|
||||||
|
|
||||||
|
if is_readable(background, fallback) {
|
||||||
|
fallback
|
||||||
|
} else {
|
||||||
|
fallback.inverse()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue