contrast-ratio-checker
Version:
A package based on WCAG 2.0 to easily check contrast ratio.
20 lines (19 loc) • 939 B
TypeScript
import { IWcagValidation, IRgb, IValidationOptions } from "./types";
export declare class ContrastRatioChecker {
private PX_TO_PT_RATIO;
constructor();
private isValidHex;
private getFullHex;
private separateStringPerCharGroup;
private convertHexToRgb;
private getRelativeLuminanceComponent;
getLuminance(rgb: IRgb): number;
getContrastRatioByLuminance(l1: number, l2: number): number;
getContrastRatioByRgb(rgb1: IRgb, rgb2: IRgb): number;
getContrastRatioByHex(hex1: string, hex2: string): number;
private getWcagLargeTextValidation;
private getCustomRatioValidation;
getWcagRatioValidation(ratio: number, fontSizePx?: number, bold?: Boolean): IWcagValidation;
getRatioValidationByRgb(rgb1: IRgb, rgb2: IRgb, options?: IValidationOptions | null): IWcagValidation;
getRatioValidationByHex(hex1: string, hex2: string, options?: IValidationOptions | null): IWcagValidation;
}