APCAcontrast

Color
stable

Compute the APCA (Accessible Perceptual Contrast Algorithm) contrast value between a text colour and a background colour. Returns a signed float in the range [-108, 106] — positive for dark text on light background, negative for light text on dark background.

API

Signature

Signature TypeScript complète, extraite du fichier util.

typescript

API

Paramètres

Paramètres d'entrée acceptés par cet util.

text
requis
TRGBA
The foreground (text) colour as an RGBA object with r, g, b in [0, 255].
background
requis
TRGBA
The background colour as an RGBA object with r, g, b in [0, 255].

API

Valeur de retour

La valeur retournée par cet util.

Signed APCA contrast value. Absolute value >= 45 is the recommended minimum for body text.

Usage

Exemples

Extraits de code prêts à coller.

Black text on white background

typescript