(hex)
| 1447 | } )(); |
| 1448 | |
| 1449 | function hexToRgb(hex){ |
| 1450 | // By Tim Down - http://stackoverflow.com/a/5624139/3493650 |
| 1451 | // Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF") |
| 1452 | var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i; |
| 1453 | hex = hex.replace(shorthandRegex, function(m, r, g, b) { |
| 1454 | return r + r + g + g + b + b; |
| 1455 | }); |
| 1456 | var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex); |
| 1457 | return result ? { |
| 1458 | r: parseInt(result[1], 16), |
| 1459 | g: parseInt(result[2], 16), |
| 1460 | b: parseInt(result[3], 16) |
| 1461 | } : null; |
| 1462 | }; |
| 1463 | |
| 1464 | function clamp(number, min, max) { |
| 1465 | return Math.min(Math.max(number, min), max); |
no outgoing calls
no test coverage detected
searching dependent graphs…