(hex)
| 456 | /** Der Abstand zweier Farben, so wie der Lauf ihn rechnet. */ |
| 457 | function colorDistance(first, second) { |
| 458 | const parse = (hex) => [ |
| 459 | parseInt(hex.slice(1, 3), 16), |
| 460 | parseInt(hex.slice(3, 5), 16), |
| 461 | parseInt(hex.slice(5, 7), 16), |
| 462 | ]; |
| 463 | const normalise = (rgb) => { |
| 464 | const top = Math.max(...rgb); |
| 465 | return top <= 0 ? [0, 0, 0] : rgb.map((value) => (value * 255) / top); |