-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
``` | ||
|