1.0.0 • Published 1 year ago

@chriscodesthings/rgb-color-fade v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

rgb-color-fade · Test workflow status NPM Version License: MIT

Lightens or darkens an RGB or RGBA color towards white or black

Install

npm install --save @chriscodesthings/rgb-color-fade

Use

import rgbColorFade from '@chriscodesthings/rgb-color-fade';

console.log(rgbColorFade([100, 149, 237], -20)); // cornflowerblue, 20% darker
// => true

Syntax

rgbColorFade(col, fade);

Parameters

  • col: an array containing red, green, blue and (optional) alpha values
  • fade: a percentage from -100 to 100. Negative values fade towards black, positive towards white.

Return Value

Returns an array containing the new red, green, blue and (if originally present) alpha values.

Note, the alpha channel is not modified

Description

Does what it says on the tin.