Contrast

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

Static Methods

Darker(tone: double, ratio: double): double
Returns a tone <= tone that ensures ratio. Returns -1 if ratio cannot be achieved.
DarkerUnsafe(tone: double, ratio: double): double
Unsafe darker version. Returns 0 if ratio cannot be achieved.
Lighter(tone: double, ratio: double): double
Returns a tone >= tone that ensures ratio. Returns -1 if ratio cannot be achieved.
LighterUnsafe(tone: double, ratio: double): double
Unsafe lighter version. Returns 100 if ratio cannot be achieved.
RatioOfTones(toneA: double, toneB: double): double
Returns a contrast ratio, which ranges from 1 to 21.

Inherited Members

On this page