Contrast

Color science for contrast utilities.

Utility methods for calculating contrast given two colors, or calculating a color given one color and a contrast ratio.

Contrast ratio is calculated using XYZ's Y. When linearized to match human perception, Y becomes HCT's tone and L*a*b*'s' L*.

Properties

Link copied to clipboard
val RATIO_30: Double = 3.0
Link copied to clipboard
val RATIO_45: Double = 4.5
Link copied to clipboard
val RATIO_70: Double = 7.0
Link copied to clipboard
val RATIO_MAX: Double = 21.0
Link copied to clipboard
val RATIO_MIN: Double = 1.0

Functions

Link copied to clipboard
open fun darker(tone: Double, ratio: Double): Double
Returns T in HCT, L* in L*a*b* <= tone parameter that ensures ratio with input T/L*.
Link copied to clipboard
open fun darkerUnsafe(tone: Double, ratio: Double): Double
Tone <= tone parameter that ensures ratio.
Link copied to clipboard
open fun lighter(tone: Double, ratio: Double): Double
Returns T in HCT, L* in L*a*b* >= tone parameter that ensures ratio with input T/L*.
Link copied to clipboard
open fun lighterUnsafe(tone: Double, ratio: Double): Double
Tone >= tone parameter that ensures ratio.
Link copied to clipboard
open fun ratioOfTones(t1: Double, t2: Double): Double
Contrast ratio of two tones.
Link copied to clipboard
open fun ratioOfYs(y1: Double, y2: Double): Double
Contrast ratio is a measure of legibility, its used to compare the lightness of two colors.