best_text_color
Picks black or white text, whichever contrasts more with background.
Compares the WCAG contrast_ratio of both and returns the winner
(black on a tie), so the text stays as readable as it can be without you choosing a color per
background by hand.
Import
Section titled “Import”Cargo feature color (enabled by default). To compile only this module:
or in Cargo.toml:
Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
background | Rgb | The color the text will sit on. |
Returns
Section titled “Returns”Rgb — Black (#000000) or white (#ffffff).
