Skip to main content

Module contrast

Module contrast 

Source
Expand description

Contrast ratios between tones, and tones that reach a given ratio.

The safe functions return None where upstream returns -1.

Functionsยง

darker
A tone at least as dark as tone that reaches ratio, if one exists.
darker_unsafe
darker, or 0 when ratio cannot be reached.
lighter
A tone at least as light as tone that reaches ratio, if one exists.
lighter_unsafe
lighter, or 100 when ratio cannot be reached.
ratio_of_tones
The contrast ratio of two tones, from 1 to 21. Tones are clamped to 0..=100.
ratio_of_ys
The contrast ratio of two relative luminances.