Created
September 24, 2015 06:52
-
-
Save eiszfuchs/587915d7d1a9372f625b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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