Skip to content

sydev/colcon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

colcon

A simple to use color code converter. Supports RGB and HEX color formats.

Table of Contents

Installation

For programmatically usage install colcon locally:

npm install colcon --save

For global usage install it globally:

npm install colcon -g

Usage

To use colcon programmatically, add something like this in your code:

var colcon = require('colcon');

var hex = '#f8f8f8',
    rgb = '150, 150, 150';

var newRgb = colcon.convert(hex);
var newHex = colcon.convert(rgb);

console.log('hex to rgb: ' + newRgb);
console.log('rgb to hex: ' + newHex);

For command line conversion hit:

colcon -c [color code]

API

Command line API:

Usage: colcon [options]

Options:

	-h, --help           output usage information
	-V, --version        output the version number
	-c, --color [value]  a color code like rgb or hex. If passing a hex color code, remove the leading #.

Programmatically API:

colcon.convert(value)

Converts a HEX or RGB color code. Returns object of colors.

colcon.isRgb(value)

Checks if given string is a valid RGB color code. Returns boolean.

colcon.isHex(value)

Checks if given string is a valid HEX color code. Returns boolean.

colcon.toRgb(value)

Converts a given string to a RGB color code. If the string isn´t a valid color code, returns `false`

colcon.toHex(value)

Converts a given string to a HEX color code. If the string isn´t a valid color code, returns `false`

Release Notes

  • 0.3.1
    • More helpful comments
    • More helpful command line output
    • Some conversion improvements
    • Some bugfixes
  • 0.3.0
    • Some bugfixes
  • 0.2.0
    • Global usage is now available
    • Some bugfixes
  • 0.1.0 Initial Release