MCPcopy Create free account
hub / github.com/alephdata/aleph / hexToRgb

Function hexToRgb

ui/src/util/reduceTranslucentColor.ts:3–15  ·  view source on GitHub ↗
(hex: string)

Source from the content-addressed store, hash-verified

1type RgbColor = { r: number; g: number; b: number };
2
3function hexToRgb(hex: string): null | RgbColor {
4 const matches = hex.match(/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i);
5
6 if (!matches) {
7 return null;
8 }
9
10 return {
11 r: parseInt(matches[1], 16),
12 g: parseInt(matches[2], 16),
13 b: parseInt(matches[3], 16),
14 };
15}
16
17function rgbToHex(rgb: RgbColor): string {
18 const hex = Object.values(rgb)

Callers 1

reduceTranslucentColorFunction · 0.85

Calls 1

matchMethod · 0.45

Tested by

no test coverage detected