Giter Site home page Giter Site logo

leeleoo / thmclrx Goto Github PK

View Code? Open in Web Editor NEW

This project forked from xadillax/thmclrx

0.0 0.0 1.0 465 KB

:art: A theme color extractor module for Node.js.

Home Page: http://blog.xcoder.in/thmclrx-stress-tester/result/

License: MIT License

Python 3.73% JavaScript 55.07% C++ 41.19%

thmclrx's Introduction

ThmclrX

thmclrx thmclrx

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

Algorithm

  • Minimum Differ Algorithm
  • Octree Algorithm
  • Mixed Algorithm

Installation

$ npm install thmclrx --save

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]);
  • file: it could be a local filename, remote url or even an image buffer.
  • maxColors: count of max theme colors you want to extract. Defaults to 256;
  • callback: it should be like function(err, colors) {}. Defaults to an empty function;
  • frameNumber: the frame you want to extract. Usually used in gif. Defaults to 0.

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]);
  • file: it could be a local filename, remote url or even an image buffer.
  • palette: palette is an array that in the struct of [ { r: .., g: .., b: .., }, { r: .., g: .., b: .. } ]. Default palette refers here.
  • callback: it should be like function(err, colors) {}. Defaults to an empty function;
  • frameNumber: the frame you want to extract. Usually used in gif. Defaults to 0.

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]);
  • file: same as the two functions above.
  • firstStepMaxColors: same as the maxColors in octreeGet. Defaults to 256.
  • palette: same as the palette in mindiffGet. Same default value.
  • callback: same as the two functions above.
  • frameNumber: same as the two functions above.

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]);
  • pixels: this is an array in the struct of [ { r: .., g: .., b: .., }, { r: .., g: .., b: .. } ].
  • maxColor: same as the maxColors in octreeGet of Node.js API. Defaults to 256.
  • @return: this function will return the theme colors.

getByMinDiff

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

var thmclrx = require("thmclrx").cpp;
var colors = thmclrx.getByMinDiff(pixels, [palette]);
  • pixels: this may be same as the pixels in octreeGet of C++ API. Otherwise, it may be the result of octreeGet of C++ API.
  • palette: same as the palette in mindiffGet of Node.js API. Same default value.
  • @return: this function will return the theme colors.

getByMixed

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

var thmclrx = require("thmclrx").cpp;
var colors = thmclrx.getByMixed(pixels, maxColors, palette);
  • pixels: this may be same as the pixels in octreeGet of C++ API. Otherwise, it may be the result of octreeGet of C++ API.
  • maxColors: same as the maxColors in octreeGet of Node.js API.
  • palette: same as the palette in mindiffGet of Node.js API.
  • @return: this function will return the theme colors.

Migrate From 0.x To 1.x

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

  • octreeGet
  • mindiffGet
  • mixGet

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

You're welcome to fork and make pull requests!

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

thmclrx's People

Contributors

xadillax avatar

Forkers

piksongit

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.