0
Fork 0
mirror of https://github.com/penpot/penpot-exporter-figma-plugin.git synced 2024-12-22 05:33:02 -05:00
penpot-exporter-figma-plugin/plugin-src/utils/rgbToHex.ts
2024-04-12 18:52:19 +02:00

7 lines
265 B
TypeScript

export const rgbToHex = (color: RGB) => {
const r = Math.round(255 * color.r);
const g = Math.round(255 * color.g);
const b = Math.round(255 * color.b);
const rgb = (r << 16) | (g << 8) | (b << 0);
return '#' + (0x1000000 + rgb).toString(16).slice(1);
};