(hex)
| 540 | } |
| 541 | |
| 542 | function HexToHSB(hex) { |
| 543 | hex = hex.replace(/^#/, ""); |
| 544 | hex = hex.length === 3 ? hex.replace(/(.)/g, "$1$1") : hex; |
| 545 | |
| 546 | var red = parseInt(hex.substr(0, 2), 16) / 255, |
| 547 | green = parseInt(hex.substr(2, 2), 16) / 255, |
| 548 | blue = parseInt(hex.substr(4, 2), 16) / 255; |
| 549 | |
| 550 | var cMax = Math.max(red, green, blue), |
| 551 | delta = cMax - Math.min(red, green, blue), |
| 552 | saturation = cMax ? delta / cMax : 0; |
| 553 | |
| 554 | switch (cMax) { |
| 555 | case red: |
| 556 | return [60 * (((green - blue) / delta) % 6) || 0, saturation, cMax]; |
| 557 | case green: |
| 558 | return [60 * ((blue - red) / delta + 2) || 0, saturation, cMax]; |
| 559 | case blue: |
| 560 | return [60 * ((red - green) / delta + 4) || 0, saturation, cMax]; |
| 561 | } |
| 562 | } |
| 563 | |
| 564 | function HSVtoHSL(hsv) { |
| 565 | var h = hsv[0], |
no outgoing calls
no test coverage detected
searching dependent graphs…