# gen-gradient-color

> generate gradient color

Latest version **1.0.5** (published 2021-01-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install gen-gradient-color
pnpm add gen-gradient-color
yarn add gen-gradient-color
bun add gen-gradient-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 | 1.0.5 |
| Published | 2021-01-25 |
| First published | 2020-09-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 37.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Shueh Chou Lu |
| Maintainers | evan361425 |
| Keywords | color, gradient color, generate color |

## Links

- npm: https://www.npmjs.com/package/gen-gradient-color
- Repository: https://github.com/evan361425/gen-gradient-color
- Homepage: https://github.com/evan361425/gen-gradient-color#readme
- Issues: https://github.com/evan361425/gen-gradient-color/issues
- npm.io page: https://npm.io/package/gen-gradient-color

## Alternatives

- [postcss-color-hex-alpha](https://npm.io/package/postcss-color-hex-alpha.md) — 6.4M weekly downloads
- [randomcolor](https://npm.io/package/randomcolor.md) — 348.0K weekly downloads
- [bows](https://npm.io/package/bows.md) — 1.3K weekly downloads
- [ep_prefer_color_scheme](https://npm.io/package/ep_prefer_color_scheme.md) — 260 weekly downloads
- [coc-yank](https://npm.io/package/coc-yank.md) — 61 weekly downloads

## Recent versions

- 1.0.5 (latest) — 2021-01-25
- 1.0.4 — 2021-01-08
- 1.0.3 — 2020-12-12
- 1.0.2 — 2020-12-12
- 1.0.1 — 2020-12-12
- 1.0.0 — 2020-09-17

## README

# gen-gradient-color
generate gradient color between two colors

## Installation

### NPM

```shell
$ npm install gen-gradient-color
```

### Website

download [dist/bundle.js](dist/bundle.js) or [dist/bundle.min.js](dist/bundle.min.js) and include it!

## Usage

### Node.js

```js
import { GenGradientColor } from 'gen-gradient-color';
// color format accept 3/6 digit hex string or array of 0-255 number
const generator = new GenGradientColor('#000000', [255, '255', 255]);
const colors = generator.gens(16);
// colors = ['#000000', '#060606', '#181818', '#2b2b2b', '#3d3d3d', '#4f4f4f', '#616161', '#737373', '#858585', '#979797', '#a8a8a8', '#bababa', '#cbcbcb', '#dddddd', '#efefef', '#ffffff'];

// reset colors, color also accept 3/6 digit hex string without '#'
generator.setColors('abc', '000def');
const color1 = generator.gen(3, 16);
// color1 = '#9baad3'
const color2 = generator.gen(8, 16);
// color2 = '#7b88dd'
```

### Web

```html
<script src="/dist/bundle.min.js"></script>
<script>
// number greater than 255 will equal to 255
var generator = new GenGradientColor('#f00', ['non number will equal to 0', 300, 0]);
var color = generator.gens(3);
// color = ['#ff0000', '#bcbc00', '#00ff00'];
</script>
```

### Util

Web environment can use it by `GenGradientColor.util`

```js
import { util } from 'gen-gradient-color';
// or var util = GenGradientColor.util in website

util.isString('abc'); // true

// change string to number array
util.hex2rgb('#000'); // [0, 0, 0]
// oposite: hex2rgb
util.rgb2hex([0, 1, 2]); // #000102

// if is string: hex2rgb
// else if is array: sanitize element
// else: error
util.color2rgb([0, '123', 'invalid-number']); // [0, 123, 0]

util.rgb2linear('001'); // oposite: util.linear2rgb
// a * p + b * (1 - p)
util.lerp(5, 6, 0.1); // a: 5, b: 6, p: 0.1
```

## Scripts

Run your own unit test

```bash
$ npm run test
```

Build your own package

``` bash
$ npm run dev
$ npm run prod
# equal to `npm run dev && npm run prod`
$ npm run build
```

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