Color-convert.js
Introduction
Color-convert.js is a little JavaScript Library, that convert color formats, as RGB, HSL, CMYK and soon many others. It is light, and easy to use.
Availables conversions:
- RGB <==> HSL
- RGB <==> CMYK
- HSL <==> CMYK
- RGB ===> Hexadecimal
Installation
Using NPM
First install in your project
npm install @eliotttak/color-convert.js
And then use it in your script
const colorConvertJs = require("@eliotttak/color-convert.js")
console.table(colorConvertJs.rgbToHsl(0, 255, 0))
Output :
| (index) | Values |
|---|---|
| h | 120 |
| s | 100 |
| l | 50 |
In a website, using an URL
Add this line to you HTML
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@eliotttak/color-convert.js"></script>
And then you can use it in your scripts:
console.table(rgbToHsl(0, 255, 0))
Output :
| (index) | Values |
|---|---|
| h | 120 |
| s | 100 |
| l | 50 |
API
You can find the JSDoc documentation here : Documentation
Demo
If the site doesn't load, find the demo on CodePen : cdpn.io/pen/full/EaPewYJ