7bfe77b9d29b654f65668c01129cc1940fddeb542b3e8e9615074f8815b1df8e406e392a548a0d475b89e32058029981a1737c20576b6e1dcc645d73370744 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. # Chroma.js
  2. Chroma.js is a tiny JavaScript library (8.5kB) for all kinds of color conversions and color scales.
  3. ### Usage
  4. Initiate and manipulate colors:
  5. ```javascript
  6. chroma('#D4F880').darken().hex(); // #9BC04B
  7. ```
  8. Working with color scales is easy, too:
  9. ```javascript
  10. scale = chroma.scale(['white', 'red']);
  11. scale(0.5).hex(); // #FF7F7F
  12. ```
  13. Lab/Lch interpolation looks better than than RGB
  14. ```javascript
  15. chroma.scale(['white', 'red']).mode('lab');
  16. ```
  17. Custom domains! Quantiles! Color Brewer!!
  18. ```javascript
  19. chroma.scale('RdYlBu').domain(myValues, 7, 'quantiles');
  20. ```
  21. And why not use logarithmic color scales once in your life?
  22. ```javascript
  23. chroma.scale(['lightyellow', 'navy']).domain([1, 100000], 7, 'log');
  24. ```
  25. ### Like it?
  26. Why not dive into the [API docs](https://github.com/gka/chroma.js/blob/master/doc/api.md) (quite short actually), and download [chroma.min.js](https://raw.github.com/gka/chroma.js/master/chroma.min.js) right away.
  27. You can use it in node.js, too!
  28. npm install chroma-js
  29. ### Build instructions
  30. To compile the coffee-script source files you have to run ``build.sh``.
  31. To run the tests simply run
  32. vows test/*.coffee
  33. ### Similar Libraries / Prior Art
  34. * [Chromatist](https://github.com/jrus/chromatist)
  35. * [GrapeFruit](https://github.com/xav/Grapefruit) (Python)
  36. * [colors.py](https://github.com/mattrobenolt/colors.py) (Python)
  37. * [d3.js](https://github.com/mbostock/d3)
  38. ### Author
  39. Chroma.js is written by [Gregor Aisch](http://driven-by-data.net).
  40. ### License
  41. Released under [BSD license](http://opensource.org/licenses/BSD-3-Clause).
  42. Versions prior to 0.4 were released under [GPL](http://www.gnu.org/licenses/gpl-3.0).
  43. ### Known issues
  44. * HSI color conversion is experimental and produces weird results sometimes
  45. ### Further reading
  46. * [How To Avoid Equidistant HSV Colors](https://vis4.net/blog/posts/avoid-equidistant-hsv-colors/)
  47. * [Mastering Multi-hued Color Scales with Chroma.js](https://vis4.net/blog/posts/mastering-multi-hued-color-scales/)