colorContrast
⚖️ Calculates the contrast ratio between two colors.
Syntax
TypeScript
import { colorContrast } from '@opentf/std'; colorContrast({ color1: any; color2: any }): number
Returns a value between 1 and 21.
Examples
TypeScript
colorContrast({ color1: 'white', color2: 'black' }); //=> 21 colorContrast({ color1: 'white', color2: 'white' }); //=> 1 colorContrast({ color1: 'red', color2: 'white' }); //=> 4