# cosine-gradient

> Cosine gradient generator

Latest version **0.3.0** (published 2016-05-09) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.0 |
| Published | 2016-05-09 |
| First published | 2016-04-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 12 |
| Author | Marcin Ignac |
| Maintainers | vorg |
| Keywords | color |

## Links

- npm: https://www.npmjs.com/package/cosine-gradient
- Repository: https://github.com/vorg/cosine-gradient
- Issues: https://github.com/vorg/cosine-gradient/issues
- npm.io page: https://npm.io/package/cosine-gradient

## 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

- 0.3.0 (latest) — 2016-05-09
- 0.2.0 — 2016-05-04
- 0.1.0 — 2016-04-22

## README

# cosine-gradient

![](screenshot.png)

[![stable](http://badges.github.io/stability-badges/dist/stable.svg)](http://github.com/badges/stability-badges)

Cosine gradient generator

## Usage

[![NPM](https://nodei.co/npm/cosine-gradient.png)](https://www.npmjs.com/package/cosine-gradient)


#### cosineGradient(scheme)

Parameters:  
`scheme` - array of cosine coefficients for R,G,B channels

Returns:  
`function(t)` - a function calculating a color value for t=0..1. The returned color is an array `[0..1, 0..1, 0..1]`


## Example

To get the middle blue gradient from the screenshot you would:

```javascript
var cosineGradient = require('cosine-gradient');
var scheme = [
    [0.000,0.500,0.500],
    [0.000,0.500,0.500],
    [0.000,0.500,0.333],
    [0.000,0.500,0.667]
];
var gradient = cosineGradient(scheme);

for(var i=0; i<=100; i++) {
    var t = i / 100;
    var color = gradient(t); //[R=0..1, G=0..1, B=0..1]
}
```

## Credits

This is an implementation of a technique by [Inigo Quilez](https://twitter.com/iquilezles) ([Color Palettes](http://www.iquilezles.org/www/articles/palettes/palettes.htm)) with color schemes by [Karsten Schmidt aka Toxi](http://twitter.com/toxi) from [thi.ng/color](https://github.com/thi-ng/color/blob/master/src/gradients.org) and [cosine gradient generator](http://dev.thi.ng/gradients/);

## License

MIT, see [LICENSE.md](http://github.com/vorg/cosine-gradient/blob/master/LICENSE.md) for details.

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