1.0.3 • Published 3 years ago

coloras.js v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Coloras.js

Color manipulation library for coloras with hex, rgb, hsl, hsv and cmyk support

Install

Using npm

$ npm install coloras.js

Using yarn

$ yarn add coloras.js

Color

  • Type: Class

  • Constructor Param: color -> the color string. Supports hex, rgb, hsl, hsv and cmyk values

  • Methods: toHex() | toRgb() | toHsl() | toHsv() | toCmyk()

  • Tip: Don't pass any params to create a random color

Usage

// -- require --
const { Color } = require("coloras.js");

const color = new Color("#68CA5B");

// -- convertions --
color.toRgb(); // Convert the color to rgb -> rgb(104, 202, 91)
color.toHsl(); // Convert the color to hsl -> hsl(113, 51%, 57%)
color.toHsv(); // Convert the color to hsv -> hsv(113, 55%, 79%)
color.toCmyk(); // Convert the color to cmyk -> cmyk(49, 0, 55, 21)
// -- require --
const { Color } = require("coloras.js");

// -- generate a random color -- 
const random = new Color();

random.toHex(); // random color in hex code
random.toRgb(); // random color in rgb code
random.toHsl(); // random color in hsl code
random.toHsv(); // random color in hsv code
random.toCmyk(); // random color in cmyk code

isColor

  • Type: function

  • Param: string -> the color string. Supports hex, rgb, hsl, hsv and cmyk values

  • Returns: Object

Usage

const { isColor } = require("coloras.js");

isColor("#1f1f1f"); // -> { color: true, colorSystem: 'hex' }
isColor("rgb(31, 31, 31)"); // -> { color: true, colorSystem: 'rgb' }
isColor("hsl(0, 0%, 12%)"); // -> { color: true, colorSystem: 'hsl' }
isColor("hsv(0, 0%, 12%)"); // -> { color: true, colorSystem: 'hsv' }
isColor("cmyk(0, 0, 0, 88)"); // -> { color: true, colorSystem: 'cmyk' }

isColor("not a color code") // -> { color: false, colorSystem: null }

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago