color-ops

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