MCPcopy Create free account
hub / github.com/bernaferrari/FigmaToCode / rgbTo6hex

Function rgbTo6hex

packages/backend/src/common/color.ts:5–12  ·  view source on GitHub ↗
(color: RGB | RGBA)

Source from the content-addressed store, hash-verified

3
4// ---- Color Format Conversion ----
5export const rgbTo6hex = (color: RGB | RGBA): string => {
6 const hex =
7 ((color.r * 255) | (1 << 8)).toString(16).slice(1) +
8 ((color.g * 255) | (1 << 8)).toString(16).slice(1) +
9 ((color.b * 255) | (1 << 8)).toString(16).slice(1);
10
11 return hex;
12};
13
14export const rgbTo8hex = (color: RGB, alpha: number): string => {
15 // when color is RGBA, alpha is set automatically

Callers 6

getColorInfoFunction · 0.90
convertSolidColorFunction · 0.90
getTextStylesMethod · 0.90
composeColorFunction · 0.90
rgbaToHexFunction · 0.90
generateBorderModifierFunction · 0.90

Calls 1

toStringMethod · 0.80

Tested by

no test coverage detected