Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

term-colors

Convert modern color formats (rgb, hex, hsl) to ANSI and back again.

This is not a tool for printing colors in your terminal -- it is meant for conversion. For writing stdout with ANSI colors, use cli-color, colors, or chalk.

Test

npm test

API

Pop open a REPL and require term-colors.

var color = require('term-colors');

Convert any format to ansi.

color('red').ansi();          // 09

color('#f00').ansi();         // 09

color('rgb(255,0,0)').ansi(); // 09

Manipulate the values using the color api. Output with #ansi().

color('green');         // 28

color.negate();         // 213

color.lighten(0.1);     // 219
color.darken(0.1);      // 213

color.saturate(10);     // 216
color.mix(color('red'); // 202

Convert to other formats if you want

color().rgb(); // { r: 255, g: 0, b: 0 }

color().hsl(); // { h: 0, s: 100, l: 50 }

License

MIT

About

Color conversion for the terminal

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.