MCPcopy Create free account
hub / github.com/botbotrobotics/BotBrain / hexToRgb

Function hexToRgb

frontend/src/utils/theme-generator.ts:4–13  ·  view source on GitHub ↗

* Converts hex color to RGB

(hex: string)

Source from the content-addressed store, hash-verified

2 * Converts hex color to RGB
3 */
4function hexToRgb(hex: string): { r: number; g: number; b: number } | null {
5 const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
6 return result
7 ? {
8 r: parseInt(result[1], 16),
9 g: parseInt(result[2], 16),
10 b: parseInt(result[3], 16),
11 }
12 : null;
13}
14
15/**
16 * Converts RGB to HSL

Callers 1

generateThemeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected