{"id":13671538,"url":"https://github.com/XadillaX/thmclrx","last_synced_at":"2025-04-27T18:31:23.601Z","repository":{"id":20760723,"uuid":"24045344","full_name":"XadillaX/thmclrx","owner":"XadillaX","description":":art: A theme color extractor module for Node.js.","archived":false,"fork":false,"pushed_at":"2025-04-12T10:12:47.000Z","size":827,"stargazers_count":207,"open_issues_count":3,"forks_count":20,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-12T11:25:32.067Z","etag":null,"topics":["c-plus-plus","nodejs","theme-color"],"latest_commit_sha":null,"homepage":"http://blog.xcoder.in/thmclrx-stress-tester/result/","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/XadillaX.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}},"created_at":"2014-09-15T06:25:53.000Z","updated_at":"2025-04-12T10:12:50.000Z","dependencies_parsed_at":"2022-08-26T01:23:54.188Z","dependency_job_id":null,"html_url":"https://github.com/XadillaX/thmclrx","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XadillaX%2Fthmclrx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XadillaX%2Fthmclrx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XadillaX%2Fthmclrx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XadillaX%2Fthmclrx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/XadillaX","download_url":"https://codeload.github.com/XadillaX/thmclrx/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251187165,"owners_count":21549596,"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":["c-plus-plus","nodejs","theme-color"],"created_at":"2024-08-02T09:01:12.433Z","updated_at":"2025-04-27T18:31:22.750Z","avatar_url":"https://github.com/XadillaX.png","language":"JavaScript","funding_links":["https://github.com/sponsors/XadillaX"],"categories":["JavaScript"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://github.com/XadillaX/thmclrx/raw/master/logo.svg\" alt=\"Thmclrx\" /\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/sponsors/XadillaX\"\u003e\u003cimg src=\"https://github.com/XadillaX/vscode-language-viml/raw/master/assets/github_sponsor_btn.png\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://www.npmjs.org/package/thmclrx\"\u003e\n    \u003cimg src=\"http://img.shields.io/npm/v/thmclrx.svg\" /\u003e\n  \u003c/a\u003e\n\n  \u003ca href=\"https://www.npmjs.org/package/thmclrx\"\u003e\n    \u003cimg src=\"http://img.shields.io/npm/dm/thmclrx.svg\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  A theme color extractor module for Node.js with ❤ and built on the top of \u003ca href=\"https://github.com/XadillaX/byakuren\"\u003eByakuren\u003c/a\u003e.\n\u003c/p\u003e\n\n## Algorithm\n\n- Minimum Differ Algorithm\n- Octree Algorithm\n- Mixed Algorithm\n\n## Installation\n\n```shell\n$ npm install --save thmclrx\n```\n\n## API\n\nThere only three API in Node.js now.\n\n### octree\n\n`octree` is to get the theme colors in an octree. The colors are unsertain but fidelity.\n\nThe function is like below:\n\n```javascript\nvar thmclrx = require(\"thmclrx\");\nthmclrx.octree(file, [maxColors], [callback], [frameNumber]);\n```\n\n+ `file`: it could be a local filename, remote url or even an image buffer.\n+ `maxColors`: count of max theme colors you want to extract. Defaults to 256;\n+ `callback`: it should be like `function(err, colors) {}`. Defaults to an empty function;\n+ `frameNumber`: the frame you want to extract. Usually used in `gif`. Defaults to 0.\n\n### minDiff\n\n`minDiff` is to get theme colors in minimum differ algorithm by passing a palette. The result theme colors are certainlly in your palette.\n\n```javascript\nvar thmclrx = require(\"thmclrx\");\nthmclrx.minDiff(file, [palette], [callback], [frameNumber]);\n```\n\n+ `file`: it could be a local filename, remote url or even an image buffer.\n+ `palette`: palette is an array that in the struct of `[ { r: .., g: .., b: .., }, { r: .., g: .., b: .. } ]`. Default palette refers [here](https://github.com/XadillaX/thmclrx/blob/master/lib/default_palette.js).\n+ `callback`: it should be like `function(err, colors) {}`. Defaults to an empty function;\n+ `frameNumber`: the frame you want to extract. Usually used in `gif`. Defaults to 0.\n\n### mixed\n\nUsing `mixed` get the basic fidelity theme colors and then using `minDiff` to standardize the fidelity theme colors to a certain palette.\n\n```javascript\nvar thmclrx = require(\"thmclrx\");\nthmclrx.mixed(file, [firstStepMaxColors], [palette], [callback], [frameNumber]);\n```\n\n+ `file`: same as the two functions above.\n+ `firstStepMaxColors`: same as the `maxColors` in `octreeGet`. Defaults to 256.\n+ `palette`: same as the `palette` in `mindiffGet`. Same default value.\n+ `callback`: same as the two functions above.\n+ `frameNumber`: same as the two functions above.\n\n## C++ API\n\nIf you want to use C++ API directly, you can refer to this.\n\n### getByOctree\n\nThis function is called in `octree` in Node.js API.\n\n```javascript\nvar thmclrx = require(\"thmclrx\").cpp;\nvar colors = thmclrx.getByOctree(pixels, [maxColor]);\n```\n\n+ `pixels`: this is an array in the struct of `[ { r: .., g: .., b: .., }, { r: .., g: .., b: .. } ]`.\n+ `maxColor`: same as the `maxColors` in `octreeGet` of Node.js API. Defaults to 256.\n+ `@return`: this function will return the theme colors.\n\n### getByMinDiff\n\nThis function is called in `minDiff` in Node.js API.\n\n```javascript\nvar thmclrx = require(\"thmclrx\").cpp;\nvar colors = thmclrx.getByMinDiff(pixels, [palette]);\n```\n\n+ `pixels`: this may be same as the `pixels` in `octreeGet` of C++ API. Otherwise, it may be the result of `octreeGet` of C++ API.\n+ `palette`: same as the `palette` in `mindiffGet` of Node.js API. Same default value.\n+ `@return`: this function will return the theme colors.\n\n### getByMixed\n\nThis function is called in `mixed` in Node.js API.\n\n```javascript\nvar thmclrx = require(\"thmclrx\").cpp;\nvar colors = thmclrx.getByMixed(pixels, maxColors, palette);\n```\n\n+ `pixels`: this may be same as the `pixels` in `octreeGet` of C++ API. Otherwise, it may be the result of `octreeGet` of C++ API.\n+ `maxColors`: same as the `maxColors` in `octreeGet` of Node.js API.\n+ `palette`: same as the `palette` in `mindiffGet` of Node.js API.\n+ `@return`: this function will return the theme colors.\n\n## Migrate From 0.x To 1.x\n\nthmclrx 0.x has three APIs which map three APIs in 1.x.\n\n+ octreeGet\n+ mindiffGet\n+ mixGet\n\nIn 1.x, these three APIs still exist but deprecated. They are exactly shallow points of `octree` / `minDiff` and `mixed`.\n\nYou may do nothing but we recommend you to rename the functions you called.\n\nBut if you're using native APIs (C++ APIs), you should read the [new document](#c-api).\n\n## Contribute\n\nIssues and PRs are welcomed!\n\n「雖然我覺得不怎麼可能有人會關注我」\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FXadillaX%2Fthmclrx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FXadillaX%2Fthmclrx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FXadillaX%2Fthmclrx/lists"}