Skip to content

Instantly share code, notes, and snippets.

@FlorianWendelborn
Created July 6, 2017 22:14
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 FlorianWendelborn/63e6909c682490cdd5b60e306cf14ea3 to your computer and use it in GitHub Desktop.
Save FlorianWendelborn/63e6909c682490cdd5b60e306cf14ea3 to your computer and use it in GitHub Desktop.
const WIDTH = 32
const fs = require('fs')
const chalk = require('chalk')
const hsl2rgb = require('pure-color/convert/hsl2rgb')
// const e = require('emoji.json')
const file = fs.readFileSync(process.argv[2])
file.forEach((char, index) => {
const rgb = hsl2rgb([char / 256 * 360, 100, 50]).map(i => Math.floor(i))
const hex = [char >> 4, char && 0x0f]
const string =
hex[0].toString(16).toUpperCase() +
hex[1].toString(16).toUpperCase() +
chalk.black.bgBlack(' ')
// const string = e[char].char + ' '
const result = chalk.black.bgRgb(rgb[0], rgb[1], rgb[2])(string)
process.stdout.write(result)
if (index % WIDTH === WIDTH - 1) console.log()
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment