Skip to content

Instantly share code, notes, and snippets.

@passcod
Created Oct 31, 2012
Embed
What would you like to do?
woot color2
/* Source: */
String.prototype.color2 = function(fg,bg) {
var conv = function(thing, _default) {
if (+thing < 16 && +thing > -1) { return +thing; }
thing = "white black blue green red brown purple orange yellow lime teal cyan royal pink grey silver".split(" ").indexOf(thing);
if (thing != -1) { return thing; }
return _default;
};
fg = conv(fg, 2);
bg = conv(bg, "");
bg = bg && ","+bg;
return "\x03" + fg + bg + this + "\x0F";
};
/* Minified: */
String.prototype.color2=function(d,b){function c(a,b){if(16>+a&&-1<+a)return+a;a="white black blue green red brown purple orange yellow lime teal cyan royal pink grey silver".split(" ").indexOf(a);return-1!=a?a:b}b=c(b,"");return"\x03"+c(d,2)+(b&&","+b)+this+"\x0f"};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment