Skip to content

Commit

Permalink
add readme
Browse files Browse the repository at this point in the history
  • Loading branch information
deyihu committed Nov 28, 2022
1 parent 4123f12 commit 5a59a84
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
Binary file added colorin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
78 changes: 78 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# colorin

colors interpolation
![](./colorin.png)

## Examples

[base](https://deyihu.github.io/colorin/test/base.html)
[pie](https://deyihu.github.io/colorin/test/pie.html)
[maptalks points](https://deyihu.github.io/colorin/test/mtk-points.html)
[maptalks polygons](https://deyihu.github.io/colorin/test/mtk-polygons.html)
[zoom stops](https://deyihu.github.io/colorin/test/zoomstop.html)
[custom imagedata size](https://deyihu.github.io/colorin/test/customsize.html)

## Install

* CDN

```html
<script src="https://unpkg.com/colorin/dist/colorin.js"></script>
```

* NPM

```sh
npm i colorin
# or
yarn add colorin
```

## API

### `ColorIn` class

#### constructor(colors, [options])

+ colors `Color collection`

```js
import {
ColorIn
} from 'colorin';

const colors = [
[0, '#226412'],
[2, '#4C931B'],
[4, '#80BD3F'],
[6, '#B9E287'],
[8, '#E7F5D1'],
[10, '#F7F7F7'],
[13, '#226412'],
[16, '#80BD3F'],
[18, '#F1B7DB'],
[22, '#DF78AF'],
[24, '#C6147E'],
[26, '#8F0051']
];
const ci = new ColorIn(colors);
const [r, g, b, a] = ci.getColor(11);

//if you use cdn
const ci = new colorin.ColorIn(colors);
```

#### method

+ getColor(stop) `get color by stop`

```js
const [r, g, b, a] = ci.getColor(11);
```

+ getImageData() `get canvas image data`

```js
const imgData = ci.getImageData();
```

0 comments on commit 5a59a84

Please sign in to comment.