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

color2xterm

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

color2xterm

Change hex or rgb color to xterm (8-bit) color.

  • 1.0.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
7
increased by133.33%
Maintainers
1
Weekly downloads
 
Created
Source

color2xterm by @michalbe

Change hex or rgb color to xterm (8-bit) color.

What?

Change hex or rgb color to xterm colors (one of the 256 basic 8-bit colors). Code is based on Python colortrans.py script by Micah Elliott.

API

This library has only two methods:

  • hex2xterm(hex_color): convert given hex color (with or without # sign) to the xterm color. If there is no exact match, search for the closest one.
  • rgb2xterm(r, g, b): convert given rgb color (passed tot he method as 3 separate parameters) to the xterm color. If there is no exact match, search for the closest one.

How to use?

Install simply with: bash npm install color2xterm


Then in your code:
```javascript
var c2xterm = require('color2xterm');

c2xterm.hex2xterm('#ffffff'); // result: 15
c2xterm.rgb2xterm(255, 255, 255); // result: 15

// Find closest color:
c2xterm.hex2xterm('#0DADD6'); // closest color is #00AFD7 so the result is 38

Color table

colors stolen from Wikimedia

FAQs

Package last updated on 24 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