@spa-tools/utilities
tint
The tint
function adds white to a color.
Usage
import { tint } from '@spa-tools/utilities';
const redTintedExponentially = tint('#FF0000', 0.2);
console.log(redTintedExponentially.toHex());
// --> #ff7272
const redTintedLinearly = tint('#FF0000', 0.2, true);
console.log(redTintedLinearly.toHex());
// --> #ff3333
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.