1.0.9 • Published 3 years ago

@ridwan-p/color-convert v1.0.9

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

Color Convert

Color Convert is a color conversion library for JavaScript and node. It converts all ways between rgb, hsl, hsv, hex strings, and generate the oposite color (invert color):

Install

$ npm i @ridwan-p/color-convert

Usage

const color = require("@ridwan-p/color-convert")

// Hexa to RGB
color.hex2RGB('#FFF')
//=> { r: 255, g: 255, b: 255 }

// RGB to Hexa
color.rgb2Hex(255, 12, 43)
//=> #ff0c2b

// Generate the oposite color
color.invertColor('#ffff00')
//=> #ff0c2b
// set black & white
color.invertColor('#ffff00', true)
//=> #000000

// Convert to HSL
color.rgb2HSL(255, 66, 66)
color.hex2HSL('#ff4242')
//=> { h: 0, s: 1, l: 0.6294117647058823 }

// Convert to HSV
color.rgb2HSL(255, 66, 66)
color.hex2HSL('#ff4242')
//=> { h: 0, s: 0.7411764705882353, v: 1 }

Contribute

If there is a new model you would like to support, or want to add a direct conversion between two existing models, please send us a pull request.

License

Copyright © 2022, Ridwan Pamungkas.

Licensed under the MIT License

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago