hasEnoughContrast

fun Color.hasEnoughContrast(other: Color, threshold: ContrastThreshold = ContrastThreshold.WCAG_AA_NORMAL_TEXT): Boolean

Check if the contrast ratio between two colors is greater than or equal to a given threshold.

Learn more about WCAG here.

Receiver

The first Color to compare.

Return

true if the contrast ratio is greater than or equal to the threshold, false otherwise.

Parameters

other

The second Color to compare.

threshold

The threshold to compare the contrast ratio against.