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 {
|
||||
if is_readable(background, text) {
|
||||
text
|
||||
} else if is_dark(background) {
|
||||
return text;
|
||||
}
|
||||
|
||||
let fallback = if is_dark(background) {
|
||||
Color::WHITE
|
||||
} else {
|
||||
Color::BLACK
|
||||
};
|
||||
|
||||
if is_readable(background, fallback) {
|
||||
fallback
|
||||
} else {
|
||||
fallback.inverse()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue