contrast

fnuint contrast(uint fg, uint bg) nothrow @nogc

Returns 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.

Parameters

fgForeground color (used as hint, may be ignored)
bgBackground color to contrast against

Returns

Contrasting color (typically white or black)

Example:

// Get readable text color for a dark background
uint textColor = contrast(Colors.BLACK, Colors.DARK_BLUE);