MCPcopy Index your code
hub / github.com/figma/plugin-samples / rgbToHex

Function rgbToHex

styles-to-variables/code.js:93–101  ·  view source on GitHub ↗
({ r, g, b })

Source from the content-addressed store, hash-verified

91}
92
93function rgbToHex({ r, g, b }) {
94 const toHex = (value) => {
95 const hex = Math.round(value * 255).toString(16);
96 return hex.length === 1 ? "0" + hex : hex;
97 };
98
99 const hex = [toHex(r), toHex(g), toHex(b)].join("");
100 return `#${hex}`;
101}

Callers 1

styleToTokenDataMapFunction · 0.70

Calls 1

toHexFunction · 0.70

Tested by

no test coverage detected