Skip to content

mndvns/term-colors

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

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

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published