Created
April 5, 2024 17:22
-
-
Save wraithgar/d563ee1d530c7b50e1a1539d978ca454 to your computer and use it in GitHub Desktop.
3-4 bit and 256-color ansi output
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
console.log('3-4 bit:') | |
const lows = [] | |
for (let c = 30;c<=37;c++) { | |
lows.push(`\x1b[${c}m${c}\x1b[0m`) | |
} | |
console.log(lows.join(' ')) | |
console.log('256 color:') | |
let mediums = [] | |
for (let c = 0;c<=231;c++) { | |
if (!(c % 16)) { // new row | |
if (mediums.length) { | |
console.log(mediums.join(' ')) | |
} | |
mediums.length = 0 | |
} | |
mediums.push(`\x1b[38;5;${c}m${c}\x1b[0m`) | |
} | |
console.log(mediums.join(' ')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment