XadillaX / thmclrx

:art: A theme color extractor module for Node.js.
http://blog.xcoder.in/thmclrx-stress-tester/result/
MIT License
205 stars 21 forks source link
c-plus-plus nodejs theme-color

Thmclrx

A theme color extractor module for Node.js with ❤ and built on the top of Byakuren.

Algorithm

Installation

$ npm install --save thmclrx

API

There only three API in Node.js now.

octree

octree is to get the theme colors in an octree. The colors are unsertain but fidelity.

The function is like below:

var thmclrx = require("thmclrx");
thmclrx.octree(file, [maxColors], [callback], [frameNumber]);

minDiff

minDiff is to get theme colors in minimum differ algorithm by passing a palette. The result theme colors are certainlly in your palette.

var thmclrx = require("thmclrx");
thmclrx.minDiff(file, [palette], [callback], [frameNumber]);

mixed

Using mixed get the basic fidelity theme colors and then using minDiff to standardize the fidelity theme colors to a certain palette.

var thmclrx = require("thmclrx");
thmclrx.mixed(file, [firstStepMaxColors], [palette], [callback], [frameNumber]);

C++ API

If you want to use C++ API directly, you can refer to this.

getByOctree

This function is called in octree in Node.js API.

var thmclrx = require("thmclrx").cpp;
var colors = thmclrx.getByOctree(pixels, [maxColor]);

getByMinDiff

This function is called in minDiff in Node.js API.

var thmclrx = require("thmclrx").cpp;
var colors = thmclrx.getByMinDiff(pixels, [palette]);

getByMixed

This function is called in mixed in Node.js API.

var thmclrx = require("thmclrx").cpp;
var colors = thmclrx.getByMixed(pixels, maxColors, palette);

Migrate From 0.x To 1.x

thmclrx 0.x has three APIs which map three APIs in 1.x.

In 1.x, these three APIs still exist but deprecated. They are exactly shallow points of octree / minDiff and mixed.

You may do nothing but we recommend you to rename the functions you called.

But if you're using native APIs (C++ APIs), you should read the new document.

Contribute

Issues and PRs are welcomed!

「雖然我覺得不怎麼可能有人會關注我」