Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

color-ops

Package Overview
Dependencies
Maintainers
29
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

color-ops

simple color operations

latest
Source
npmnpm
Version
2.0.0
Version published
Maintainers
29
Created
Source

color-ops

build status

simple color operations

toHSL(color)

Convert a color specified as an RGBA array into an HSL object.

Parameters

parametertypedescription
colorArrayrgba color

Returns Object, hsl representation of that color

rgb(r, g, b)

Given an r, g, b color, return a 4-element RGBA array

Parameters

parametertypedescription
rnumberred
gnumbergreen
bnumberblue

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

parametertypedescription
rnumberred
gnumbergreen
bnumberblue
anumberalpha

Returns Array, rgba array

hsl(h, s, l)

Given an HSL color as components, return an RGBA array with 100% alpha

Parameters

parametertypedescription
hnumberhue
snumbersaturation
lnumberluminosity

Returns Array, rgba color

hsla(h, s, l, a)

Given an HSL color as components, return an RGBA array

Parameters

parametertypedescription
hnumberhue
snumbersaturation
lnumberluminosity
anumberalpha

Returns Array, rgba color

hue(color)

Get the hue component of a color

Parameters

parametertypedescription
colorColor

Returns Number, hue

saturation(color)

Get the saturation component of a color as a string representing percentage

Parameters

parametertypedescription
colorColor

Returns String, saturation

lightness(color)

Get the lightness component of a color as a string representing percentage

Parameters

parametertypedescription
colorColor

Returns String, lightness

alpha(color)

Get the alpha component of a color

Parameters

parametertypedescription
colorArray

Returns Number, alpha

saturate(color, amount)

Saturate or desaturate a color by a given amount

Parameters

parametertypedescription
colorColor
amountNumber

Returns Color, color

lighten(color, amount)

Lighten or darken a color by a given amount

Parameters

parametertypedescription
colorColor
amountNumber

Returns Color, color

fade(color, amount)

Fade a color by a given amount

Parameters

parametertypedescription
colorColor
amountNumber

Returns Color, color

spin(color, degrees)

Rotate the hue of a color by an amount given in decimal degrees.

Parameters

parametertypedescription
colorColor
degreesNumber

Returns Color, output

mix(color1, color2, degrees)

Mix two colors.

Parameters

parametertypedescription
color1Color
color2Color
degreesNumber

Returns Color, output

Installation

Requires nodejs.

$ npm install color-ops

Tests

$ npm test

Keywords

color

FAQs

Package last updated on 29 Apr 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts