@spa-tools/utilities
shade
The shade
function adds black to a color.
Usage
import { shade } from '@spa-tools/utilities';
const redShadedExponentially = shade('#FF0000', 0.5);
console.log(redShadedExponentially.toHex());
// --> #b40000
const redShadedLinearly = shade('#FF0000', 0.5, true);
console.log(redShadedLinearly.toHex());
// --> #800000
Arguments
Name | Type | Required? | Default | Description |
---|---|---|---|---|
rgbOrRgbaOrHex | string | yes | - | RGB(A) or hex color string |
ratio | number | yes | - | Interpolation ratio between 0 and 1 |
linear | boolean | no | false | If true uses a linear interpolation algorithm; otherwise, exponential interpolation will be used |
Returns
ColorObject
object.