# @sunify/lerp-color

> ## Installation

Latest version **2.0.0** (published 2019-07-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install @sunify/lerp-color
pnpm add @sunify/lerp-color
yarn add @sunify/lerp-color
bun add @sunify/lerp-color
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2019-07-30 |
| First published | 2019-01-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 15.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 12 |
| Author | Alex Lunyov |
| Maintainers | sunify |

## Links

- npm: https://www.npmjs.com/package/@sunify/lerp-color
- Repository: https://github.com/sunify/lerp-color
- Homepage: https://github.com/sunify/lerp-color#readme
- Issues: https://github.com/sunify/lerp-color/issues
- npm.io page: https://npm.io/package/@sunify/lerp-color

## Dependencies (5)

- [hex-rgb](https://npm.io/package/hex-rgb.md) ^3.0.0
- [rgb-hex](https://npm.io/package/rgb-hex.md) ^2.1.0
- [lerp-array](https://npm.io/package/lerp-array.md) ^1.1.1
- [@types/hex-rgb](https://npm.io/package/@types/hex-rgb.md) ^3.0.0
- [@types/rgb-hex](https://npm.io/package/@types/rgb-hex.md) ^2.1.0

## Recent versions

- 2.0.0 (latest) — 2019-07-30
- 1.3.0 — 2019-02-14
- 1.2.0 — 2019-02-13
- 1.1.1 — 2019-02-03
- 1.1.0 — 2019-02-03
- 1.0.0 — 2019-01-28

## README

# Linear interpolation function for colors

## Installation

`yarn add @sunify/lerp-color` or `npm install @sunify/lerp-color`

## Usage

```
/**
 * t — number 0..1
 */

(start: string, end: string, t: number) => string

// for more than 2 colors
(colors: string[], t: number) => string

// or as partial

(colors: string[]) => (t: number) => string
```

Supports arbitary (2+) amount of `rgb`, `rgba` and `hex` colors

## Examples

```es6
lerp('#FFF', '#000', 0.5); // #808080
lerp('#F00', '#000', 0.5); // #800000
lerp(['#F00', '#000', '#FFF'], 0.25); // #800000
lerp(['#F00', '#000', '#FFF'], 0.5); // #000000
lerp(['#F00', '#000', '#FFF'], 0.75); // #808080
lerp(['#F00', '#000', '#FFF'], 1); // #FFF

lerp('#FF0', 'rgba(#FF0, 0.2)', 0.5); // rgba(255, 255, 0, 0.6)
lerp('#FF0', 'rgba(#FF0, 0.2)', 1); // rgba(255, 255, 0, 0.2)
lerp('#FF0', 'rgba(#FF0, 0.2)', 0); // #FFF

/**
 * or as partial
 *
 * In this case all color will be preparsed
 * Useful for animations and similar stuff
 */

const partial = lerp(['#F00', '#000', '#FFF']);
partial(0.25); // #800000
partial(0.5); // #000000
partial(0.75); // #808080
partial(1); // #FFF
```

---
_Source: https://npm.io/package/@sunify/lerp-color · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
