diff --git a/.gitignore b/.gitignore index c91b435b..f101a998 100644 --- a/.gitignore +++ b/.gitignore @@ -34,4 +34,33 @@ .Spotlight-V100 .Trashes ehthumbs.db -Thumbs.db \ No newline at end of file +Thumbs.db + +# Logs +logs +*.log +npm-debug.log* + +# Runtime data +pids +*.pid +*.seed + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directory +# https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git +node_modules \ No newline at end of file diff --git a/CNAME b/CNAME new file mode 100644 index 00000000..de53684e --- /dev/null +++ b/CNAME @@ -0,0 +1 @@ +simpleicons.org diff --git a/README.md b/README.md new file mode 100644 index 00000000..a9c0c007 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# Simple Icons + +SVG icons for popular brands. https://simpleicons.org \ No newline at end of file diff --git a/build.js b/build.js new file mode 100644 index 00000000..85ff33ad --- /dev/null +++ b/build.js @@ -0,0 +1,112 @@ +// Get JSON from source file +var source = require('./simple-icons.json'); + +// Loop through icons +for (var i = 0; i < source.icons.length; i++) { + + var hex = source.icons[i].hex; + + // Add red, green and blue values to the JSON object + var red = parseInt(hex.substr(0,2), 16) / 255; + var green = parseInt(hex.substr(2,2), 16) / 255; + var blue = parseInt(hex.substr(4,2), 16) / 255; + + // Add hue to the JSON object + 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; + 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) { + hue += 360; + } + } else if (max === green) { + var hue = (((blue - red) / delta) + 2) * 60; + } else { + var hue = (((red - green) / delta) + 4) * 60; + } + } + source.icons[i].hue = hue; +} + +// Sort icons by hue + +// Ensures blue icons appear first in the last, purple ones last +for (var i = 0; i < source.icons.length; i++) { + source.icons[i].hue += 100; + source.icons[i].hue = source.icons[i].hue % 360; +} +source.icons.sort(function(a, b) { + return parseFloat(b.hue) - parseFloat(a.hue); +}); +var tmp = []; +for (var i = 0; i < source.icons.length; i++) { + if (source.icons[i].luminance < 10) { + tmp.push(source.icons[i]); + source.icons.splice(i,1); + 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); +}); +for (var i = 0; i < tmp.length; i++) { + source.icons.push(tmp[i]); +} +console.log(tmp); + +// Read header and footer content into variables +var fs = require('fs'); +function readFile(path, callback) { + try { + var filename = require.resolve(path); + fs.readFile(filename, 'utf8', callback); + } catch (e) { + callback(e); + } +} +var fs = require('fs'); +var header = fs.readFileSync('./src/header.html', 'utf8'); +var footer = fs.readFileSync('./src/footer.html', 'utf8'); + +// Build content +var main = "

" + source.icons.length + " SVG icons for popular brands Download them from GitHub

\n + + + + + \ No newline at end of file diff --git a/src/header.html b/src/header.html new file mode 100644 index 00000000..afc9bcb5 --- /dev/null +++ b/src/header.html @@ -0,0 +1,156 @@ + + + + + + Simple Icons + + + + + + +