(hex)
| 69 | } |
| 70 | |
| 71 | function 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 | } |
no outgoing calls
no test coverage detected