# gradient-base

> Base module of the gradient.js library

Latest version **1.0.4** (published 2018-08-04) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install gradient-base
pnpm add gradient-base
yarn add gradient-base
bun add gradient-base
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2018-08-04 |
| First published | 2018-08-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 8.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Jakub Antolak |
| Maintainers | afternoon2 |
| Keywords | chroma-js, colors, gradients |

## Links

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

## Dependencies (1)

- [chroma-js](https://npm.io/package/chroma-js.md) ^1.3.7

## 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.4 (latest) — 2018-08-04
- 1.0.3 — 2018-08-04
- 1.0.2 — 2018-08-04
- 1.0.1 — 2018-08-04
- 1.0.0 — 2018-08-03
- 0.0.0-development — 2018-08-03

## README

# gradient-base.js 
[![License](https://img.shields.io/npm/l/gradient-base.svg?style=flat)](https://github.com/afternoon2/gradient-base/blob/master/LICENSE)&nbsp;&nbsp;
[![Travis build](https://img.shields.io/travis/afternoon2/gradient-base.svg?style=flat)](https://travis-ci.org/afternoon2/gradient-base)&nbsp;&nbsp;[![Codecov](https://img.shields.io/codecov/c/github/afternoon2/gradient-base.svg?style=flat)](https://codecov.io/gh/afternoon2/gradient-base)

---

This module creates base gradient output for gradient.js modules.

## Table of contents
* [gradient.js](#gradient.js)
* [Usage](#usage)
* [Parameters](#parameters)
    * [Colors](#colors)
    * [Options](#options)
    * [Opacity](#opacity)

---
## gradient.js
### Gradient creation library running in the browser 🖌🌈

gradient.js is a javascript module that takes your source colors array and configuration object, and returns a gradient suitable for your needs.

---
## Usage
`Base.get` function takes 2 parameters: the colors array and the configuration object.
```javascript
const base = new Base()

const g = base.get(colors, options)
// [[0,222,31,0.4],[1.3265624999999999,199.890625,31.331640625,0.466328125], (...)]
```

## Parameters
### Colors
Colors input should be an array of numbers in rgb or rgba format or array of css rgb(a) strings.

### Options

Options object stands for the basic settings of the gradient creation, mandatory for the chroma-js library. Its interface looks like below:

```typescript
{
    interpolation: 'linear' | 'bezier'
    mode: 'none' | 'lch' | 'lab' | 'rgb' | 'hsv' | 'hsl' | 'hsi' | 'hcl'
    samples: number
    lightnessCorrection: boolean
}
```
The `mode` entry is ommited when the `interpolation` is set to `bezier`.

Usefullness of setting the lightness correction to `true` (combined with the `bezier` interpolation) is [very well described by Gregor Aisch here](https://www.vis4.net/blog/2013/09/mastering-multi-hued-color-scales/).

The `samples` stand for the number of the output colors. The more you set, the nicer gradient you get (but with worse performance of course).

## Opacity
Alpha values will be not preserved in the output if the `interpolation` will be set to the `bezier` value.

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