Need help with chromath?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

jfsiii
189 Stars 16 Forks 57 Commits 9 Opened issues

Description

JavaScript color conversion and manipulation functions

Services available

!
?

Need anything else?

Contributors list

# 24,776
Electro...
bash-pr...
bash-ha...
Bash
52 commits
# 178,107
JavaScr...
React
TypeScr...
redux-p...
1 commit
# 9,793
autohot...
ahk
bitwise...
Nette
1 commit

chromath

Overview

chromath provides provides many color conversion and manipulation functions.

You can:

  • Create a color from just about any reasonable string
  • Convert from one color space to another (rgb->hex, hsv->hsl, rgb->hex->hsl->rgb)
  • Add two colors (using additive or subtractive color)
  • Get a color scheme (complement, split complement, triad, tetrad, etc) based on a color
  • Lots more. Take a look at the docs

Getting started

In the browser:


In NodeJS:

npm install chromath

then

var Chromath = require('chromath')

From there, the usage is identical in both environments.

Functional or Object-oriented

You can use chromath in a functional or object-oriented manner.

var red = new Chromath('rgb(255, 0, 0)');
red.towards('yellow', 0.5).toString(); // #FF7F00

is the same as

Chromath.towards('red', 'yellow', 0.5).toString(); // #FF7F00

The only difference between instance methods and Class methods with the same name (e.g,

Chromath.tint
and
tint
) is that the instance methods pass the instance value as the first argument.

Here's the definition of

Chromath.prototype.tint
:
tint: function (by) {
    return Chromath.tint(this, by);
}

In NodeJS you can only pull in the portions you're interesed in, e.g:

> var fromRGBToHex = require('chromath').rgb2hex
> fromRGBToHex(234, 56, 78)
'#EA384E'

Documentation

http://JFSIII.org/project/chromath/docs/

License

MIT

Bitdeli Badge

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.