⚖️ 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('white', 'black'); //=> 21 colorContrast('white', 'white'); //=> 1 colorContrast('red', 'white'); //=> 4