Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

x256

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

x256

find the nearest xterm 256 color index for an rgb

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
90K
decreased by-2.87%
Maintainers
1
Weekly downloads
 
Created
Source

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

Keywords

FAQs

Package last updated on 01 Jul 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc