MCPcopy Create free account
hub / github.com/adobe/react-spectrum / hexToRgb

Function hexToRgb

scripts/convertAnatomy.js:71–85  ·  view source on GitHub ↗
(hex)

Source from the content-addressed store, hash-verified

69}
70
71function hexToRgb(hex) {
72 var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
73 hex = hex.replace(shorthandRegex, function (m, r, g, b) {
74 return r + r + g + g + b + b;
75 });
76
77 var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
78 return result
79 ? {
80 r: parseInt(result[1], 16),
81 g: parseInt(result[2], 16),
82 b: parseInt(result[3], 16)
83 }
84 : null;
85}

Callers 2

convertAnatomy.jsFile · 0.85
nearestColorFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected