firstWithContrast

fun Color.firstWithContrast(vararg colors: Color, targetContrast: Float): Color

Return the first color with a contrast ratio exceeding the targetContrast against this color. If no color meets the target, black or white will be returned, whichever has the most contrast.

This implements the color-contrast functionality specified in the CSS Color 5 Spec