MCPcopy Create free account
hub / github.com/devforth/painterro / HexToRGB

Function HexToRGB

js/colorPicker.js:4–21  ·  view source on GitHub ↗
(hex)

Source from the content-addressed store, hash-verified

2import { KEYS } from './utils';
3
4export function HexToRGB(hex) {
5 let parse = /^#?([a-fA-F\d]{2})([a-fA-F\d]{2})([a-fA-F\d]{2})$/i.exec(hex);
6 if (parse) {
7 return {
8 r: parseInt(parse[1], 16),
9 g: parseInt(parse[2], 16),
10 b: parseInt(parse[3], 16),
11 };
12 }
13 parse = /^#?([a-fA-F\d])([a-fA-F\d])([a-fA-F\d])$/i.exec(hex);
14 if (parse) {
15 return {
16 r: parseInt(parse[1].repeat(2), 16),
17 g: parseInt(parse[2].repeat(2), 16),
18 b: parseInt(parse[3].repeat(2), 16),
19 };
20 }
21}
22
23export function HexToRGBA(hex, alpha) {
24 const rgb = HexToRGB(hex);

Callers 5

constructorMethod · 0.90
paintAtMethod · 0.90
floodFillMethod · 0.90
HexToRGBAFunction · 0.85
reversedColorFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…