x256
find the nearest xterm 256 color index for an rgb
Last updated 13 years ago by substack .
MIT · Repository · Original npm · Tarball · package.json
$ npm install x256 
SYNC missed versions from official npm registry.

x256

return the nearest xterm 256 color code for rgb inputs.

testling badge

build status

example

You can just print the index:

var x256 = require('x256');
var ix = x256(220,40,150);
console.log(ix);

output:

162

or you can use raw ansi escape codes:

var x256 = require('x256');
var ix = x256(220,40,150);
console.log('\x1b[38;5;' + ix + 'mBEEEEEP');

output:

x256 raw beep

or you can use charm:

var x256 = require('x256');
var charm = require('charm')(process.stdout);

var ix = x256(220,40,150);
charm.foreground(ix).write('beep boop');

output:

x256 charm beep boop

methods

var x256 = require('x256')

x256(red, green, blue)

Return the nearest xterm 256 color code for the 24-bit [red, green, blue] values.

red, green, and blue should each be integers from 0 through 255, inclusive.

attributes

x256.colors

array of [red,green,blue] 24-bit color arrays indexed by xterm 256 color code

install

With npm do:

npm install x256

license

MIT

Current Tags

  • 0.0.2                                ...           latest (10 years ago)

3 Versions

  • 0.0.2                                ...           10 years ago
  • 0.0.1                                ...           13 years ago
  • 0.0.0                                ...           13 years ago
Maintainers (1)
Downloads
Total 2
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 1
Last Month 0
Dependencies (0)
None
Dev Dependencies (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE