simple color operations
Convert a color specified as an RGBA array into an HSL object.
parameter | type | description |
---|---|---|
color |
Array | rgba color |
Returns Object
, hsl representation of that color
Given an r, g, b color, return a 4-element RGBA array
parameter | type | description |
---|---|---|
r |
number | red |
g |
number | green |
b |
number | blue |
Returns Array
, rgba array
Given an rgba color as number-like objects, return that array with numbers if possible, and null otherwise
parameter | type | description |
---|---|---|
r |
number | red |
g |
number | green |
b |
number | blue |
a |
number | alpha |
Returns Array
, rgba array
Given an HSL color as components, return an RGBA array with 100% alpha
parameter | type | description |
---|---|---|
h |
number | hue |
s |
number | saturation |
l |
number | luminosity |
Returns Array
, rgba color
Given an HSL color as components, return an RGBA array
parameter | type | description |
---|---|---|
h |
number | hue |
s |
number | saturation |
l |
number | luminosity |
a |
number | alpha |
Returns Array
, rgba color
Get the hue component of a color
parameter | type | description |
---|---|---|
color |
Color |
Returns Number
, hue
Get the saturation component of a color as a string representing percentage
parameter | type | description |
---|---|---|
color |
Color |
Returns String
, saturation
Get the lightness component of a color as a string representing percentage
parameter | type | description |
---|---|---|
color |
Color |
Returns String
, lightness
Get the alpha component of a color
parameter | type | description |
---|---|---|
color |
Array |
Returns Number
, alpha
Saturate or desaturate a color by a given amount
parameter | type | description |
---|---|---|
color |
Color | |
amount |
Number |
Returns Color
, color
Lighten or darken a color by a given amount
parameter | type | description |
---|---|---|
color |
Color | |
amount |
Number |
Returns Color
, color
Fade a color by a given amount
parameter | type | description |
---|---|---|
color |
Color | |
amount |
Number |
Returns Color
, color
Rotate the hue of a color by an amount given in decimal degrees.
parameter | type | description |
---|---|---|
color |
Color | |
degrees |
Number |
Returns Color
, output
Mix two colors.
parameter | type | description |
---|---|---|
color1 |
Color | |
color2 |
Color | |
degrees |
Number |
Returns Color
, output
Requires nodejs.
$ npm install color-ops
$ npm test