Skip to content

Instantly share code, notes, and snippets.

@eiszfuchs
Created September 24, 2015 06:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eiszfuchs/587915d7d1a9372f625b to your computer and use it in GitHub Desktop.
Save eiszfuchs/587915d7d1a9372f625b to your computer and use it in GitHub Desktop.
var reset = ["0"];
var resetGround = ["49"];
var frontColors = ["30", "1;30", "31", "1;31", "32", "1;32", "33", "1;33", "34", "1;34", "35", "1;35", "36", "1;36", "37", "1;37"];
var groundColors = ["", "40", "41", "42", "43", "44", "45", "46", "47"];
var cellContent = " cWy "
var spaceFill = function (caption, length) {
while (caption.length < length) {
caption = " " + caption;
}
return caption;
};
var buildEscape = function (attributes) {
return "\u001b[" + attributes.filter(function (value) {
return !!value;
}).join(";") + "m";
};
var resultPrint = "\r\n" + " ".repeat(4);
groundColors.forEach(function (groundColor) {
resultPrint += spaceFill(groundColor, cellContent.length + 1);
});
resultPrint += "\r\n";
frontColors.forEach(function (frontColor) {
resultPrint += spaceFill(frontColor, 5) + " ";
groundColors.forEach(function (groundColor) {
resultPrint += buildEscape([frontColor, groundColor]) + cellContent;
resultPrint += buildEscape(resetGround) + " ";
});
resultPrint += buildEscape(reset) + "\r\n";
});
console.log(resultPrint);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment