MCPcopy Create free account
hub / github.com/DavidHDev/react-bits / hexToRGB

Function hexToRGB

src/content/Backgrounds/Lightfall/Lightfall.jsx:7–13  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5const MAX_COLORS = 8;
6
7const hexToRGB = hex => {
8 const c = hex.replace('#', '').padEnd(6, '0');
9 const r = parseInt(c.slice(0, 2), 16) / 255;
10 const g = parseInt(c.slice(2, 4), 16) / 255;
11 const b = parseInt(c.slice(4, 6), 16) / 255;
12 return [r, g, b];
13};
14
15const prepColors = input => {
16 const base = (input && input.length ? input : ['#A6C8FF', '#5227FF', '#FF9FFC']).slice(0, MAX_COLORS);

Callers 2

prepColorsFunction · 0.70
LightfallFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected