{"id":13821862,"url":"https://github.com/aresrpg/aresrpg-map-colors","last_synced_at":"2025-05-16T15:31:19.946Z","repository":{"id":33788720,"uuid":"161393588","full_name":"aresrpg/aresrpg-map-colors","owner":"aresrpg","description":"Minecraft map item colors utility","archived":false,"fork":false,"pushed_at":"2023-11-16T19:36:09.000Z","size":297,"stargazers_count":16,"open_issues_count":2,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-07-28T11:22:44.740Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/aresrpg.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}},"created_at":"2018-12-11T21:05:26.000Z","updated_at":"2024-07-12T14:45:30.000Z","dependencies_parsed_at":"2024-01-15T15:46:09.446Z","dependency_job_id":"a13acfa0-31be-4cdf-8739-8afe2852bb72","html_url":"https://github.com/aresrpg/aresrpg-map-colors","commit_stats":{"total_commits":89,"total_committers":5,"mean_commits":17.8,"dds":0.2696629213483146,"last_synced_commit":"4b3b0360c1278df214ad25d0461beb5c28a6d606"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aresrpg%2Faresrpg-map-colors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aresrpg%2Faresrpg-map-colors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aresrpg%2Faresrpg-map-colors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aresrpg%2Faresrpg-map-colors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aresrpg","download_url":"https://codeload.github.com/aresrpg/aresrpg-map-colors/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":213893315,"owners_count":15653524,"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":"2024-08-04T08:01:31.327Z","updated_at":"2025-05-16T15:31:19.916Z","avatar_url":"https://github.com/aresrpg.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"![][licence] [![][npm]][npmlink] [![][npmdl]][npmlink]\n\n# aresrpg-map-colors\n\n[![][discord]][discordlink] [![][twitter]][twitterlink] ![][mcversion]\n\n[licence]: https://img.shields.io/github/license/AresRPG/aresrpg-map-colors.svg?style=for-the-badge\n[npm]: https://img.shields.io/npm/v/@aresrpg/aresrpg-map-colors.svg?logo=npm\u0026style=for-the-badge\n[npmlink]: https://www.npmjs.com/package/@aresrpg/aresrpg-map-colors\n[npmdl]: https://img.shields.io/npm/dw/@aresrpg/aresrpg-map-colors.svg?color=%239C27B0\u0026style=for-the-badge\n[twitter]: https://img.shields.io/badge/follow-us-55acee.svg?logo=twitter\u0026style=for-the-badge\n[twitterlink]: https://twitter.com/AresRPG\n[discord]: https://img.shields.io/discord/265104803531587584.svg?logo=discord\u0026style=for-the-badge\n[discordlink]: https://discord.gg/Ea6a5cn\n[mcversion]: https://img.shields.io/badge/minecraft-1.12+-AB47BC.svg?style=for-the-badge\n\nI'm a **performances focused** tool to help you manage minecraft map colors.\nI provide utilities to bridge between any colors to minecraft compatible colors\n\n\u003e since 1.1.4 i also provide a transform stream under `aresrpg-map-colors/minecraftTransform` that take images as input and output only updated frames to avoid sending the whole image each time\n\u003e the feature is not documented yet so refer to `test/index.js`\n\n---\n\n## Installation\n\n```sh\nnpm i @aresrpg/aresrpg-map-colors\n```\n\n## Minecraft colors\n\n[![](https://i.imgur.com/Wjsg0KU.png)](https://minecraft.wiki/w/Map_item_format#Color_table)\n\n---\n\n## Usage\n\n```js\nimport { nearestMatch, color, hex, fromImage, COLORS } from '@aresrpg/aresrpg-map-colors'\n```\n\nConvert an image into an array of minecraft compatible ids\n\n```js\nvoid (async function() {\n\tconst { width, height, datas } = await fromImage('https://i.imgur.com/28NLJWg.png')\n\tconsole.log(datas.length) // imageWidth * imageHeight\n\tconsole.log(datas) // [id,id,...] // uInt8\n})()\n```\n\n#### use it with [@Prismarine/node-minecraft-protocol](https://github.com/PrismarineJS/node-minecraft-protocol)\n\nNote that you will need to handle image sizes and multiples neighbors map (via item frames) by your own, we only provide conversions\n\n```js\nimport { fromImage } from '@aresrpg/aresrpg-map-colors'\nimport mc from 'minecraft-protocol'\n\nvoid (async function() {\n\tconst size = 128\n\tconst { datas } = await fromImage('https://i.imgur.com/h8g7SEf.jpg')\n\tthis.client.write('map', {\n\t\titemDamage: 0,\n\t\tscale: 4,\n\t\ttrackingPosition: false,\n\t\ticons: [],\n\t\tcolumns: -size,\n\t\trows: -size,\n\t\tx: 0,\n\t\ty: 0,\n\t\tdata: Buffer.from(data),\n\t})\n})()\n```\n\n\u003e In case you want to build an item frame wall with multiple blocks you'll need to handle the buffer to split every 128 values, see [Map item format](https://minecraft.wiki/w/Map_item_format)\n\n#### Find the closest color available in minecraft from any color\n\nArguments and return value are memoized for performances\n\n\u003e We use a weighted aproach of the color space, read more on [Here](https://en.wikipedia.org/wiki/Color_difference)\n\n```js\nconst colorId = nearestMatch(70, 120, 35)\n```\n\n![](https://i.imgur.com/gWAHyQl.png)\n![](https://i.imgur.com/ue85juy.png)\n\n#### Find a color by id\n\nsame as doing `COLORS[id-4]`\n\n```js\nconst { r, g, b } = color(4)\n```\n\nYou can also get the decimal/hexadecimal value\n\n```js\nconst color = hex(4).toString(16)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faresrpg%2Faresrpg-map-colors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faresrpg%2Faresrpg-map-colors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faresrpg%2Faresrpg-map-colors/lists"}