rgbToHex
Converts an RGB(A) color into a hex color string.
r/g/b are clamped to 0-255 and rounded to the nearest integer before
formatting. The alpha channel is only appended (as #rrggbbaa) when it is
below 1 — fully opaque colors format as the plain 6-digit #rrggbb.
Available since v3.0.0
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
color | RgbColor | The color to convert. `a` defaults to 1 (opaque) when omitted. |
Returns
Section titled “Returns”string — A lowercase hex color string
Examples
Section titled “Examples”Format an opaque color as hex
Section titled “Format an opaque color as hex”Alpha defaults to 1 (opaque) and is omitted from the output.
Include alpha when the color is translucent
Section titled “Include alpha when the color is translucent”A non-opaque color formats as an 8-digit #rrggbbaa string.
Related Types
Section titled “Related Types”RgbColor
Section titled “RgbColor”An RGB(A) color with channels expressed as plain numbers, convenient for further conversion or manipulation.
