{"id":13410732,"url":"https://github.com/markusn/color-diff","last_synced_at":"2025-05-15T10:06:30.897Z","repository":{"id":2812301,"uuid":"3813618","full_name":"markusn/color-diff","owner":"markusn","description":"Implemets the CIEDE2000 color difference algorithm, conversion between RGB and lab color and mapping all colors in palette X to the closest color in palette Y based on the CIEDE2000 difference.","archived":false,"fork":false,"pushed_at":"2024-09-26T15:18:03.000Z","size":199,"stargazers_count":363,"open_issues_count":3,"forks_count":30,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-11T19:59:43.672Z","etag":null,"topics":["ciede2000","colordiff","conversion","javascript","lab-color","palette","rgb"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/markusn.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"COPYING","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":"2012-03-23T23:29:27.000Z","updated_at":"2025-03-31T15:07:38.000Z","dependencies_parsed_at":"2023-01-13T12:06:30.793Z","dependency_job_id":"ee379d41-8d61-498b-b4b6-260d4946209c","html_url":"https://github.com/markusn/color-diff","commit_stats":{"total_commits":81,"total_committers":9,"mean_commits":9.0,"dds":"0.33333333333333337","last_synced_commit":"7ad453cd8ae62656a90d8071c4ae6ad2bd002ebf"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markusn%2Fcolor-diff","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markusn%2Fcolor-diff/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markusn%2Fcolor-diff/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markusn%2Fcolor-diff/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/markusn","download_url":"https://codeload.github.com/markusn/color-diff/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254319718,"owners_count":22051072,"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":["ciede2000","colordiff","conversion","javascript","lab-color","palette","rgb"],"created_at":"2024-07-30T20:01:08.729Z","updated_at":"2025-05-15T10:06:25.876Z","avatar_url":"https://github.com/markusn.png","language":"JavaScript","readme":"# color-diff\n\n[![Build Status](https://github.com/markusn/color-diff/actions/workflows/build-latest.yaml/badge.svg?branch=master)](https://github.com/markusn/color-diff/actions/workflows/build-latest.yaml)\n[![Coverage Status](https://coveralls.io/repos/markusn/color-diff/badge.png?branch=master)](https://coveralls.io/r/markusn/color-diff?branch=master)\n\nImplements the CIEDE2000 color difference algorithm, conversion between RGB and\nLAB color and mapping all colors in palette X to the closest color in palette Y\nbased on the CIEDE2000 difference.\n\n## Installation\n\n```bash\nnpm install color-diff --save\n```\n\n## Tests\n\nAre located in the `test/` folder and are run by:\n\n```bash\nnpm test\n```\n\n## Usage\n\n```js\n// CommonJS\nconst { \n  closest, \n  furthest,\n  diff, \n  mapPalette,\n  paletteMapKey,\n  rgbaToLab,\n  mapPaletteLab,\n  labPaletteMapKey,\n} = require(\"color-diff\");\n\n// ESM\nimport {\n  closest,\n  furthest,\n  diff,\n  mapPalette,\n  paletteMapKey,\n  rgbaToLab,\n  mapPaletteLab,\n  labPaletteMapKey,\n} from \"color-diff\";\n```\n\n### closest(color, palette, bc)\n\nReturns the closest color. The parameter bc is optional and is used as\nbackground color when the color and/or palette uses alpha channels.\n\n```js\nconst color = { R: 255, G: 1, B: 30 };\n// red, green, blue\nconst palette = [ {R: 255, G: 0, B: 0 },\n                {R: 0, G: 255, B: 0 },\n                {R: 0, G: 0, B: 255} ];\n\nclosest(color, palette); // {R: 255, G: 0, B: 0 }, red\n```\n\nThe result above is obvious, but `diff.closest` could deal with more complicated\ncases.\n\n### furthest(color, palette, bc)\n\nReturns the most different color. The parameter bc is optional and is used as\nbackground color when the color and/or palette uses alpha channels.\n\n```js\nconst color = { R: 255, G: 255, B: 255 };\n// black, white\nconst palette = [ {R: 0, G: 0, B: 0 }, {R: 255, G: 255, B: 255 } ];\n\nfurthest(color, palette); // {R: 0, G: 0, B: 0 }, black\n```\n\nThe result above is obvious, but `diff.furthest` could deal with more\ncomplicated cases.\n\n### mapPalette(palette1, palette2)\n\nReturns a mapping from the colors in palette1 to palette2.\n\n### paletteMapKey(color)\n\nReturn the palette map key for the color, to be used with the result from mapPalette.\n\n### diff(color1, color2, bc)\n\nReturns the difference between the lab colors color1 and color2. The parameter bc is optional and\nis used as background color when one of the colors uses alpha channels.\n\n#### rgba color\n\n`Object`\n\n`RGBAColor` is an object containing 4 properties: 'R', 'G', 'B', 'A', where 'A' is optional OR\n'r', 'g', 'b', 'a', where 'a' is optional . Such as:\n\n```js\n{ R: 255, G: 1, B: 0 }\n```\n\nThere is an optional property 'A', which specifies the alpha channel between 0.0\nand 1.0. If not present the color will be treated as fully opaque, i.e. A = 1.0.\n\nEach RGBA-color is transformed into a RGB-color before being used to calculate\nthe CIEDE2000 difference, using the specified background color\n(defaults to white).\n\n### lab color\n\n`Object`\n\n`LabColor` is an object containing 3 properties 'L', 'a', 'b' such as:\n\n```js\n{ L: 100, a: 0.005, b: -0.010 }\n```\n\n#### palette\n\n`Array.\u003cRGBAColor\u003e`\n\nColor palette array which contains many `RGBAColor` objects.\n\n## Author\n\nMarkus Ekholm\n\n## License\n\n3-clause BSD. For details see `COPYING`.\n","funding_links":[],"categories":["JavaScript","data structures and algorithms"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkusn%2Fcolor-diff","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarkusn%2Fcolor-diff","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkusn%2Fcolor-diff/lists"}