(a, b)
| 50 | // Distance between 2 colors (in RGB) |
| 51 | // https://stackoverflow.com/questions/23990802/find-nearest-color-from-a-colors-list |
| 52 | function distance(a, b) { |
| 53 | return Math.sqrt(Math.pow(a.r - b.r, 2) + Math.pow(a.g - b.g, 2) + Math.pow(a.b - b.b, 2)); |
| 54 | } |
| 55 | |
| 56 | // return nearest color from array |
| 57 | function nearestColor(target) { |