Skip to content

Commit

Permalink
added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
camme committed Apr 9, 2014
1 parent f07913a commit c800f41
Show file tree
Hide file tree
Showing 6 changed files with 445 additions and 282 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.swp
/node_modules§
32 changes: 32 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "rlcolormixer",
"version": "0.6.0",
"description": "Mix colors as expected in real life (subtractive) in javascript.",
"main": "ryb-color-mixer.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://github.com/Camme/rlcolormixer.git"
},
"keywords": [
"color",
"mixer",
"rgb",
"ryb"
],
"author": "Camilo Tapia <camilo.tapia@gmail.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/Camme/rlcolormixer/issues"
},
"homepage": "https://github.com/Camme/rlcolormixer",
"devDependencies": {
"mocha": "^1.17.1",
"should": "^3.1.3"
},
"dependencies": {
"ryb2rgb": "0.0.0"
}
}
45 changes: 28 additions & 17 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,52 @@
#Real Life Color Mixer.
#Real Life Color (RYB) Mixer.

Emulate color mixing as if you where mixing real life colors, ie substractive colors

Usage:

RLColorMixer.mixColors(arrayOfColors);

rybColorMixer.mix(arrayOfColors [,options]);

// or

rybColorMixer.mix(color1, color2, color3.... [,options]);

Where arrayOfColos is an array of hex rgb colors ['#ff0000', '#00ff00']. Example:

RLColorMixer.mixColors(['#ff0000', '#00ff00']);
rybColorMixer.mix(['#ff0000', '#00ff00']);

You can pass an options object:

You can also pass the amount of each color you want to use:
{
hex: Boolean, // default is true
result: "ryb|rgb", // default is "ryb"
}

RLColorMixer.mixColors({color: '#ff0000', parts: 10}, {color: '#00ff00', parts: 2});
So, for example, if you want to return a mixed color as RGB:

Or a mixture of the two:

RLColorMixer.mixColors(['#ff0000', {color: '#00ff00', parts: 2}]);
rybColorMixer.mix('#ff0000', '#00ff00', { result: "rgb" });

You can also snap to the nearest color in an array of hex rgb colors:
You can also snap to the nearest color in an array of hex colors:

RLColorMixer.findNearest(orgColorinHex, listOfColors);
rybColorMixer.findNearest(orgColorinHex, listOfColors);

Example:

RLColorMixer.findNearest('#fff000', ['#ff0000', '#ff0f00']);
rybColorMixer.findNearest('#fff000', ['#ff0000', '#ff0f00']);

## List of all methods:

- RLColorMixer.mixColors(*array*); **Returns a RGB color in hex.**
- RLColorMixer.findNearest(*color*, *array*); **Returns a RGB color in hex.**
- RLColorMixer.hexToRgb(*string*); **Returns an array.**
- RLColorMixer.rgbToHex([*int*, *int*, *int*]); **Returns a RGB color in hex.**
- rybColorMixer.mix(*array* *[,options]*); **Returns a RGB color in hex.**
- rybColorMixer.mix(*color1, color2, color3, ...* *[,options]*); **Returns a RGB color in hex.**
- rybColorMixer.findNearest(*color*, *array*); **Returns a RGB color in hex.**
- rybColorMixer.rybToRgb(*color*); **convert a color from RYB to RGB.**

## More on how this works:
If you want to read how this works, just head over to [my blog](http://www.1001.io/mixing-real-colours-with-javascript-yellow-blue-green/)


## Dependecies
The source coude contains the code from https://github.com/bahamas10/node-rgb2ryb
I included the rgb2ryb code inside the rlcolormixer for ease of use in the browser. Great job @bahamas10.
I included the rgb2ryb code inside the ryb-color-mixer for ease of use in the browser. Great job @bahamas10.

-------------------------
## License
Expand Down
265 changes: 0 additions & 265 deletions rlcolormixer-0.5.0.js

This file was deleted.

Loading

0 comments on commit c800f41

Please sign in to comment.