Skip to content

Colour conversions between Hex, Hex3, Hex8, RGB, RGBA and CMYK.

License

Notifications You must be signed in to change notification settings

jrrom/some-colours

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

some-colours

Library for conversion between Hex, Hex3, Hex8, RGB, RGBA and CMYK. All inputs must be strings.

Create a colour object:

let redHex = new Hex("#FF0000");
let redHex3 = new Hex3("#F00");
let redHex8 = new Hex8("#FF000000");               //Hex, Hex3 and Hex8 must use #
let redRGB = new RGB(["255", "0", "0"]);
let redRGBA = new RGBA(["255", "0", "0"]);
let redCMYK = new CMYK(["0", "100%", "100%", "0"]) //CMYK must use %

Obtain value of object:

console.log(redHex.value)                          //"#FF0000"

Convert between colour types:

let newRedRGBA = redHex.toRGBA();
console.log(newRedRGBA.value);                     // ["255", "0", "0", "1"]

About

Colour conversions between Hex, Hex3, Hex8, RGB, RGBA and CMYK.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published