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

Full TypeScript signature sourced from the util file.

typescript

API

Parameters

Input parameters accepted by this util.

{r, g, b, a}
required
TRGBA

API

Return value

The value returned by this util.

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

Usage

Examples

Ready-to-paste usage snippets.

RGB to hex encoding

typescript