diff --git a/build.js b/build.js index 52d1ff6de..50fbe5832 100644 --- a/build.js +++ b/build.js @@ -15,7 +15,12 @@ for (var i = 0; i < source.icons.length; i++) { var max = Math.max(red, green, blue); var min = Math.min(red, green, blue); var delta = max - min; - source.icons[i].luminance = 100 * (max - min) / 2; + 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; } else { @@ -51,6 +56,13 @@ for (var i = 0; i < source.icons.length; i++) { i--; } } +for (var i = 0; i < source.icons.length; i++) { + if (source.icons[i].saturation < 5) { + tmp.push(source.icons[i]); + source.icons.splice(i,1); + i--; + } +} tmp.sort(function(a, b) { return parseFloat(b.luminance) - parseFloat(a.luminance); }); @@ -82,7 +94,7 @@ for (var i = 0; i < source.icons.length; i++) { filePath = filePath.replace('.', ''); filePath = filePath.replace('+', 'plus'); filePath = "./icons/" + filePath + ".svg"; - console.log(source.icons[i].title + ", lum = " + source.icons[i].luminance); + console.log(source.icons[i].title + ", sat = " + source.icons[i].saturation); var fs = require('fs'); var svg = fs.readFileSync(filePath, 'utf8'); main += "\t\t\t
  • " + svg + source.icons[i].title + "
    #" + source.icons[i].hex + "
  • \n"; diff --git a/index.html b/index.html index c37f9d9fe..4c1d76764 100644 --- a/index.html +++ b/index.html @@ -136,6 +136,8 @@