npm install --save @thebespokepixel/trucolor
import {trucolor, palette, chalkish, simple} from 'trucolor'
const simpleColor = trucolor('bright red')
console.log(`${simpleColor.in}simpleColor${simpleColor.out}`)
const simplePalette = simple()
console.log(`${simplePalette.red}simplePalette Red${simplePalette.red.out}`)
console.log(`${simplePalette.blue}simplePalette Blue${simplePalette.blue.out}`)
const myPalette = palette({}, {
red: '#F00',
blue: 'lighten 30 blue'
})
console.log(`${myPalette.red}myPalette Red${myPalette.red.out}`)
console.log(`${myPalette.blue}myPalette Blue${myPalette.blue.out}`)
const myChalkishPalette = chalkish(palette({}, {
red: '#F00',
blue: 'lighten 30 blue'
}))
console.log(myChalkishPalette.red('myChalkishPalette Red'))
console.log(myChalkishPalette.blue('myChalkishPalette Blue'))
Color retreival API. Will return different values if called with a cli or sgr context.
Type: Trucolor
(string)
: Human readable color name.
(string)
: Opening SGR code
(string)
: Closing SGR code
(string)
: #RRGGBB Hexadecimal color value (or SGR reset name)
(string)
: 'rgb(red, green, blue)' CSS format (or SGR reset name)
(function)
: Returns a Hex code, SGR in code or CLI
arguments with formatting flags, depending on
format.
(function)
: Returns a graphic swatch of the color.
Create an SGR-aware color from a loose text definition.
Trucolor
:
A Trucolor instance.
Create a map of trucolor instances from a map of name/color values.
(Object)
Options to pass to trucolor creation.
(Object)
A map of name/color definitions.
Object
:
The resultant name/trucolor map.
Create a map of nestable functions, allowing color to be applied a-lá-chalk.
(Object)
A map of name/color definitions.
function
:
The resultant name/function map.
Create a simple, sharable palette
(Object)
Options to pass to trucolor creation.
Object
:
The resultant name/trucolor map.
{
white: '#BBB',
black: '#111',
red: '#B00',
green: '#0B0',
blue: '#44B',
cyan: '#0BB',
yellow: '#BB0',
magenta: '#B0B',
brightWhite: '#FFF',
brightRed: '#F33',
brightGreen: '#3F3',
brightBlue: '#44F',
brightCyan: '#3FF',
brightYellow: '#FF3',
brightMagenta: '#F3F',
dim: 'dim',
bold: 'bold',
italic: 'italic',
invert: 'invert',
example: '#CC99FF',
command: '#31A0FF',
argument: '#7DC3FF',
option: '#C1BA89',
operator: '#FFFFFF',
grey: '#808080',
title: 'bold #80C480',
normal: 'normal',
reset: 'reset'
}