Culor
Just another color converter.
Installation
npm:
npm install culor
yarn:
yarn add culor
Usage example
const color_name = const color_hex = const color_hex_short = const color_rgb = const color_rgba = const color_hsl = const color_hsla =
const rgb = const rgba = const hsl = const hsla =
const c = c // '#00ff00'c // '#00ff00ff'c // 'rgb(0, 255, 0)'c // 'rgba(0, 255, 0, 1)'c // 'hsl(120, 100%, 50%)'c // 'hsla(120, 100%, 50%, 1)'c // 'lime'
Syntax
color(csscolor)
RGB(R, G, B)
RGBA(R, G, B, A)
HSL(H, S, L)
HSLA(H, S, L, A)
Parameters
Key | Type | Value |
---|---|---|
csscolor |
String |
Color keywords, rgb(), rgba(), hsl(), hsla() or Hexadecimal notation in css data type. |
R |
Number String |
red, [0, 255] |
G |
Number String |
green, [0, 255] |
B |
Number String |
blue, [0, 255] |
H |
String |
hue angel |
S |
Number String |
saturation can be a number [0, 1], or a string between '0%' and '100%' |
L |
Number String |
lightness can be a number [0, 1], or a string between '0%' and '100%' |
A |
Number String |
alpha can be a number [0, 1], or a string between '0' and '1' |
Functions
Key | Type | Value |
---|---|---|
.Hex() |
String |
#RRGGBB |
.HexA() |
String |
#RRGGBBAA |
.RGB() |
String |
rgb(r, g, b) |
.RGBA() |
String |
rgba(r, g, b, a) |
.HSL() |
String |
hsl(h, s, l) |
.HSLA() |
String |
hsla(h, s, l, a) |
.keyword() |
String |
color keyword or undefined |
To-Do
- support rgb() / rgba() percentage unit.
- .Hex(A) .RGB(A) .HSL(A)
- HSLA2RGB -> HSL2RGB
- .keyword
Contributing
- Fork it
- Create your feature branch (
git checkout -b feature/fooBar
) - Commit your changes (
git commit -am 'Add some fooBar'
) - Push to the branch (
git push origin feature/fooBar
) - Create a new Pull Request