npm install rainbow-dash
In the browser, simply copy
/lib/rainbow-dash.min.js and include it in your site:
var rainbowDash = ;var gradeScale =;; // Returns 'rgb(0,0,255)'; // Returns 'rgb(0,127,127)'; // Returns 'rgb(255,0,0)'var hexOut =;; // Returns '#0000ff'; // Returns '#00ff00'; // Returns '#ff0000'var uniformSpacing =;; // Returns 'rgb(255,0,0)'; // Returns 'rgb(255,153,0)'; // Returns 'rgb(255,255,0)'; // Returns 'rgb(0,255,0)'; // Returns 'rgb(0,0,255)'; // Returns 'rgb(255,0,255)'
rainbow-dash precalculates interpolation constants for all specified ranges to make the interpolation calculation as fast as possible. This makes it faster than even using
<canvas> to calculate the desired values (in fact, if you don't want to be ridiculously wasteful with your memory, you need to scale the input, anyways, and lose any gain you could have had from that approach).
This means that rainbow-dash gets over 4.3 million samples/sec on Travis CI versus the less than 100k most commonly seen on jsperf for
<canvas> queries (with a maximum of 425k with Opera) and far less memory usage to do so.
Copyright (C) 2013 by Uber Technologies, Inc
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.