Skip to main content

readable_on

Function readable_on 

Source
pub fn readable_on(bg: Color) -> Color
Expand description

Black or white, whichever a reader can see on bg.

The split is at Color::luminance 0.4 rather than at the midpoint: white text needs a darker background than black text needs a light one, and the accents that land near the line (macOS’s yellow at 0.72, its orange at 0.44) come out the way the platform paints them. It is the stock button’s answer, not a general contrast checker — a palette that cares should say what its label colour is.