{"id":24988718,"url":"https://github.com/maptalks/colorin","last_synced_at":"2025-04-19T18:05:35.385Z","repository":{"id":63871478,"uuid":"571209073","full_name":"maptalks/colorin","owner":"maptalks","description":"a simple colors interpolate lib","archived":false,"fork":false,"pushed_at":"2024-11-01T08:11:31.000Z","size":2914,"stargazers_count":3,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-05T19:52:20.949Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/maptalks.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-11-27T14:15:51.000Z","updated_at":"2025-01-10T08:28:08.000Z","dependencies_parsed_at":"2024-06-19T16:03:49.618Z","dependency_job_id":"9b3abca4-4cc3-4bd1-8bb1-043316e9410d","html_url":"https://github.com/maptalks/colorin","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maptalks%2Fcolorin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maptalks%2Fcolorin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maptalks%2Fcolorin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maptalks%2Fcolorin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maptalks","download_url":"https://codeload.github.com/maptalks/colorin/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246174742,"owners_count":20735442,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-04T12:05:10.403Z","updated_at":"2025-03-29T11:19:38.194Z","avatar_url":"https://github.com/maptalks.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# colorin\n\ncolors interpolate  \n\n![](./colorin.png)\n\n## gallery\n![](./images/1.png)\n![](./images/2.png)\n![](./images/3.png)\n\n## Examples\n\n[base](https://maptalks.github.io/colorin/test/base.html)  \n[pie](https://maptalks.github.io/colorin/test/pie.html)  \n[maptalks points](https://maptalks.github.io/colorin/test/mtk-points.html)  \n[maptalks lines](https://maptalks.github.io/colorin/test/mtk-lines.html)  \n[maptalks polygons](https://maptalks.github.io/colorin/test/mtk-polygons.html)  \n[zoom stops](https://maptalks.github.io/colorin/test/zoomstop.html)  \n[custom imagedata size](https://maptalks.github.io/colorin/test/customsize.html)  \n[covid-19 usa](https://maptalks.github.io/colorin/test/covid-19.html)  \n[echarts-bar](https://maptalks.github.io/colorin/test/echarts-bar.html)  \n[echarts-calendar](https://maptalks.github.io/colorin/test/echarts-calendar.html)  \nmaptalks.js already has this feature built-in\n[maptalks funtion-type demo](https://maptalks.org/examples/en/style/color-interpolate/#style_color-interpolate)\n\n## Install\n\n* CDN\n\n```html\n\u003cscript src=\"https://unpkg.com/colorin/dist/colorin.js\"\u003e\u003c/script\u003e\n```\n\n* NPM\n\n```sh\nnpm i colorin\n# or\nyarn add colorin\n```\n\n### Warning\n\nin nodejs, you need  dynamic registerCanvas,you can use [@napi-rs/canvas](https://github.com/Brooooooklyn/canvas) or [node-canvas](https://github.com/Automattic/node-canvas)\n\n```sh\nnpm i @napi-rs/canvas\n# or\nyarn add @napi-rs/canvas\n```\n\n```js\nconst {\n    ColorIn,\n    registerCanvas\n} = require('colorin');\nconst {\n    createCanvas\n} = require('@napi-rs/canvas');\nconst canvas = createCanvas(1, 1);\nregisterCanvas(canvas);\n```\n\n## API\n\n### `ColorIn` class\n\n#### constructor(colors, [options])\n\n  + colors `Color collection`\n\n```js\nimport {\n    ColorIn\n} from 'colorin';\n\nconst colors = [\n    [0, '#226412'],\n    [2, '#4C931B'],\n    [4, '#80BD3F'],\n    [6, '#B9E287'],\n    [8, '#E7F5D1'],\n    [10, '#F7F7F7'],\n    [13, '#226412'],\n    [16, '#80BD3F'],\n    [18, '#F1B7DB'],\n    [22, '#DF78AF'],\n    [24, '#C6147E'],\n    [26, '#8F0051']\n];\nconst ci = new ColorIn(colors);\nconst [r, g, b, a] = ci.getColor(11);\n\n//if you use cdn\nconst ci = new colorin.ColorIn(colors);\n```\n\n####  method\n\n  + getColor(stop) `get color by stop`\n\n```js\nconst [r, g, b, a] = ci.getColor(11);\n```\n\n  + getImageData() `get canvas image data`\n\n```js\n    const imgData = ci.getImageData();\n```\n\n    \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaptalks%2Fcolorin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaptalks%2Fcolorin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaptalks%2Fcolorin/lists"}