Giter VIP home page Giter VIP logo

rgb2xterm's Introduction

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:

npm install color2xterm

Then in your code:

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

rgb2xterm's People

Contributors

michalbe avatar wilt00 avatar

Stargazers

Gabriel Celis avatar Lsong avatar Coleman Gariety avatar Angus H. avatar  avatar

Watchers

 avatar James Cloos avatar  avatar

Forkers

wilt00

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.