Skip to main content
@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

NameTypeRequired?DefaultDescription
rgbOrRgbaOrHexstringyes-RGB(A) or hex color string
rationumberyes-Interpolation ratio between 0 and 1
linearbooleannofalseIf true uses a linear interpolation algorithm; otherwise, exponential interpolation will be used

Returns

ColorObject object.