(hex)
| 2 | import { KEYS } from './utils'; |
| 3 | |
| 4 | export 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 | |
| 23 | export function HexToRGBA(hex, alpha) { |
| 24 | const rgb = HexToRGB(hex); |
no outgoing calls
no test coverage detected
searching dependent graphs…