sc-color

0.4.0 • Public • Published

sc-color

A JavaScript color parsing and manipulation library designed for convenience and flexibility (rather than runtime performance).

Usage

See the User Guide for examples and full documentation.

var color = require("sc-color");
 
var c0 = color("#0c7").hue("+30").hex6(); // returns "#00bbcc"
var c1 = color("red")
    .saturation(20)
    .tone(.35)
    .alpha(.5)
    .html();  // returns "rgba(211,177,177,0.5)"
 

Parsing

The library is intended to support many color formats. See the full documentation for all formats.

color('orange');                  
color('#FC3');                    
color('rgb(128,64,200)');         
color('hsl', 200, 90, 90);        
color('hsv', [200, 90, 90]);    

Output Formats

The parsing formats are also available as output formats:

var orange = color('orange');
orange.html();                          
orange.hex6();                          
orange.hex3();                          
orange.html('keyword');                 
orange.complement().html('keyword');    

Color Manipulation

The library supports many operations for manipulating a given color. Change the color saturation, reduce the amount of green, blend with another color, find the color's complement, find a different tone of the same base color, etc.

var c = color('#F00');
= c.blend('yellow', .25);                
c.hue('-30');                              
c.hue('+=30');                             
= c.saturation(50).shade(.5).tint(.3);   
c.complement();                            
c.complement().hueSet();                   
c.blend('lawngreen','55%').hueRange(60,9); 

Development

  • npm test - run the unit tests

Pull requests and issues are welcome. If you want proactively contribute, see the TODO file for ways to contribute.

License

The source code is under the MIT License.

References / Acknowledgments

Readme

Keywords

none

Package Sidebar

Install

npm i sc-color

Weekly Downloads

27

Version

0.4.0

License

MIT

Last publish

Collaborators

  • bcronin