@spa-tools/utilities
tone
The tone
function adds gray to a color.
Usage
import { tone } from '@spa-tools/utilities';
const redTonedExponentially = tone('#FF0000', 0.2);
console.log(redTonedExponentially.toHex());
// --> #eb3939
const redTonedLinearly = tone('#FF0000', 0.2, true);
console.log(redTonedLinearly.toHex());
// --> #e61a1a
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.