RGBtoHex

Color
stable

Convert an sRGB object to a hex colour string. Each channel is rounded to the nearest integer before encoding. The alpha component is appended only when defined.

API

Signature

Signature TypeScript complète, extraite du fichier util.

typescript

API

Paramètres

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

{r, g, b, a}
requis
TRGBA

API

Valeur de retour

La valeur retournée par cet util.

Uppercase hex colour string with leading "#". 7 characters for opaque colours (#RRGGBB), 9 characters when alpha is present (#RRGGBBAA).

Usage

Exemples

Extraits de code prêts à coller.

RGB to hex encoding

typescript