Skip to content

Instantly share code, notes, and snippets.

@kindziora
Created January 23, 2017 22:22
Show Gist options
  • Save kindziora/803c04ad63855e553e9652043f8ecd13 to your computer and use it in GitHub Desktop.
Save kindziora/803c04ad63855e553e9652043f8ecd13 to your computer and use it in GitHub Desktop.
colors.js
var cc = ['#804080',
'#800000',
'#808080',
'#0000C0',
'#808000',
'#400080',
'#C0C000',
'#40C000',
'#4080C0',
'#C0C080',
'#404080',
'#C080C0',
'#404000',
'#004040',
'#C08080',
'#C04080',
'#C000C0',
'#0080C0'];
function hexToRgb(hex) {
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
return result ? [
parseInt(result[1], 16),
parseInt(result[2], 16),
parseInt(result[3], 16)
] : null;
}
var rgb = [];
var old = ["120 72 120",
"72 72 72",
"0 0 0",
"72 120 168",
"96 144 24",
"96 96 144",
"0 0 144",
"240 24 240",
"96 120 48",
"72 96 48"];
cc.forEach(function(v) {
rgb.push(hexToRgb(v).join(" "));
});
var existing = old.filter(function(c) {
console.log(c)
return rgb.indexOf(c) !== -1;
});
console.log(existing);
console.log(rgb.join('\n'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment