Skip to content

Instantly share code, notes, and snippets.

@wraithgar
Created April 5, 2024 17:22
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 wraithgar/d563ee1d530c7b50e1a1539d978ca454 to your computer and use it in GitHub Desktop.
Save wraithgar/d563ee1d530c7b50e1a1539d978ca454 to your computer and use it in GitHub Desktop.
3-4 bit and 256-color ansi output
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