1
0
mirror of https://github.com/simple-icons/simple-icons.git synced 2024-12-16 01:10:30 +02:00

Fixed divide by zero issue

This commit is contained in:
Dan Leech 2015-10-16 15:43:13 +01:00
parent f1662ea440
commit d8eee12f69

View File

@ -16,14 +16,15 @@ for (var i = 0; i < source.icons.length; i++) {
var min = Math.min(red, green, blue);
var delta = max - min;
source.icons[i].luminance = 100 * (max + min) / 2;
if (source.icons[i].luminance < 50) {
source.icons[i].saturation = 100 * (max - min) / (max + min);
} else {
source.icons[i].saturation = 100 * (max - min) / (2 - max - min);
}
if (delta === 0) {
var hue = 0;
source.icons[i].saturation = 0;
} else {
if (source.icons[i].luminance < 50) {
source.icons[i].saturation = 100 * (max - min) / (max + min);
} else {
source.icons[i].saturation = 100 * (max - min) / (2 - max - min);
}
if (max === red) {
var hue = ((green - blue) / delta) * 60;
if (hue < 0) {