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 Lab*'s' L*.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
darker(
double tone, double ratio) → double? - Returns T in HCT, L* in Lab* <= tone parameter that ensures ratio with input T/L*. Returns null if ratio cannot be achieved.
-
darkerUnsafe(
double tone, double ratio) → double - Tone <= tone parameter that ensures ratio. 0 if ratio cannot be achieved.
-
lighter(
double tone, double ratio) → double? - Returns T in HCT, L* in Lab* >= tone parameter that ensures ratio with input T/L*. Returns null if ratio cannot be achieved.
-
lighterUnsafe(
double tone, double ratio) → double - Tone >= tone parameter that ensures ratio. 100 if ratio cannot be achieved.
-
ratioOfTones(
double t1, double t2) → double - Contrast ratio of two tones. T in HCT, L* in Lab*. Also known as luminance or perpectual luminance.
-
ratioOfYs(
double y1, double y2) → double - Contrast ratio is a measure of legibility, its used to compare the lightness of two colors. This method is used commonly in industry due to its use by WCAG.
Constants
- ratio30 → const double
- ratio45 → const double
- ratio70 → const double
- ratioMax → const double
- The maximum contrast ratio of two colors. Contrast ratio equation = (lighter + 5) / (darker + 5). If lighter == 100 and darker = 0, ratio == 21.
- ratioMin → const double
- The minimum contrast ratio of two colors. Contrast ratio equation = (lighter + 5) / (darker + 5). If lighter == darker, ratio == 1.