Example:
// Get readable text color for a dark background
uint textColor = contrast(Colors.BLACK, Colors.DARK_BLUE);uint contrast(uint fg, uint bg) nothrow @nogcReturns a contrasting color.
Returns either white or black, depending on which provides better contrast against the background color. Useful for choosing text colors that will be readable on any background.
fg | Foreground color (used as hint, may be ignored) |
bg | Background color to contrast against |
Example:
// Get readable text color for a dark background
uint textColor = contrast(Colors.BLACK, Colors.DARK_BLUE);