MCPcopy
hub / github.com/omgovich/colord / rgbaToHex

Function rgbaToHex

src/colorModels/hex.ts:43–47  ·  view source on GitHub ↗
(rgba: RgbaColor)

Source from the content-addressed store, hash-verified

41
42/** Converts RGBA object to Hex6 or (if it has alpha channel) Hex8 string */
43export const rgbaToHex = (rgba: RgbaColor): string => {
44 const { r, g, b, a } = roundRgba(rgba);
45 const alphaHex = a < 1 ? format(round(a * 255)) : "";
46 return "#" + format(r) + format(g) + format(b) + alphaHex;
47};

Callers 1

toHexMethod · 0.90

Calls 3

roundRgbaFunction · 0.90
roundFunction · 0.90
formatFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…