[Pkg-javascript-commits] [node-chroma-js] 01/05: Imported Upstream version 1.1.1

Ross Gammon ross-guest at moszumanska.debian.org
Tue Dec 20 18:48:47 UTC 2016


This is an automated email from the git hooks/post-receive script.

ross-guest pushed a commit to branch master
in repository node-chroma-js.

commit fca08e3b695f2981ae3dc543c53500b33f6866a8
Author: Ross Gammon <rossgammon at mail.dk>
Date:   Sat Nov 19 11:42:13 2016 +0100

    Imported Upstream version 1.1.1
---
 .gitignore                               |    9 +
 .travis.yml                              |    6 +
 CHANGELOG                                |   21 +
 Gruntfile.js                             |   74 +
 LICENSE                                  |   28 +
 LICENSE-colors                           |   22 +
 bower.json                               |   33 +
 chroma.js                                | 2465 ++++++++++++++++++++++++++++++
 chroma.min.js                            |   33 +
 doc/api.md                               |  389 +++++
 package.json                             |   52 +
 readme.md                                |   89 ++
 src/analyze.coffee                       |   24 +
 src/api.coffee                           |   20 +
 src/color.coffee                         |   83 +
 src/colors/colorbrewer.coffee            |   63 +
 src/colors/w3cx11.coffee                 |  157 ++
 src/converter/in/cmyk2rgb.coffee         |   10 +
 src/converter/in/css2rgb.coffee          |   45 +
 src/converter/in/hex2rgb.coffee          |   29 +
 src/converter/in/hsi2rgb.coffee          |   32 +
 src/converter/in/hsl2rgb.coffee          |   29 +
 src/converter/in/hsv2rgb.coffee          |   28 +
 src/converter/in/lab2rgb.coffee          |   31 +
 src/converter/in/lch2rgb.coffee          |    8 +
 src/converter/in/num2rgb.coffee          |   10 +
 src/converter/in/temperature2rgb.coffee  |   18 +
 src/converter/misc/lab-constants.coffee  |   16 +
 src/converter/misc/lab2lch.coffee        |    8 +
 src/converter/misc/lch2lab.coffee        |   13 +
 src/converter/out/hsl2css.coffee         |   11 +
 src/converter/out/rgb2cmyk.coffee        |   12 +
 src/converter/out/rgb2css.coffee         |   10 +
 src/converter/out/rgb2hex.coffee         |   12 +
 src/converter/out/rgb2hsi.coffee         |   26 +
 src/converter/out/rgb2hsl.coffee         |   26 +
 src/converter/out/rgb2hsv.coffee         |   18 +
 src/converter/out/rgb2lab.coffee         |   22 +
 src/converter/out/rgb2lch.coffee         |    6 +
 src/converter/out/rgb2luminance.coffee   |   16 +
 src/converter/out/rgb2num.coffee         |    4 +
 src/converter/out/rgb2temperature.coffee |   20 +
 src/generator/bezier.coffee              |   43 +
 src/generator/cubehelix.coffee           |   94 ++
 src/generator/random.coffee              |    7 +
 src/index.coffee                         |   34 +
 src/interpolator/interpolate-hsx.coffee  |   44 +
 src/interpolator/interpolate-lab.coffee  |   13 +
 src/interpolator/interpolate-num.coffee  |    8 +
 src/interpolator/interpolate-rgb.coffee  |   13 +
 src/interpolator/interpolate.coffee      |   35 +
 src/io/cmyk.coffee                       |   11 +
 src/io/contrast.coffee                   |    9 +
 src/io/css.coffee                        |   13 +
 src/io/gl.coffee                         |   14 +
 src/io/hex.coffee                        |   15 +
 src/io/hsi.coffee                        |   11 +
 src/io/hsl.coffee                        |   11 +
 src/io/hsv.coffee                        |    9 +
 src/io/lab.coffee                        |   11 +
 src/io/lch.coffee                        |   23 +
 src/io/luminance.coffee                  |   23 +
 src/io/named.coffee                      |   23 +
 src/io/num.coffee                        |   14 +
 src/io/rgb.coffee                        |   20 +
 src/io/temperature.coffee                |   12 +
 src/limits.coffee                        |  169 ++
 src/ops/blend.coffee                     |   68 +
 src/ops/darken.coffee                    |   13 +
 src/ops/get.coffee                       |   14 +
 src/ops/premultiply.coffee               |    6 +
 src/ops/saturate.coffee                  |   11 +
 src/ops/set.coffee                       |   24 +
 src/scale.coffee                         |  249 +++
 src/utils.coffee                         |   41 +
 test/alpha-test.coffee                   |  112 ++
 test/analyze-test.coffee                 |   42 +
 test/bezier-test.coffee                  |   54 +
 test/blend-test.coffee                   |   25 +
 test/cache-performance.coffee            |   19 +
 test/cmyk-test.coffee                    |   45 +
 test/colors-test.coffee                  |   70 +
 test/contrast-test.coffee                |   24 +
 test/cubehelix-test.coffee               |   61 +
 test/get-test.coffee                     |   14 +
 test/gl-test.coffee                      |   27 +
 test/guess-format-test.coffee            |   91 ++
 test/html/bezier.html                    |   51 +
 test/html/blend.html                     |   70 +
 test/html/colorscales.html               |   73 +
 test/html/cubehelix.html                 |   58 +
 test/html/luminance.html                 |   50 +
 test/interpolate-test.coffee             |   80 +
 test/lch-test.coffee                     |   28 +
 test/lcorrection-test.coffee             |   54 +
 test/limits-test.coffee                  |   46 +
 test/luminance-test.coffee               |   60 +
 test/manipulate-test.coffee              |   36 +
 test/num-test.coffee                     |   27 +
 test/random-test.coffee                  |   16 +
 test/scales-test.coffee                  |  140 ++
 test/set-test.coffee                     |   15 +
 test/temperature-test.coffee             |   29 +
 test/utils-test.coffee                   |   23 +
 104 files changed, 6573 insertions(+)

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..8f32fb5
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,9 @@
+
+readme (Autosaved).md
+
+m.txt
+
+.DS_Store
+license.coffee
+node_modules
+
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..266ea0d
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,6 @@
+language: node_js
+node_js:
+  - 0.12
+  - 0.11
+before_script: "npm install -g grunt-cli"
+script: "npm run-script build"
\ No newline at end of file
diff --git a/CHANGELOG b/CHANGELOG
new file mode 100644
index 0000000..d5c096f
--- /dev/null
+++ b/CHANGELOG
@@ -0,0 +1,21 @@
+# 1.1.0
+
+* refactored chroma.scale
+* changed behaviour of scale.domain
+* added scale.classes
+* added scale.padding
+
+# 1.0.2
+
+* standardized alpha channel construction
+* chroma.bezier automatically returns chroma.scale
+
+# 1.0.1
+
+* added simple color output to chroma.scale().colors()
+
+# 1.0.0
+
+* numeric interpolation does what it should
+* refactored and modularized code base
+* changed argument order of Color::interpolate 
\ No newline at end of file
diff --git a/Gruntfile.js b/Gruntfile.js
new file mode 100644
index 0000000..f2ef43a
--- /dev/null
+++ b/Gruntfile.js
@@ -0,0 +1,74 @@
+"use strict";
+
+var fs = require('fs'),
+  pkgInfo = JSON.parse(fs.readFileSync(__dirname + '/package.json'));
+
+module.exports = function(grunt) {
+
+  grunt.initConfig({
+    clean: {
+      pre: [
+        'chroma.js',
+        'chroma.min.js',
+        'license.coffee',
+      ],
+      post: ['chroma.coffee']
+    },
+    coffee: {
+      compile: {
+        options: {
+          join: true
+        },
+        files: {
+          'chroma.js': [
+            'license.coffee',
+            'chroma.coffee'
+          ],
+        },
+      }
+    },
+    replace: {
+      dist: {
+        options: { patterns: [{ match: 'version', replacement: pkgInfo.version }] },
+        files: [{expand: true, flatten: true, src: ['chroma.js'], dest: '.'}]
+      }
+    },
+    uglify: {
+      options: {
+        banner: "/*\n" + fs.readFileSync("LICENSE", {encoding: "utf8"}) + "\n*/\n",
+      },
+      my_target: {
+        files: {
+          'chroma.min.js': ['chroma.js']
+        },
+      },
+    },
+  });
+
+  grunt.loadNpmTasks('grunt-contrib-clean');
+  grunt.loadNpmTasks('grunt-contrib-coffee');
+  grunt.loadNpmTasks('grunt-replace');
+  grunt.loadNpmTasks('grunt-contrib-uglify');
+
+  grunt.registerTask('license', function() {
+    var license = [
+      "###*",
+      " * @license",
+      " *",
+    ].concat(fs.readFileSync('LICENSE', {encoding: "utf8"}).split("\n").map(function(line) {
+      return " * " + line;
+    }));
+    license.push("###\n");
+    fs.writeFileSync('license.coffee', license.join("\n"));
+  });
+
+  grunt.registerTask('catty', function() {
+    require("catty")({ global: true })
+      .coffee(true)
+      .addLibrary("src")
+      .cat("src/index.coffee", "./chroma.coffee");
+  });
+
+  grunt.registerTask('default', ['clean:pre', 'license', 'catty', 'coffee', 'replace', 'uglify', 'clean:post']);
+};
+
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..7c59371
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,28 @@
+chroma.js - JavaScript library for color conversions
+
+Copyright (c) 2011-2015, Gregor Aisch
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this
+   list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright notice,
+   this list of conditions and the following disclaimer in the documentation
+   and/or other materials provided with the distribution.
+
+3. The name Gregor Aisch may not be used to endorse or promote products
+   derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL GREGOR AISCH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/LICENSE-colors b/LICENSE-colors
new file mode 100644
index 0000000..7e431b6
--- /dev/null
+++ b/LICENSE-colors
@@ -0,0 +1,22 @@
+
+chroma.js includes colors from colorbrewer2.org,
+which are released under the following license:
+
+
+Copyright (c) 2002 Cynthia Brewer, Mark Harrower, 
+and The Pennsylvania State University.
+
+Licensed under the Apache License, Version 2.0 (the "License"); 
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at	
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, 
+software distributed under the License is distributed on an 
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
+either express or implied. See the License for the specific 
+language governing permissions and limitations under the License.
+
+
+Named colors are taken from X11 Color Names.
+http://www.w3.org/TR/css3-color/#svg-color
diff --git a/bower.json b/bower.json
new file mode 100644
index 0000000..db19116
--- /dev/null
+++ b/bower.json
@@ -0,0 +1,33 @@
+{
+  "name": "chroma-js",
+  "description": "JavaScript library for color conversions",
+  "main": [
+    "./chroma.js"
+  ],
+  "ignore": [
+    "doc",
+    "src",
+    "**/.*",
+    "node_modules",
+    "bower_components",
+    "test",
+    "tests"
+  ],
+  "homepage": "https://github.com/gka/chroma.js",
+  "authors": [
+    "Gregor Aisch <contact at vis4.net>"
+  ],
+  "keywords": [
+    "color",
+    "scale",
+    "gradient",
+    "scheme",
+    "rgb",
+    "hsv",
+    "hsl",
+    "css",
+    "lch",
+    "lab"
+  ],
+  "license": "MIT"
+}
diff --git a/chroma.js b/chroma.js
new file mode 100644
index 0000000..54e1410
--- /dev/null
+++ b/chroma.js
@@ -0,0 +1,2465 @@
+
+/**
+ * @license
+ *
+ * chroma.js - JavaScript library for color conversions
+ * 
+ * Copyright (c) 2011-2015, Gregor Aisch
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ *    list of conditions and the following disclaimer.
+ * 
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution.
+ * 
+ * 3. The name Gregor Aisch may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL GREGOR AISCH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+(function() {
+  var Color, DEG2RAD, LAB_CONSTANTS, PI, PITHIRD, RAD2DEG, TWOPI, _guess_formats, _guess_formats_sorted, _input, _interpolators, abs, atan2, bezier, blend, blend_f, brewer, burn, chroma, clip_rgb, cmyk2rgb, colors, cos, css2rgb, darken, dodge, each, floor, hex2rgb, hsi2rgb, hsl2css, hsl2rgb, hsv2rgb, interpolate, interpolate_hsx, interpolate_lab, interpolate_num, interpolate_rgb, lab2lch, lab2rgb, lab_xyz, lch2lab, lch2rgb, lighten, limit, log, luminance_x, m, max, multiply, normal, num2 [...]
+    slice = [].slice;
+
+  type = (function() {
+
+    /*
+    for browser-safe type checking+
+    ported from jQuery's $.type
+     */
+    var classToType, len, name, o, ref;
+    classToType = {};
+    ref = "Boolean Number String Function Array Date RegExp Undefined Null".split(" ");
+    for (o = 0, len = ref.length; o < len; o++) {
+      name = ref[o];
+      classToType["[object " + name + "]"] = name.toLowerCase();
+    }
+    return function(obj) {
+      var strType;
+      strType = Object.prototype.toString.call(obj);
+      return classToType[strType] || "object";
+    };
+  })();
+
+  limit = function(x, min, max) {
+    if (min == null) {
+      min = 0;
+    }
+    if (max == null) {
+      max = 1;
+    }
+    if (x < min) {
+      x = min;
+    }
+    if (x > max) {
+      x = max;
+    }
+    return x;
+  };
+
+  unpack = function(args) {
+    if (args.length >= 3) {
+      return [].slice.call(args);
+    } else {
+      return args[0];
+    }
+  };
+
+  clip_rgb = function(rgb) {
+    var i;
+    for (i in rgb) {
+      if (i < 3) {
+        if (rgb[i] < 0) {
+          rgb[i] = 0;
+        }
+        if (rgb[i] > 255) {
+          rgb[i] = 255;
+        }
+      } else if (i === 3) {
+        if (rgb[i] < 0) {
+          rgb[i] = 0;
+        }
+        if (rgb[i] > 1) {
+          rgb[i] = 1;
+        }
+      }
+    }
+    return rgb;
+  };
+
+  PI = Math.PI, round = Math.round, cos = Math.cos, floor = Math.floor, pow = Math.pow, log = Math.log, sin = Math.sin, sqrt = Math.sqrt, atan2 = Math.atan2, max = Math.max, abs = Math.abs;
+
+  TWOPI = PI * 2;
+
+  PITHIRD = PI / 3;
+
+  DEG2RAD = PI / 180;
+
+  RAD2DEG = 180 / PI;
+
+  chroma = function() {
+    if (arguments[0] instanceof Color) {
+      return arguments[0];
+    }
+    return (function(func, args, ctor) {
+      ctor.prototype = func.prototype;
+      var child = new ctor, result = func.apply(child, args);
+      return Object(result) === result ? result : child;
+    })(Color, arguments, function(){});
+  };
+
+  _interpolators = [];
+
+  if ((typeof module !== "undefined" && module !== null) && (module.exports != null)) {
+    module.exports = chroma;
+  }
+
+  if (typeof define === 'function' && define.amd) {
+    define([], function() {
+      return chroma;
+    });
+  } else {
+    root = typeof exports !== "undefined" && exports !== null ? exports : this;
+    root.chroma = chroma;
+  }
+
+  chroma.version = '1.1.1';
+
+
+  /**
+      chroma.js
+  
+      Copyright (c) 2011-2013, Gregor Aisch
+      All rights reserved.
+  
+      Redistribution and use in source and binary forms, with or without
+      modification, are permitted provided that the following conditions are met:
+  
+      * Redistributions of source code must retain the above copyright notice, this
+        list of conditions and the following disclaimer.
+  
+      * Redistributions in binary form must reproduce the above copyright notice,
+        this list of conditions and the following disclaimer in the documentation
+        and/or other materials provided with the distribution.
+  
+      * The name Gregor Aisch may not be used to endorse or promote products
+        derived from this software without specific prior written permission.
+  
+      THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+      AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+      IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+      DISCLAIMED. IN NO EVENT SHALL GREGOR AISCH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+      INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+      BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+      DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+      OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+      NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+      EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+  
+      @source: https://github.com/gka/chroma.js
+   */
+
+  _input = {};
+
+  _guess_formats = [];
+
+  _guess_formats_sorted = false;
+
+  Color = (function() {
+    function Color() {
+      var arg, args, chk, len, len1, me, mode, o, w;
+      me = this;
+      args = [];
+      for (o = 0, len = arguments.length; o < len; o++) {
+        arg = arguments[o];
+        if (arg != null) {
+          args.push(arg);
+        }
+      }
+      mode = args[args.length - 1];
+      if (_input[mode] != null) {
+        me._rgb = clip_rgb(_input[mode](unpack(args.slice(0, -1))));
+      } else {
+        if (!_guess_formats_sorted) {
+          _guess_formats = _guess_formats.sort(function(a, b) {
+            return b.p - a.p;
+          });
+          _guess_formats_sorted = true;
+        }
+        for (w = 0, len1 = _guess_formats.length; w < len1; w++) {
+          chk = _guess_formats[w];
+          mode = chk.test.apply(chk, args);
+          if (mode) {
+            break;
+          }
+        }
+        if (mode) {
+          me._rgb = clip_rgb(_input[mode].apply(_input, args));
+        }
+      }
+      if (me._rgb == null) {
+        console.warn('unknown format: ' + args);
+      }
+      if (me._rgb == null) {
+        me._rgb = [0, 0, 0];
+      }
+      if (me._rgb.length === 3) {
+        me._rgb.push(1);
+      }
+    }
+
+    Color.prototype.alpha = function(alpha) {
+      if (arguments.length) {
+        this._rgb[3] = alpha;
+        return this;
+      }
+      return this._rgb[3];
+    };
+
+    Color.prototype.toString = function() {
+      return this.name();
+    };
+
+    return Color;
+
+  })();
+
+  chroma._input = _input;
+
+
+  /**
+  	ColorBrewer colors for chroma.js
+  
+  	Copyright (c) 2002 Cynthia Brewer, Mark Harrower, and The 
+  	Pennsylvania State University.
+  
+  	Licensed under the Apache License, Version 2.0 (the "License"); 
+  	you may not use this file except in compliance with the License.
+  	You may obtain a copy of the License at	
+  	http://www.apache.org/licenses/LICENSE-2.0
+  
+  	Unless required by applicable law or agreed to in writing, software distributed
+  	under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+  	CONDITIONS OF ANY KIND, either express or implied. See the License for the
+  	specific language governing permissions and limitations under the License.
+  
+      @preserve
+   */
+
+  chroma.brewer = brewer = {
+    OrRd: ['#fff7ec', '#fee8c8', '#fdd49e', '#fdbb84', '#fc8d59', '#ef6548', '#d7301f', '#b30000', '#7f0000'],
+    PuBu: ['#fff7fb', '#ece7f2', '#d0d1e6', '#a6bddb', '#74a9cf', '#3690c0', '#0570b0', '#045a8d', '#023858'],
+    BuPu: ['#f7fcfd', '#e0ecf4', '#bfd3e6', '#9ebcda', '#8c96c6', '#8c6bb1', '#88419d', '#810f7c', '#4d004b'],
+    Oranges: ['#fff5eb', '#fee6ce', '#fdd0a2', '#fdae6b', '#fd8d3c', '#f16913', '#d94801', '#a63603', '#7f2704'],
+    BuGn: ['#f7fcfd', '#e5f5f9', '#ccece6', '#99d8c9', '#66c2a4', '#41ae76', '#238b45', '#006d2c', '#00441b'],
+    YlOrBr: ['#ffffe5', '#fff7bc', '#fee391', '#fec44f', '#fe9929', '#ec7014', '#cc4c02', '#993404', '#662506'],
+    YlGn: ['#ffffe5', '#f7fcb9', '#d9f0a3', '#addd8e', '#78c679', '#41ab5d', '#238443', '#006837', '#004529'],
+    Reds: ['#fff5f0', '#fee0d2', '#fcbba1', '#fc9272', '#fb6a4a', '#ef3b2c', '#cb181d', '#a50f15', '#67000d'],
+    RdPu: ['#fff7f3', '#fde0dd', '#fcc5c0', '#fa9fb5', '#f768a1', '#dd3497', '#ae017e', '#7a0177', '#49006a'],
+    Greens: ['#f7fcf5', '#e5f5e0', '#c7e9c0', '#a1d99b', '#74c476', '#41ab5d', '#238b45', '#006d2c', '#00441b'],
+    YlGnBu: ['#ffffd9', '#edf8b1', '#c7e9b4', '#7fcdbb', '#41b6c4', '#1d91c0', '#225ea8', '#253494', '#081d58'],
+    Purples: ['#fcfbfd', '#efedf5', '#dadaeb', '#bcbddc', '#9e9ac8', '#807dba', '#6a51a3', '#54278f', '#3f007d'],
+    GnBu: ['#f7fcf0', '#e0f3db', '#ccebc5', '#a8ddb5', '#7bccc4', '#4eb3d3', '#2b8cbe', '#0868ac', '#084081'],
+    Greys: ['#ffffff', '#f0f0f0', '#d9d9d9', '#bdbdbd', '#969696', '#737373', '#525252', '#252525', '#000000'],
+    YlOrRd: ['#ffffcc', '#ffeda0', '#fed976', '#feb24c', '#fd8d3c', '#fc4e2a', '#e31a1c', '#bd0026', '#800026'],
+    PuRd: ['#f7f4f9', '#e7e1ef', '#d4b9da', '#c994c7', '#df65b0', '#e7298a', '#ce1256', '#980043', '#67001f'],
+    Blues: ['#f7fbff', '#deebf7', '#c6dbef', '#9ecae1', '#6baed6', '#4292c6', '#2171b5', '#08519c', '#08306b'],
+    PuBuGn: ['#fff7fb', '#ece2f0', '#d0d1e6', '#a6bddb', '#67a9cf', '#3690c0', '#02818a', '#016c59', '#014636'],
+    Spectral: ['#9e0142', '#d53e4f', '#f46d43', '#fdae61', '#fee08b', '#ffffbf', '#e6f598', '#abdda4', '#66c2a5', '#3288bd', '#5e4fa2'],
+    RdYlGn: ['#a50026', '#d73027', '#f46d43', '#fdae61', '#fee08b', '#ffffbf', '#d9ef8b', '#a6d96a', '#66bd63', '#1a9850', '#006837'],
+    RdBu: ['#67001f', '#b2182b', '#d6604d', '#f4a582', '#fddbc7', '#f7f7f7', '#d1e5f0', '#92c5de', '#4393c3', '#2166ac', '#053061'],
+    PiYG: ['#8e0152', '#c51b7d', '#de77ae', '#f1b6da', '#fde0ef', '#f7f7f7', '#e6f5d0', '#b8e186', '#7fbc41', '#4d9221', '#276419'],
+    PRGn: ['#40004b', '#762a83', '#9970ab', '#c2a5cf', '#e7d4e8', '#f7f7f7', '#d9f0d3', '#a6dba0', '#5aae61', '#1b7837', '#00441b'],
+    RdYlBu: ['#a50026', '#d73027', '#f46d43', '#fdae61', '#fee090', '#ffffbf', '#e0f3f8', '#abd9e9', '#74add1', '#4575b4', '#313695'],
+    BrBG: ['#543005', '#8c510a', '#bf812d', '#dfc27d', '#f6e8c3', '#f5f5f5', '#c7eae5', '#80cdc1', '#35978f', '#01665e', '#003c30'],
+    RdGy: ['#67001f', '#b2182b', '#d6604d', '#f4a582', '#fddbc7', '#ffffff', '#e0e0e0', '#bababa', '#878787', '#4d4d4d', '#1a1a1a'],
+    PuOr: ['#7f3b08', '#b35806', '#e08214', '#fdb863', '#fee0b6', '#f7f7f7', '#d8daeb', '#b2abd2', '#8073ac', '#542788', '#2d004b'],
+    Set2: ['#66c2a5', '#fc8d62', '#8da0cb', '#e78ac3', '#a6d854', '#ffd92f', '#e5c494', '#b3b3b3'],
+    Accent: ['#7fc97f', '#beaed4', '#fdc086', '#ffff99', '#386cb0', '#f0027f', '#bf5b17', '#666666'],
+    Set1: ['#e41a1c', '#377eb8', '#4daf4a', '#984ea3', '#ff7f00', '#ffff33', '#a65628', '#f781bf', '#999999'],
+    Set3: ['#8dd3c7', '#ffffb3', '#bebada', '#fb8072', '#80b1d3', '#fdb462', '#b3de69', '#fccde5', '#d9d9d9', '#bc80bd', '#ccebc5', '#ffed6f'],
+    Dark2: ['#1b9e77', '#d95f02', '#7570b3', '#e7298a', '#66a61e', '#e6ab02', '#a6761d', '#666666'],
+    Paired: ['#a6cee3', '#1f78b4', '#b2df8a', '#33a02c', '#fb9a99', '#e31a1c', '#fdbf6f', '#ff7f00', '#cab2d6', '#6a3d9a', '#ffff99', '#b15928'],
+    Pastel2: ['#b3e2cd', '#fdcdac', '#cbd5e8', '#f4cae4', '#e6f5c9', '#fff2ae', '#f1e2cc', '#cccccc'],
+    Pastel1: ['#fbb4ae', '#b3cde3', '#ccebc5', '#decbe4', '#fed9a6', '#ffffcc', '#e5d8bd', '#fddaec', '#f2f2f2']
+  };
+
+
+  /**
+  	X11 color names
+  
+  	http://www.w3.org/TR/css3-color/#svg-color
+   */
+
+  w3cx11 = {
+    indigo: "#4b0082",
+    gold: "#ffd700",
+    hotpink: "#ff69b4",
+    firebrick: "#b22222",
+    indianred: "#cd5c5c",
+    yellow: "#ffff00",
+    mistyrose: "#ffe4e1",
+    darkolivegreen: "#556b2f",
+    olive: "#808000",
+    darkseagreen: "#8fbc8f",
+    pink: "#ffc0cb",
+    tomato: "#ff6347",
+    lightcoral: "#f08080",
+    orangered: "#ff4500",
+    navajowhite: "#ffdead",
+    lime: "#00ff00",
+    palegreen: "#98fb98",
+    darkslategrey: "#2f4f4f",
+    greenyellow: "#adff2f",
+    burlywood: "#deb887",
+    seashell: "#fff5ee",
+    mediumspringgreen: "#00fa9a",
+    fuchsia: "#ff00ff",
+    papayawhip: "#ffefd5",
+    blanchedalmond: "#ffebcd",
+    chartreuse: "#7fff00",
+    dimgray: "#696969",
+    black: "#000000",
+    peachpuff: "#ffdab9",
+    springgreen: "#00ff7f",
+    aquamarine: "#7fffd4",
+    white: "#ffffff",
+    orange: "#ffa500",
+    lightsalmon: "#ffa07a",
+    darkslategray: "#2f4f4f",
+    brown: "#a52a2a",
+    ivory: "#fffff0",
+    dodgerblue: "#1e90ff",
+    peru: "#cd853f",
+    lawngreen: "#7cfc00",
+    chocolate: "#d2691e",
+    crimson: "#dc143c",
+    forestgreen: "#228b22",
+    darkgrey: "#a9a9a9",
+    lightseagreen: "#20b2aa",
+    cyan: "#00ffff",
+    mintcream: "#f5fffa",
+    silver: "#c0c0c0",
+    antiquewhite: "#faebd7",
+    mediumorchid: "#ba55d3",
+    skyblue: "#87ceeb",
+    gray: "#808080",
+    darkturquoise: "#00ced1",
+    goldenrod: "#daa520",
+    darkgreen: "#006400",
+    floralwhite: "#fffaf0",
+    darkviolet: "#9400d3",
+    darkgray: "#a9a9a9",
+    moccasin: "#ffe4b5",
+    saddlebrown: "#8b4513",
+    grey: "#808080",
+    darkslateblue: "#483d8b",
+    lightskyblue: "#87cefa",
+    lightpink: "#ffb6c1",
+    mediumvioletred: "#c71585",
+    slategrey: "#708090",
+    red: "#ff0000",
+    deeppink: "#ff1493",
+    limegreen: "#32cd32",
+    darkmagenta: "#8b008b",
+    palegoldenrod: "#eee8aa",
+    plum: "#dda0dd",
+    turquoise: "#40e0d0",
+    lightgrey: "#d3d3d3",
+    lightgoldenrodyellow: "#fafad2",
+    darkgoldenrod: "#b8860b",
+    lavender: "#e6e6fa",
+    maroon: "#800000",
+    yellowgreen: "#9acd32",
+    sandybrown: "#f4a460",
+    thistle: "#d8bfd8",
+    violet: "#ee82ee",
+    navy: "#000080",
+    magenta: "#ff00ff",
+    dimgrey: "#696969",
+    tan: "#d2b48c",
+    rosybrown: "#bc8f8f",
+    olivedrab: "#6b8e23",
+    blue: "#0000ff",
+    lightblue: "#add8e6",
+    ghostwhite: "#f8f8ff",
+    honeydew: "#f0fff0",
+    cornflowerblue: "#6495ed",
+    slateblue: "#6a5acd",
+    linen: "#faf0e6",
+    darkblue: "#00008b",
+    powderblue: "#b0e0e6",
+    seagreen: "#2e8b57",
+    darkkhaki: "#bdb76b",
+    snow: "#fffafa",
+    sienna: "#a0522d",
+    mediumblue: "#0000cd",
+    royalblue: "#4169e1",
+    lightcyan: "#e0ffff",
+    green: "#008000",
+    mediumpurple: "#9370db",
+    midnightblue: "#191970",
+    cornsilk: "#fff8dc",
+    paleturquoise: "#afeeee",
+    bisque: "#ffe4c4",
+    slategray: "#708090",
+    darkcyan: "#008b8b",
+    khaki: "#f0e68c",
+    wheat: "#f5deb3",
+    teal: "#008080",
+    darkorchid: "#9932cc",
+    deepskyblue: "#00bfff",
+    salmon: "#fa8072",
+    darkred: "#8b0000",
+    steelblue: "#4682b4",
+    palevioletred: "#db7093",
+    lightslategray: "#778899",
+    aliceblue: "#f0f8ff",
+    lightslategrey: "#778899",
+    lightgreen: "#90ee90",
+    orchid: "#da70d6",
+    gainsboro: "#dcdcdc",
+    mediumseagreen: "#3cb371",
+    lightgray: "#d3d3d3",
+    mediumturquoise: "#48d1cc",
+    lemonchiffon: "#fffacd",
+    cadetblue: "#5f9ea0",
+    lightyellow: "#ffffe0",
+    lavenderblush: "#fff0f5",
+    coral: "#ff7f50",
+    purple: "#800080",
+    aqua: "#00ffff",
+    whitesmoke: "#f5f5f5",
+    mediumslateblue: "#7b68ee",
+    darkorange: "#ff8c00",
+    mediumaquamarine: "#66cdaa",
+    darksalmon: "#e9967a",
+    beige: "#f5f5dc",
+    blueviolet: "#8a2be2",
+    azure: "#f0ffff",
+    lightsteelblue: "#b0c4de",
+    oldlace: "#fdf5e6",
+    rebeccapurple: "#663399"
+  };
+
+  chroma.colors = colors = w3cx11;
+
+  lab2rgb = function() {
+    var a, args, b, g, l, r, x, y, z;
+    args = unpack(arguments);
+    l = args[0], a = args[1], b = args[2];
+    y = (l + 16) / 116;
+    x = isNaN(a) ? y : y + a / 500;
+    z = isNaN(b) ? y : y - b / 200;
+    y = LAB_CONSTANTS.Yn * lab_xyz(y);
+    x = LAB_CONSTANTS.Xn * lab_xyz(x);
+    z = LAB_CONSTANTS.Zn * lab_xyz(z);
+    r = xyz_rgb(3.2404542 * x - 1.5371385 * y - 0.4985314 * z);
+    g = xyz_rgb(-0.9692660 * x + 1.8760108 * y + 0.0415560 * z);
+    b = xyz_rgb(0.0556434 * x - 0.2040259 * y + 1.0572252 * z);
+    r = limit(r, 0, 255);
+    g = limit(g, 0, 255);
+    b = limit(b, 0, 255);
+    return [r, g, b, args.length > 3 ? args[3] : 1];
+  };
+
+  xyz_rgb = function(r) {
+    return round(255 * (r <= 0.00304 ? 12.92 * r : 1.055 * pow(r, 1 / 2.4) - 0.055));
+  };
+
+  lab_xyz = function(t) {
+    if (t > LAB_CONSTANTS.t1) {
+      return t * t * t;
+    } else {
+      return LAB_CONSTANTS.t2 * (t - LAB_CONSTANTS.t0);
+    }
+  };
+
+  LAB_CONSTANTS = {
+    Kn: 18,
+    Xn: 0.950470,
+    Yn: 1,
+    Zn: 1.088830,
+    t0: 0.137931034,
+    t1: 0.206896552,
+    t2: 0.12841855,
+    t3: 0.008856452
+  };
+
+  rgb2lab = function() {
+    var b, g, r, ref, ref1, x, y, z;
+    ref = unpack(arguments), r = ref[0], g = ref[1], b = ref[2];
+    ref1 = rgb2xyz(r, g, b), x = ref1[0], y = ref1[1], z = ref1[2];
+    return [116 * y - 16, 500 * (x - y), 200 * (y - z)];
+  };
+
+  rgb_xyz = function(r) {
+    if ((r /= 255) <= 0.04045) {
+      return r / 12.92;
+    } else {
+      return pow((r + 0.055) / 1.055, 2.4);
+    }
+  };
+
+  xyz_lab = function(t) {
+    if (t > LAB_CONSTANTS.t3) {
+      return pow(t, 1 / 3);
+    } else {
+      return t / LAB_CONSTANTS.t2 + LAB_CONSTANTS.t0;
+    }
+  };
+
+  rgb2xyz = function() {
+    var b, g, r, ref, x, y, z;
+    ref = unpack(arguments), r = ref[0], g = ref[1], b = ref[2];
+    r = rgb_xyz(r);
+    g = rgb_xyz(g);
+    b = rgb_xyz(b);
+    x = xyz_lab((0.4124564 * r + 0.3575761 * g + 0.1804375 * b) / LAB_CONSTANTS.Xn);
+    y = xyz_lab((0.2126729 * r + 0.7151522 * g + 0.0721750 * b) / LAB_CONSTANTS.Yn);
+    z = xyz_lab((0.0193339 * r + 0.1191920 * g + 0.9503041 * b) / LAB_CONSTANTS.Zn);
+    return [x, y, z];
+  };
+
+  chroma.lab = function() {
+    return (function(func, args, ctor) {
+      ctor.prototype = func.prototype;
+      var child = new ctor, result = func.apply(child, args);
+      return Object(result) === result ? result : child;
+    })(Color, slice.call(arguments).concat(['lab']), function(){});
+  };
+
+  _input.lab = lab2rgb;
+
+  Color.prototype.lab = function() {
+    return rgb2lab(this._rgb);
+  };
+
+  bezier = function(colors) {
+    var I, I0, I1, c, lab0, lab1, lab2, lab3, ref, ref1, ref2;
+    colors = (function() {
+      var len, o, results;
+      results = [];
+      for (o = 0, len = colors.length; o < len; o++) {
+        c = colors[o];
+        results.push(chroma(c));
+      }
+      return results;
+    })();
+    if (colors.length === 2) {
+      ref = (function() {
+        var len, o, results;
+        results = [];
+        for (o = 0, len = colors.length; o < len; o++) {
+          c = colors[o];
+          results.push(c.lab());
+        }
+        return results;
+      })(), lab0 = ref[0], lab1 = ref[1];
+      I = function(t) {
+        var i, lab;
+        lab = (function() {
+          var o, results;
+          results = [];
+          for (i = o = 0; o <= 2; i = ++o) {
+            results.push(lab0[i] + t * (lab1[i] - lab0[i]));
+          }
+          return results;
+        })();
+        return chroma.lab.apply(chroma, lab);
+      };
+    } else if (colors.length === 3) {
+      ref1 = (function() {
+        var len, o, results;
+        results = [];
+        for (o = 0, len = colors.length; o < len; o++) {
+          c = colors[o];
+          results.push(c.lab());
+        }
+        return results;
+      })(), lab0 = ref1[0], lab1 = ref1[1], lab2 = ref1[2];
+      I = function(t) {
+        var i, lab;
+        lab = (function() {
+          var o, results;
+          results = [];
+          for (i = o = 0; o <= 2; i = ++o) {
+            results.push((1 - t) * (1 - t) * lab0[i] + 2 * (1 - t) * t * lab1[i] + t * t * lab2[i]);
+          }
+          return results;
+        })();
+        return chroma.lab.apply(chroma, lab);
+      };
+    } else if (colors.length === 4) {
+      ref2 = (function() {
+        var len, o, results;
+        results = [];
+        for (o = 0, len = colors.length; o < len; o++) {
+          c = colors[o];
+          results.push(c.lab());
+        }
+        return results;
+      })(), lab0 = ref2[0], lab1 = ref2[1], lab2 = ref2[2], lab3 = ref2[3];
+      I = function(t) {
+        var i, lab;
+        lab = (function() {
+          var o, results;
+          results = [];
+          for (i = o = 0; o <= 2; i = ++o) {
+            results.push((1 - t) * (1 - t) * (1 - t) * lab0[i] + 3 * (1 - t) * (1 - t) * t * lab1[i] + 3 * (1 - t) * t * t * lab2[i] + t * t * t * lab3[i]);
+          }
+          return results;
+        })();
+        return chroma.lab.apply(chroma, lab);
+      };
+    } else if (colors.length === 5) {
+      I0 = bezier(colors.slice(0, 3));
+      I1 = bezier(colors.slice(2, 5));
+      I = function(t) {
+        if (t < 0.5) {
+          return I0(t * 2);
+        } else {
+          return I1((t - 0.5) * 2);
+        }
+      };
+    }
+    return I;
+  };
+
+  chroma.bezier = function(colors) {
+    var f;
+    f = bezier(colors);
+    f.scale = function() {
+      return chroma.scale(f);
+    };
+    return f;
+  };
+
+
+  /*
+      chroma.js
+  
+      Copyright (c) 2011-2013, Gregor Aisch
+      All rights reserved.
+  
+      Redistribution and use in source and binary forms, with or without
+      modification, are permitted provided that the following conditions are met:
+  
+      * Redistributions of source code must retain the above copyright notice, this
+        list of conditions and the following disclaimer.
+  
+      * Redistributions in binary form must reproduce the above copyright notice,
+        this list of conditions and the following disclaimer in the documentation
+        and/or other materials provided with the distribution.
+  
+      * The name Gregor Aisch may not be used to endorse or promote products
+        derived from this software without specific prior written permission.
+  
+      THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+      AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+      IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+      DISCLAIMED. IN NO EVENT SHALL GREGOR AISCH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+      INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+      BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+      DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+      OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+      NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+      EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+  
+      @source: https://github.com/gka/chroma.js
+   */
+
+  chroma.cubehelix = function(start, rotations, hue, gamma, lightness) {
+    var dh, dl, f;
+    if (start == null) {
+      start = 300;
+    }
+    if (rotations == null) {
+      rotations = -1.5;
+    }
+    if (hue == null) {
+      hue = 1;
+    }
+    if (gamma == null) {
+      gamma = 1;
+    }
+    if (lightness == null) {
+      lightness = [0, 1];
+    }
+    dl = lightness[1] - lightness[0];
+    dh = 0;
+    f = function(fract) {
+      var a, amp, b, cos_a, g, h, l, r, sin_a;
+      a = TWOPI * ((start + 120) / 360 + rotations * fract);
+      l = pow(lightness[0] + dl * fract, gamma);
+      h = dh !== 0 ? hue[0] + fract * dh : hue;
+      amp = h * l * (1 - l) / 2;
+      cos_a = cos(a);
+      sin_a = sin(a);
+      r = l + amp * (-0.14861 * cos_a + 1.78277 * sin_a);
+      g = l + amp * (-0.29227 * cos_a - 0.90649 * sin_a);
+      b = l + amp * (+1.97294 * cos_a);
+      return chroma(clip_rgb([r * 255, g * 255, b * 255]));
+    };
+    f.start = function(s) {
+      if (s == null) {
+        return start;
+      }
+      start = s;
+      return f;
+    };
+    f.rotations = function(r) {
+      if (r == null) {
+        return rotations;
+      }
+      rotations = r;
+      return f;
+    };
+    f.gamma = function(g) {
+      if (g == null) {
+        return gamma;
+      }
+      gamma = g;
+      return f;
+    };
+    f.hue = function(h) {
+      if (h == null) {
+        return hue;
+      }
+      hue = h;
+      if (type(hue) === 'array') {
+        dh = hue[1] - hue[0];
+        if (dh === 0) {
+          hue = hue[1];
+        }
+      } else {
+        dh = 0;
+      }
+      return f;
+    };
+    f.lightness = function(h) {
+      if (h == null) {
+        return lightness;
+      }
+      lightness = h;
+      if (type(lightness) === 'array') {
+        dl = lightness[1] - lightness[0];
+        if (dl === 0) {
+          lightness = lightness[1];
+        }
+      } else {
+        dl = 0;
+      }
+      return f;
+    };
+    f.scale = function() {
+      return chroma.scale(f);
+    };
+    f.hue(hue);
+    return f;
+  };
+
+  chroma.random = function() {
+    var code, digits, i, o;
+    digits = '0123456789abcdef';
+    code = '#';
+    for (i = o = 0; o < 6; i = ++o) {
+      code += digits.charAt(floor(Math.random() * 16));
+    }
+    return new Color(code);
+  };
+
+  _input.rgb = function() {
+    var k, ref, results, v;
+    ref = unpack(arguments);
+    results = [];
+    for (k in ref) {
+      v = ref[k];
+      results.push(v);
+    }
+    return results;
+  };
+
+  chroma.rgb = function() {
+    return (function(func, args, ctor) {
+      ctor.prototype = func.prototype;
+      var child = new ctor, result = func.apply(child, args);
+      return Object(result) === result ? result : child;
+    })(Color, slice.call(arguments).concat(['rgb']), function(){});
+  };
+
+  Color.prototype.rgb = function() {
+    return this._rgb.slice(0, 3);
+  };
+
+  Color.prototype.rgba = function() {
+    return this._rgb;
+  };
+
+  _guess_formats.push({
+    p: 15,
+    test: function(n) {
+      var a;
+      a = unpack(arguments);
+      if (type(a) === 'array' && a.length === 3) {
+        return 'rgb';
+      }
+      if (a.length === 4 && type(a[3]) === "number" && a[3] >= 0 && a[3] <= 1) {
+        return 'rgb';
+      }
+    }
+  });
+
+  hex2rgb = function(hex) {
+    var a, b, g, r, rgb, u;
+    if (hex.match(/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/)) {
+      if (hex.length === 4 || hex.length === 7) {
+        hex = hex.substr(1);
+      }
+      if (hex.length === 3) {
+        hex = hex.split("");
+        hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
+      }
+      u = parseInt(hex, 16);
+      r = u >> 16;
+      g = u >> 8 & 0xFF;
+      b = u & 0xFF;
+      return [r, g, b, 1];
+    }
+    if (hex.match(/^#?([A-Fa-f0-9]{8})$/)) {
+      if (hex.length === 9) {
+        hex = hex.substr(1);
+      }
+      u = parseInt(hex, 16);
+      r = u >> 24 & 0xFF;
+      g = u >> 16 & 0xFF;
+      b = u >> 8 & 0xFF;
+      a = round((u & 0xFF) / 0xFF * 100) / 100;
+      return [r, g, b, a];
+    }
+    if ((_input.css != null) && (rgb = _input.css(hex))) {
+      return rgb;
+    }
+    throw "unknown color: " + hex;
+  };
+
+  rgb2hex = function(channels, mode) {
+    var a, b, g, hxa, r, str, u;
+    if (mode == null) {
+      mode = 'rgb';
+    }
+    r = channels[0], g = channels[1], b = channels[2], a = channels[3];
+    u = r << 16 | g << 8 | b;
+    str = "000000" + u.toString(16);
+    str = str.substr(str.length - 6);
+    hxa = '0' + round(a * 255).toString(16);
+    hxa = hxa.substr(hxa.length - 2);
+    return "#" + (function() {
+      switch (mode.toLowerCase()) {
+        case 'rgba':
+          return str + hxa;
+        case 'argb':
+          return hxa + str;
+        default:
+          return str;
+      }
+    })();
+  };
+
+  _input.hex = function(h) {
+    return hex2rgb(h);
+  };
+
+  chroma.hex = function() {
+    return (function(func, args, ctor) {
+      ctor.prototype = func.prototype;
+      var child = new ctor, result = func.apply(child, args);
+      return Object(result) === result ? result : child;
+    })(Color, slice.call(arguments).concat(['hex']), function(){});
+  };
+
+  Color.prototype.hex = function(mode) {
+    if (mode == null) {
+      mode = 'rgb';
+    }
+    return rgb2hex(this._rgb, mode);
+  };
+
+  _guess_formats.push({
+    p: 10,
+    test: function(n) {
+      if (arguments.length === 1 && type(n) === "string") {
+        return 'hex';
+      }
+    }
+  });
+
+  hsl2rgb = function() {
+    var args, b, c, g, h, i, l, o, r, ref, s, t1, t2, t3;
+    args = unpack(arguments);
+    h = args[0], s = args[1], l = args[2];
+    if (s === 0) {
+      r = g = b = l * 255;
+    } else {
+      t3 = [0, 0, 0];
+      c = [0, 0, 0];
+      t2 = l < 0.5 ? l * (1 + s) : l + s - l * s;
+      t1 = 2 * l - t2;
+      h /= 360;
+      t3[0] = h + 1 / 3;
+      t3[1] = h;
+      t3[2] = h - 1 / 3;
+      for (i = o = 0; o <= 2; i = ++o) {
+        if (t3[i] < 0) {
+          t3[i] += 1;
+        }
+        if (t3[i] > 1) {
+          t3[i] -= 1;
+        }
+        if (6 * t3[i] < 1) {
+          c[i] = t1 + (t2 - t1) * 6 * t3[i];
+        } else if (2 * t3[i] < 1) {
+          c[i] = t2;
+        } else if (3 * t3[i] < 2) {
+          c[i] = t1 + (t2 - t1) * ((2 / 3) - t3[i]) * 6;
+        } else {
+          c[i] = t1;
+        }
+      }
+      ref = [round(c[0] * 255), round(c[1] * 255), round(c[2] * 255)], r = ref[0], g = ref[1], b = ref[2];
+    }
+    if (args.length > 3) {
+      return [r, g, b, args[3]];
+    } else {
+      return [r, g, b];
+    }
+  };
+
+  rgb2hsl = function(r, g, b) {
+    var h, l, min, ref, s;
+    if (r !== void 0 && r.length >= 3) {
+      ref = r, r = ref[0], g = ref[1], b = ref[2];
+    }
+    r /= 255;
+    g /= 255;
+    b /= 255;
+    min = Math.min(r, g, b);
+    max = Math.max(r, g, b);
+    l = (max + min) / 2;
+    if (max === min) {
+      s = 0;
+      h = Number.NaN;
+    } else {
+      s = l < 0.5 ? (max - min) / (max + min) : (max - min) / (2 - max - min);
+    }
+    if (r === max) {
+      h = (g - b) / (max - min);
+    } else if (g === max) {
+      h = 2 + (b - r) / (max - min);
+    } else if (b === max) {
+      h = 4 + (r - g) / (max - min);
+    }
+    h *= 60;
+    if (h < 0) {
+      h += 360;
+    }
+    return [h, s, l];
+  };
+
+  chroma.hsl = function() {
+    return (function(func, args, ctor) {
+      ctor.prototype = func.prototype;
+      var child = new ctor, result = func.apply(child, args);
+      return Object(result) === result ? result : child;
+    })(Color, slice.call(arguments).concat(['hsl']), function(){});
+  };
+
+  _input.hsl = hsl2rgb;
+
+  Color.prototype.hsl = function() {
+    return rgb2hsl(this._rgb);
+  };
+
+  hsv2rgb = function() {
+    var args, b, f, g, h, i, p, q, r, ref, ref1, ref2, ref3, ref4, ref5, s, t, v;
+    args = unpack(arguments);
+    h = args[0], s = args[1], v = args[2];
+    v *= 255;
+    if (s === 0) {
+      r = g = b = v;
+    } else {
+      if (h === 360) {
+        h = 0;
+      }
+      if (h > 360) {
+        h -= 360;
+      }
+      if (h < 0) {
+        h += 360;
+      }
+      h /= 60;
+      i = floor(h);
+      f = h - i;
+      p = v * (1 - s);
+      q = v * (1 - s * f);
+      t = v * (1 - s * (1 - f));
+      switch (i) {
+        case 0:
+          ref = [v, t, p], r = ref[0], g = ref[1], b = ref[2];
+          break;
+        case 1:
+          ref1 = [q, v, p], r = ref1[0], g = ref1[1], b = ref1[2];
+          break;
+        case 2:
+          ref2 = [p, v, t], r = ref2[0], g = ref2[1], b = ref2[2];
+          break;
+        case 3:
+          ref3 = [p, q, v], r = ref3[0], g = ref3[1], b = ref3[2];
+          break;
+        case 4:
+          ref4 = [t, p, v], r = ref4[0], g = ref4[1], b = ref4[2];
+          break;
+        case 5:
+          ref5 = [v, p, q], r = ref5[0], g = ref5[1], b = ref5[2];
+      }
+    }
+    r = round(r);
+    g = round(g);
+    b = round(b);
+    return [r, g, b, args.length > 3 ? args[3] : 1];
+  };
+
+  rgb2hsv = function() {
+    var b, delta, g, h, min, r, ref, s, v;
+    ref = unpack(arguments), r = ref[0], g = ref[1], b = ref[2];
+    min = Math.min(r, g, b);
+    max = Math.max(r, g, b);
+    delta = max - min;
+    v = max / 255.0;
+    if (max === 0) {
+      h = Number.NaN;
+      s = 0;
+    } else {
+      s = delta / max;
+      if (r === max) {
+        h = (g - b) / delta;
+      }
+      if (g === max) {
+        h = 2 + (b - r) / delta;
+      }
+      if (b === max) {
+        h = 4 + (r - g) / delta;
+      }
+      h *= 60;
+      if (h < 0) {
+        h += 360;
+      }
+    }
+    return [h, s, v];
+  };
+
+  chroma.hsv = function() {
+    return (function(func, args, ctor) {
+      ctor.prototype = func.prototype;
+      var child = new ctor, result = func.apply(child, args);
+      return Object(result) === result ? result : child;
+    })(Color, slice.call(arguments).concat(['hsv']), function(){});
+  };
+
+  _input.hsv = hsv2rgb;
+
+  Color.prototype.hsv = function() {
+    return rgb2hsv(this._rgb);
+  };
+
+  num2rgb = function(num) {
+    var b, g, r;
+    if (type(num) === "number" && num >= 0 && num <= 0xFFFFFF) {
+      r = num >> 16;
+      g = (num >> 8) & 0xFF;
+      b = num & 0xFF;
+      return [r, g, b, 1];
+    }
+    console.warn("unknown num color: " + num);
+    return [0, 0, 0, 1];
+  };
+
+  rgb2num = function() {
+    var b, g, r, ref;
+    ref = unpack(arguments), r = ref[0], g = ref[1], b = ref[2];
+    return (r << 16) + (g << 8) + b;
+  };
+
+  chroma.num = function(num) {
+    return new Color(num, 'num');
+  };
+
+  Color.prototype.num = function(mode) {
+    if (mode == null) {
+      mode = 'rgb';
+    }
+    return rgb2num(this._rgb, mode);
+  };
+
+  _input.num = num2rgb;
+
+  _guess_formats.push({
+    p: 10,
+    test: function(n) {
+      if (arguments.length === 1 && type(n) === "number" && n >= 0 && n <= 0xFFFFFF) {
+        return 'num';
+      }
+    }
+  });
+
+  css2rgb = function(css) {
+    var aa, ab, hsl, i, m, o, rgb, w;
+    css = css.toLowerCase();
+    if ((chroma.colors != null) && chroma.colors[css]) {
+      return hex2rgb(chroma.colors[css]);
+    }
+    if (m = css.match(/rgb\(\s*(\-?\d+),\s*(\-?\d+)\s*,\s*(\-?\d+)\s*\)/)) {
+      rgb = m.slice(1, 4);
+      for (i = o = 0; o <= 2; i = ++o) {
+        rgb[i] = +rgb[i];
+      }
+      rgb[3] = 1;
+    } else if (m = css.match(/rgba\(\s*(\-?\d+),\s*(\-?\d+)\s*,\s*(\-?\d+)\s*,\s*([01]|[01]?\.\d+)\)/)) {
+      rgb = m.slice(1, 5);
+      for (i = w = 0; w <= 3; i = ++w) {
+        rgb[i] = +rgb[i];
+      }
+    } else if (m = css.match(/rgb\(\s*(\-?\d+(?:\.\d+)?)%,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*\)/)) {
+      rgb = m.slice(1, 4);
+      for (i = aa = 0; aa <= 2; i = ++aa) {
+        rgb[i] = round(rgb[i] * 2.55);
+      }
+      rgb[3] = 1;
+    } else if (m = css.match(/rgba\(\s*(\-?\d+(?:\.\d+)?)%,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)/)) {
+      rgb = m.slice(1, 5);
+      for (i = ab = 0; ab <= 2; i = ++ab) {
+        rgb[i] = round(rgb[i] * 2.55);
+      }
+      rgb[3] = +rgb[3];
+    } else if (m = css.match(/hsl\(\s*(\-?\d+(?:\.\d+)?),\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*\)/)) {
+      hsl = m.slice(1, 4);
+      hsl[1] *= 0.01;
+      hsl[2] *= 0.01;
+      rgb = hsl2rgb(hsl);
+      rgb[3] = 1;
+    } else if (m = css.match(/hsla\(\s*(\-?\d+(?:\.\d+)?),\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)/)) {
+      hsl = m.slice(1, 4);
+      hsl[1] *= 0.01;
+      hsl[2] *= 0.01;
+      rgb = hsl2rgb(hsl);
+      rgb[3] = +m[4];
+    }
+    return rgb;
+  };
+
+  rgb2css = function(rgba) {
+    var mode;
+    mode = rgba[3] < 1 ? 'rgba' : 'rgb';
+    if (mode === 'rgb') {
+      return mode + '(' + rgba.slice(0, 3).map(round).join(',') + ')';
+    } else if (mode === 'rgba') {
+      return mode + '(' + rgba.slice(0, 3).map(round).join(',') + ',' + rgba[3] + ')';
+    } else {
+
+    }
+  };
+
+  rnd = function(a) {
+    return round(a * 100) / 100;
+  };
+
+  hsl2css = function(hsl, alpha) {
+    var mode;
+    mode = alpha < 1 ? 'hsla' : 'hsl';
+    hsl[0] = rnd(hsl[0] || 0);
+    hsl[1] = rnd(hsl[1] * 100) + '%';
+    hsl[2] = rnd(hsl[2] * 100) + '%';
+    if (mode === 'hsla') {
+      hsl[3] = alpha;
+    }
+    return mode + '(' + hsl.join(',') + ')';
+  };
+
+  _input.css = function(h) {
+    return css2rgb(h);
+  };
+
+  chroma.css = function() {
+    return (function(func, args, ctor) {
+      ctor.prototype = func.prototype;
+      var child = new ctor, result = func.apply(child, args);
+      return Object(result) === result ? result : child;
+    })(Color, slice.call(arguments).concat(['css']), function(){});
+  };
+
+  Color.prototype.css = function(mode) {
+    if (mode == null) {
+      mode = 'rgb';
+    }
+    if (mode.slice(0, 3) === 'rgb') {
+      return rgb2css(this._rgb);
+    } else if (mode.slice(0, 3) === 'hsl') {
+      return hsl2css(this.hsl(), this.alpha());
+    }
+  };
+
+  _input.named = function(name) {
+    return hex2rgb(w3cx11[name]);
+  };
+
+  _guess_formats.push({
+    p: 20,
+    test: function(n) {
+      if (arguments.length === 1 && (w3cx11[n] != null)) {
+        return 'named';
+      }
+    }
+  });
+
+  Color.prototype.name = function(n) {
+    var h, k;
+    if (arguments.length) {
+      if (w3cx11[n]) {
+        this._rgb = hex2rgb(w3cx11[n]);
+      }
+      this._rgb[3] = 1;
+      this;
+    }
+    h = this.hex();
+    for (k in w3cx11) {
+      if (h === w3cx11[k]) {
+        return k;
+      }
+    }
+    return h;
+  };
+
+  lch2lab = function() {
+
+    /*
+    Convert from a qualitative parameter h and a quantitative parameter l to a 24-bit pixel.
+    These formulas were invented by David Dalrymple to obtain maximum contrast without going
+    out of gamut if the parameters are in the range 0-1.
+    
+    A saturation multiplier was added by Gregor Aisch
+     */
+    var c, h, l, ref;
+    ref = unpack(arguments), l = ref[0], c = ref[1], h = ref[2];
+    h = h * DEG2RAD;
+    return [l, cos(h) * c, sin(h) * c];
+  };
+
+  lch2rgb = function() {
+    var L, a, args, b, c, g, h, l, r, ref, ref1;
+    args = unpack(arguments);
+    l = args[0], c = args[1], h = args[2];
+    ref = lch2lab(l, c, h), L = ref[0], a = ref[1], b = ref[2];
+    ref1 = lab2rgb(L, a, b), r = ref1[0], g = ref1[1], b = ref1[2];
+    return [limit(r, 0, 255), limit(g, 0, 255), limit(b, 0, 255), args.length > 3 ? args[3] : 1];
+  };
+
+  lab2lch = function() {
+    var a, b, c, h, l, ref;
+    ref = unpack(arguments), l = ref[0], a = ref[1], b = ref[2];
+    c = sqrt(a * a + b * b);
+    h = (atan2(b, a) * RAD2DEG + 360) % 360;
+    if (round(c * 10000) === 0) {
+      h = Number.NaN;
+    }
+    return [l, c, h];
+  };
+
+  rgb2lch = function() {
+    var a, b, g, l, r, ref, ref1;
+    ref = unpack(arguments), r = ref[0], g = ref[1], b = ref[2];
+    ref1 = rgb2lab(r, g, b), l = ref1[0], a = ref1[1], b = ref1[2];
+    return lab2lch(l, a, b);
+  };
+
+  chroma.lch = function() {
+    var args;
+    args = unpack(arguments);
+    return new Color(args, 'lch');
+  };
+
+  chroma.hcl = function() {
+    var args;
+    args = unpack(arguments);
+    return new Color(args, 'hcl');
+  };
+
+  _input.lch = lch2rgb;
+
+  _input.hcl = function() {
+    var c, h, l, ref;
+    ref = unpack(arguments), h = ref[0], c = ref[1], l = ref[2];
+    return lch2rgb([l, c, h]);
+  };
+
+  Color.prototype.lch = function() {
+    return rgb2lch(this._rgb);
+  };
+
+  Color.prototype.hcl = function() {
+    return rgb2lch(this._rgb).reverse();
+  };
+
+  rgb2cmyk = function(mode) {
+    var b, c, f, g, k, m, r, ref, y;
+    if (mode == null) {
+      mode = 'rgb';
+    }
+    ref = unpack(arguments), r = ref[0], g = ref[1], b = ref[2];
+    r = r / 255;
+    g = g / 255;
+    b = b / 255;
+    k = 1 - Math.max(r, Math.max(g, b));
+    f = k < 1 ? 1 / (1 - k) : 0;
+    c = (1 - r - k) * f;
+    m = (1 - g - k) * f;
+    y = (1 - b - k) * f;
+    return [c, m, y, k];
+  };
+
+  cmyk2rgb = function() {
+    var alpha, args, b, c, g, k, m, r, y;
+    args = unpack(arguments);
+    c = args[0], m = args[1], y = args[2], k = args[3];
+    alpha = args.length > 4 ? args[4] : 1;
+    if (k === 1) {
+      return [0, 0, 0, alpha];
+    }
+    r = c >= 1 ? 0 : round(255 * (1 - c) * (1 - k));
+    g = m >= 1 ? 0 : round(255 * (1 - m) * (1 - k));
+    b = y >= 1 ? 0 : round(255 * (1 - y) * (1 - k));
+    return [r, g, b, alpha];
+  };
+
+  _input.cmyk = function() {
+    return cmyk2rgb(unpack(arguments));
+  };
+
+  chroma.cmyk = function() {
+    return (function(func, args, ctor) {
+      ctor.prototype = func.prototype;
+      var child = new ctor, result = func.apply(child, args);
+      return Object(result) === result ? result : child;
+    })(Color, slice.call(arguments).concat(['cmyk']), function(){});
+  };
+
+  Color.prototype.cmyk = function() {
+    return rgb2cmyk(this._rgb);
+  };
+
+  _input.gl = function() {
+    var i, k, o, rgb, v;
+    rgb = (function() {
+      var ref, results;
+      ref = unpack(arguments);
+      results = [];
+      for (k in ref) {
+        v = ref[k];
+        results.push(v);
+      }
+      return results;
+    }).apply(this, arguments);
+    for (i = o = 0; o <= 2; i = ++o) {
+      rgb[i] *= 255;
+    }
+    return rgb;
+  };
+
+  chroma.gl = function() {
+    return (function(func, args, ctor) {
+      ctor.prototype = func.prototype;
+      var child = new ctor, result = func.apply(child, args);
+      return Object(result) === result ? result : child;
+    })(Color, slice.call(arguments).concat(['gl']), function(){});
+  };
+
+  Color.prototype.gl = function() {
+    var rgb;
+    rgb = this._rgb;
+    return [rgb[0] / 255, rgb[1] / 255, rgb[2] / 255, rgb[3]];
+  };
+
+  rgb2luminance = function(r, g, b) {
+    var ref;
+    ref = unpack(arguments), r = ref[0], g = ref[1], b = ref[2];
+    r = luminance_x(r);
+    g = luminance_x(g);
+    b = luminance_x(b);
+    return 0.2126 * r + 0.7152 * g + 0.0722 * b;
+  };
+
+  luminance_x = function(x) {
+    x /= 255;
+    if (x <= 0.03928) {
+      return x / 12.92;
+    } else {
+      return pow((x + 0.055) / 1.055, 2.4);
+    }
+  };
+
+  _interpolators = [];
+
+  interpolate = function(col1, col2, f, m) {
+    var interpol, len, o, res;
+    if (f == null) {
+      f = 0.5;
+    }
+    if (m == null) {
+      m = 'rgb';
+    }
+
+    /*
+    interpolates between colors
+    f = 0 --> me
+    f = 1 --> col
+     */
+    if (type(col1) !== 'object') {
+      col1 = chroma(col1);
+    }
+    if (type(col2) !== 'object') {
+      col2 = chroma(col2);
+    }
+    for (o = 0, len = _interpolators.length; o < len; o++) {
+      interpol = _interpolators[o];
+      if (m === interpol[0]) {
+        res = interpol[1](col1, col2, f, m);
+        break;
+      }
+    }
+    if (res == null) {
+      throw "color mode " + m + " is not supported";
+    }
+    res.alpha(col1.alpha() + f * (col2.alpha() - col1.alpha()));
+    return res;
+  };
+
+  chroma.interpolate = interpolate;
+
+  Color.prototype.interpolate = function(col2, f, m) {
+    return interpolate(this, col2, f, m);
+  };
+
+  chroma.mix = interpolate;
+
+  Color.prototype.mix = Color.prototype.interpolate;
+
+  interpolate_rgb = function(col1, col2, f, m) {
+    var xyz0, xyz1;
+    xyz0 = col1._rgb;
+    xyz1 = col2._rgb;
+    return new Color(xyz0[0] + f * (xyz1[0] - xyz0[0]), xyz0[1] + f * (xyz1[1] - xyz0[1]), xyz0[2] + f * (xyz1[2] - xyz0[2]), m);
+  };
+
+  _interpolators.push(['rgb', interpolate_rgb]);
+
+  Color.prototype.luminance = function(lum, mode) {
+    var cur_lum, eps, max_iter, test;
+    if (mode == null) {
+      mode = 'rgb';
+    }
+    if (!arguments.length) {
+      return rgb2luminance(this._rgb);
+    }
+    if (lum === 0) {
+      this._rgb = [0, 0, 0, this._rgb[3]];
+    } else if (lum === 1) {
+      this._rgb = [255, 255, 255, this._rgb[3]];
+    } else {
+      eps = 1e-7;
+      max_iter = 20;
+      test = function(l, h) {
+        var lm, m;
+        m = l.interpolate(h, 0.5, mode);
+        lm = m.luminance();
+        if (Math.abs(lum - lm) < eps || !max_iter--) {
+          return m;
+        }
+        if (lm > lum) {
+          return test(l, m);
+        }
+        return test(m, h);
+      };
+      cur_lum = rgb2luminance(this._rgb);
+      this._rgb = (cur_lum > lum ? test(chroma('black'), this) : test(this, chroma('white'))).rgba();
+    }
+    return this;
+  };
+
+  temperature2rgb = function(kelvin) {
+    var b, g, r, temp;
+    temp = kelvin / 100;
+    if (temp < 66) {
+      r = 255;
+      g = -155.25485562709179 - 0.44596950469579133 * (g = temp - 2) + 104.49216199393888 * log(g);
+      b = temp < 20 ? 0 : -254.76935184120902 + 0.8274096064007395 * (b = temp - 10) + 115.67994401066147 * log(b);
+    } else {
+      r = 351.97690566805693 + 0.114206453784165 * (r = temp - 55) - 40.25366309332127 * log(r);
+      g = 325.4494125711974 + 0.07943456536662342 * (g = temp - 50) - 28.0852963507957 * log(g);
+      b = 255;
+    }
+    return clip_rgb([r, g, b]);
+  };
+
+  rgb2temperature = function() {
+    var b, eps, g, maxTemp, minTemp, r, ref, rgb, temp;
+    ref = unpack(arguments), r = ref[0], g = ref[1], b = ref[2];
+    minTemp = 1000;
+    maxTemp = 40000;
+    eps = 0.4;
+    while (maxTemp - minTemp > eps) {
+      temp = (maxTemp + minTemp) * 0.5;
+      rgb = temperature2rgb(temp);
+      if ((rgb[2] / rgb[0]) >= (b / r)) {
+        maxTemp = temp;
+      } else {
+        minTemp = temp;
+      }
+    }
+    return round(temp);
+  };
+
+  chroma.temperature = chroma.kelvin = function() {
+    return (function(func, args, ctor) {
+      ctor.prototype = func.prototype;
+      var child = new ctor, result = func.apply(child, args);
+      return Object(result) === result ? result : child;
+    })(Color, slice.call(arguments).concat(['temperature']), function(){});
+  };
+
+  _input.temperature = _input.kelvin = _input.K = temperature2rgb;
+
+  Color.prototype.temperature = function() {
+    return rgb2temperature(this._rgb);
+  };
+
+  Color.prototype.kelvin = Color.prototype.temperature;
+
+  chroma.contrast = function(a, b) {
+    var l1, l2, ref, ref1;
+    if ((ref = type(a)) === 'string' || ref === 'number') {
+      a = new Color(a);
+    }
+    if ((ref1 = type(b)) === 'string' || ref1 === 'number') {
+      b = new Color(b);
+    }
+    l1 = a.luminance();
+    l2 = b.luminance();
+    if (l1 > l2) {
+      return (l1 + 0.05) / (l2 + 0.05);
+    } else {
+      return (l2 + 0.05) / (l1 + 0.05);
+    }
+  };
+
+  Color.prototype.get = function(modechan) {
+    var channel, i, me, mode, ref, src;
+    me = this;
+    ref = modechan.split('.'), mode = ref[0], channel = ref[1];
+    src = me[mode]();
+    if (channel) {
+      i = mode.indexOf(channel);
+      if (i > -1) {
+        return src[i];
+      } else {
+        return console.warn('unknown channel ' + channel + ' in mode ' + mode);
+      }
+    } else {
+      return src;
+    }
+  };
+
+  Color.prototype.set = function(modechan, value) {
+    var channel, i, me, mode, ref, src;
+    me = this;
+    ref = modechan.split('.'), mode = ref[0], channel = ref[1];
+    if (channel) {
+      src = me[mode]();
+      i = mode.indexOf(channel);
+      if (i > -1) {
+        if (type(value) === 'string') {
+          switch (value.charAt(0)) {
+            case '+':
+              src[i] += +value;
+              break;
+            case '-':
+              src[i] += +value;
+              break;
+            case '*':
+              src[i] *= +(value.substr(1));
+              break;
+            case '/':
+              src[i] /= +(value.substr(1));
+              break;
+            default:
+              src[i] = +value;
+          }
+        } else {
+          src[i] = value;
+        }
+      } else {
+        console.warn('unknown channel ' + channel + ' in mode ' + mode);
+      }
+    } else {
+      src = value;
+    }
+    me._rgb = chroma(src, mode).alpha(me.alpha())._rgb;
+    return me;
+  };
+
+  Color.prototype.darken = function(amount) {
+    var lab, me;
+    if (amount == null) {
+      amount = 1;
+    }
+    me = this;
+    lab = me.lab();
+    lab[0] -= LAB_CONSTANTS.Kn * amount;
+    return chroma.lab(lab).alpha(me.alpha());
+  };
+
+  Color.prototype.brighten = function(amount) {
+    if (amount == null) {
+      amount = 1;
+    }
+    return this.darken(-amount);
+  };
+
+  Color.prototype.darker = Color.prototype.darken;
+
+  Color.prototype.brighter = Color.prototype.brighten;
+
+  Color.prototype.saturate = function(amount) {
+    var lch, me;
+    if (amount == null) {
+      amount = 1;
+    }
+    me = this;
+    lch = me.lch();
+    lch[1] += amount * LAB_CONSTANTS.Kn;
+    if (lch[1] < 0) {
+      lch[1] = 0;
+    }
+    return chroma.lch(lch).alpha(me.alpha());
+  };
+
+  Color.prototype.desaturate = function(amount) {
+    if (amount == null) {
+      amount = 1;
+    }
+    return this.saturate(-amount);
+  };
+
+  Color.prototype.premultiply = function() {
+    var a, rgb;
+    rgb = this.rgb();
+    a = this.alpha();
+    return chroma(rgb[0] * a, rgb[1] * a, rgb[2] * a, a);
+  };
+
+  blend = function(bottom, top, mode) {
+    if (!blend[mode]) {
+      throw 'unknown blend mode ' + mode;
+    }
+    return blend[mode](bottom, top);
+  };
+
+  blend_f = function(f) {
+    return function(bottom, top) {
+      var c0, c1;
+      c0 = chroma(top).rgb();
+      c1 = chroma(bottom).rgb();
+      return chroma(f(c0, c1), 'rgb');
+    };
+  };
+
+  each = function(f) {
+    return function(c0, c1) {
+      var i, o, out;
+      out = [];
+      for (i = o = 0; o <= 3; i = ++o) {
+        out[i] = f(c0[i], c1[i]);
+      }
+      return out;
+    };
+  };
+
+  normal = function(a, b) {
+    return a;
+  };
+
+  multiply = function(a, b) {
+    return a * b / 255;
+  };
+
+  darken = function(a, b) {
+    if (a > b) {
+      return b;
+    } else {
+      return a;
+    }
+  };
+
+  lighten = function(a, b) {
+    if (a > b) {
+      return a;
+    } else {
+      return b;
+    }
+  };
+
+  screen = function(a, b) {
+    return 255 * (1 - (1 - a / 255) * (1 - b / 255));
+  };
+
+  overlay = function(a, b) {
+    if (b < 128) {
+      return 2 * a * b / 255;
+    } else {
+      return 255 * (1 - 2 * (1 - a / 255) * (1 - b / 255));
+    }
+  };
+
+  burn = function(a, b) {
+    return 255 * (1 - (1 - b / 255) / (a / 255));
+  };
+
+  dodge = function(a, b) {
+    if (a === 255) {
+      return 255;
+    }
+    a = 255 * (b / 255) / (1 - a / 255);
+    if (a > 255) {
+      return 255;
+    } else {
+      return a;
+    }
+  };
+
+  blend.normal = blend_f(each(normal));
+
+  blend.multiply = blend_f(each(multiply));
+
+  blend.screen = blend_f(each(screen));
+
+  blend.overlay = blend_f(each(overlay));
+
+  blend.darken = blend_f(each(darken));
+
+  blend.lighten = blend_f(each(lighten));
+
+  blend.dodge = blend_f(each(dodge));
+
+  blend.burn = blend_f(each(burn));
+
+  chroma.blend = blend;
+
+  chroma.analyze = function(data) {
+    var len, o, r, val;
+    r = {
+      min: Number.MAX_VALUE,
+      max: Number.MAX_VALUE * -1,
+      sum: 0,
+      values: [],
+      count: 0
+    };
+    for (o = 0, len = data.length; o < len; o++) {
+      val = data[o];
+      if ((val != null) && !isNaN(val)) {
+        r.values.push(val);
+        r.sum += val;
+        if (val < r.min) {
+          r.min = val;
+        }
+        if (val > r.max) {
+          r.max = val;
+        }
+        r.count += 1;
+      }
+    }
+    r.domain = [r.min, r.max];
+    r.limits = function(mode, num) {
+      return chroma.limits(r, mode, num);
+    };
+    return r;
+  };
+
+  chroma.scale = function(colors, positions) {
+    var _classes, _colorCache, _colors, _correctLightness, _domain, _fixed, _max, _min, _mode, _nacol, _out, _padding, _pos, _spread, classifyValue, f, getClass, getColor, resetCache, setColors, tmap;
+    _mode = 'rgb';
+    _nacol = chroma('#ccc');
+    _spread = 0;
+    _fixed = false;
+    _domain = [0, 1];
+    _pos = [];
+    _padding = [0, 0];
+    _classes = false;
+    _colors = [];
+    _out = false;
+    _min = 0;
+    _max = 1;
+    _correctLightness = false;
+    _colorCache = {};
+    setColors = function(colors) {
+      var c, col, o, ref, ref1, ref2, w;
+      if (colors == null) {
+        colors = ['#fff', '#000'];
+      }
+      if ((colors != null) && type(colors) === 'string' && (((ref = chroma.brewer) != null ? ref[colors] : void 0) != null)) {
+        colors = chroma.brewer[colors];
+      }
+      if (type(colors) === 'array') {
+        colors = colors.slice(0);
+        for (c = o = 0, ref1 = colors.length - 1; 0 <= ref1 ? o <= ref1 : o >= ref1; c = 0 <= ref1 ? ++o : --o) {
+          col = colors[c];
+          if (type(col) === "string") {
+            colors[c] = chroma(col);
+          }
+        }
+        _pos.length = 0;
+        for (c = w = 0, ref2 = colors.length - 1; 0 <= ref2 ? w <= ref2 : w >= ref2; c = 0 <= ref2 ? ++w : --w) {
+          _pos.push(c / (colors.length - 1));
+        }
+      }
+      resetCache();
+      return _colors = colors;
+    };
+    getClass = function(value) {
+      var i, n;
+      if (_classes != null) {
+        n = _classes.length - 1;
+        i = 0;
+        while (i < n && value >= _classes[i]) {
+          i++;
+        }
+        return i - 1;
+      }
+      return 0;
+    };
+    tmap = function(t) {
+      return t;
+    };
+    classifyValue = function(value) {
+      var i, maxc, minc, n, val;
+      val = value;
+      if (_classes.length > 2) {
+        n = _classes.length - 1;
+        i = getClass(value);
+        minc = _classes[0] + (_classes[1] - _classes[0]) * (0 + _spread * 0.5);
+        maxc = _classes[n - 1] + (_classes[n] - _classes[n - 1]) * (1 - _spread * 0.5);
+        val = _min + ((_classes[i] + (_classes[i + 1] - _classes[i]) * 0.5 - minc) / (maxc - minc)) * (_max - _min);
+      }
+      return val;
+    };
+    getColor = function(val, bypassMap) {
+      var c, col, i, k, o, p, ref, t;
+      if (bypassMap == null) {
+        bypassMap = false;
+      }
+      if (isNaN(val)) {
+        return _nacol;
+      }
+      if (!bypassMap) {
+        if (_classes && _classes.length > 2) {
+          c = getClass(val);
+          t = c / (_classes.length - 2);
+          t = _padding[0] + (t * (1 - _padding[0] - _padding[1]));
+        } else if (_max !== _min) {
+          t = (val - _min) / (_max - _min);
+          t = _padding[0] + (t * (1 - _padding[0] - _padding[1]));
+          t = Math.min(1, Math.max(0, t));
+        } else {
+          t = 1;
+        }
+      } else {
+        t = val;
+      }
+      if (!bypassMap) {
+        t = tmap(t);
+      }
+      k = Math.floor(t * 10000);
+      if (_colorCache[k]) {
+        col = _colorCache[k];
+      } else {
+        if (type(_colors) === 'array') {
+          for (i = o = 0, ref = _pos.length - 1; 0 <= ref ? o <= ref : o >= ref; i = 0 <= ref ? ++o : --o) {
+            p = _pos[i];
+            if (t <= p) {
+              col = _colors[i];
+              break;
+            }
+            if (t >= p && i === _pos.length - 1) {
+              col = _colors[i];
+              break;
+            }
+            if (t > p && t < _pos[i + 1]) {
+              t = (t - p) / (_pos[i + 1] - p);
+              col = chroma.interpolate(_colors[i], _colors[i + 1], t, _mode);
+              break;
+            }
+          }
+        } else if (type(_colors) === 'function') {
+          col = _colors(t);
+        }
+        _colorCache[k] = col;
+      }
+      return col;
+    };
+    resetCache = function() {
+      return _colorCache = {};
+    };
+    setColors(colors);
+    f = function(v) {
+      var c;
+      c = chroma(getColor(v));
+      if (_out && c[_out]) {
+        return c[_out]();
+      } else {
+        return c;
+      }
+    };
+    f.classes = function(classes) {
+      var d;
+      if (classes != null) {
+        if (type(classes) === 'array') {
+          _classes = classes;
+          _domain = [classes[0], classes[classes.length - 1]];
+        } else {
+          d = chroma.analyze(_domain);
+          if (classes === 0) {
+            _classes = [d.min, d.max];
+          } else {
+            _classes = chroma.limits(d, 'e', classes);
+          }
+        }
+        return f;
+      }
+      return _classes;
+    };
+    f.domain = function(domain) {
+      var c, d, k, len, o, ref, w;
+      if (!arguments.length) {
+        return _domain;
+      }
+      _min = domain[0];
+      _max = domain[domain.length - 1];
+      _pos = [];
+      k = _colors.length;
+      if (domain.length === k && _min !== _max) {
+        for (o = 0, len = domain.length; o < len; o++) {
+          d = domain[o];
+          _pos.push((d - _min) / (_max - _min));
+        }
+      } else {
+        for (c = w = 0, ref = k - 1; 0 <= ref ? w <= ref : w >= ref; c = 0 <= ref ? ++w : --w) {
+          _pos.push(c / (k - 1));
+        }
+      }
+      _domain = [_min, _max];
+      return f;
+    };
+    f.mode = function(_m) {
+      if (!arguments.length) {
+        return _mode;
+      }
+      _mode = _m;
+      resetCache();
+      return f;
+    };
+    f.range = function(colors, _pos) {
+      setColors(colors, _pos);
+      return f;
+    };
+    f.out = function(_o) {
+      _out = _o;
+      return f;
+    };
+    f.spread = function(val) {
+      if (!arguments.length) {
+        return _spread;
+      }
+      _spread = val;
+      return f;
+    };
+    f.correctLightness = function(v) {
+      if (v == null) {
+        v = true;
+      }
+      _correctLightness = v;
+      resetCache();
+      if (_correctLightness) {
+        tmap = function(t) {
+          var L0, L1, L_actual, L_diff, L_ideal, max_iter, pol, t0, t1;
+          L0 = getColor(0, true).lab()[0];
+          L1 = getColor(1, true).lab()[0];
+          pol = L0 > L1;
+          L_actual = getColor(t, true).lab()[0];
+          L_ideal = L0 + (L1 - L0) * t;
+          L_diff = L_actual - L_ideal;
+          t0 = 0;
+          t1 = 1;
+          max_iter = 20;
+          while (Math.abs(L_diff) > 1e-2 && max_iter-- > 0) {
+            (function() {
+              if (pol) {
+                L_diff *= -1;
+              }
+              if (L_diff < 0) {
+                t0 = t;
+                t += (t1 - t) * 0.5;
+              } else {
+                t1 = t;
+                t += (t0 - t) * 0.5;
+              }
+              L_actual = getColor(t, true).lab()[0];
+              return L_diff = L_actual - L_ideal;
+            })();
+          }
+          return t;
+        };
+      } else {
+        tmap = function(t) {
+          return t;
+        };
+      }
+      return f;
+    };
+    f.padding = function(p) {
+      if (p != null) {
+        if (type(p) === 'number') {
+          p = [p, p];
+        }
+        _padding = p;
+        return f;
+      } else {
+        return _padding;
+      }
+    };
+    f.colors = function() {
+      var dd, dm, i, numColors, o, out, ref, results, samples, w;
+      numColors = 0;
+      out = 'hex';
+      if (arguments.length === 1) {
+        if (type(arguments[0]) === 'string') {
+          out = arguments[0];
+        } else {
+          numColors = arguments[0];
+        }
+      }
+      if (arguments.length === 2) {
+        numColors = arguments[0], out = arguments[1];
+      }
+      if (numColors) {
+        dm = _domain[0];
+        dd = _domain[1] - dm;
+        return (function() {
+          results = [];
+          for (var o = 0; 0 <= numColors ? o < numColors : o > numColors; 0 <= numColors ? o++ : o--){ results.push(o); }
+          return results;
+        }).apply(this).map(function(i) {
+          return f(dm + i / (numColors - 1) * dd)[out]();
+        });
+      }
+      colors = [];
+      samples = [];
+      if (_classes && _classes.length > 2) {
+        for (i = w = 1, ref = _classes.length; 1 <= ref ? w < ref : w > ref; i = 1 <= ref ? ++w : --w) {
+          samples.push((_classes[i - 1] + _classes[i]) * 0.5);
+        }
+      } else {
+        samples = _domain;
+      }
+      return samples.map(function(v) {
+        return f(v)[out]();
+      });
+    };
+    return f;
+  };
+
+  if (chroma.scales == null) {
+    chroma.scales = {};
+  }
+
+  chroma.scales.cool = function() {
+    return chroma.scale([chroma.hsl(180, 1, .9), chroma.hsl(250, .7, .4)]);
+  };
+
+  chroma.scales.hot = function() {
+    return chroma.scale(['#000', '#f00', '#ff0', '#fff'], [0, .25, .75, 1]).mode('rgb');
+  };
+
+  chroma.analyze = function(data, key, filter) {
+    var add, k, len, o, r, val, visit;
+    r = {
+      min: Number.MAX_VALUE,
+      max: Number.MAX_VALUE * -1,
+      sum: 0,
+      values: [],
+      count: 0
+    };
+    if (filter == null) {
+      filter = function() {
+        return true;
+      };
+    }
+    add = function(val) {
+      if ((val != null) && !isNaN(val)) {
+        r.values.push(val);
+        r.sum += val;
+        if (val < r.min) {
+          r.min = val;
+        }
+        if (val > r.max) {
+          r.max = val;
+        }
+        r.count += 1;
+      }
+    };
+    visit = function(val, k) {
+      if (filter(val, k)) {
+        if ((key != null) && type(key) === 'function') {
+          return add(key(val));
+        } else if ((key != null) && type(key) === 'string' || type(key) === 'number') {
+          return add(val[key]);
+        } else {
+          return add(val);
+        }
+      }
+    };
+    if (type(data) === 'array') {
+      for (o = 0, len = data.length; o < len; o++) {
+        val = data[o];
+        visit(val);
+      }
+    } else {
+      for (k in data) {
+        val = data[k];
+        visit(val, k);
+      }
+    }
+    r.domain = [r.min, r.max];
+    r.limits = function(mode, num) {
+      return chroma.limits(r, mode, num);
+    };
+    return r;
+  };
+
+  chroma.limits = function(data, mode, num) {
+    var aa, ab, ac, ad, ae, af, ag, ah, ai, aj, ak, al, am, assignments, best, centroids, cluster, clusterSizes, dist, i, j, kClusters, limits, max_log, min, min_log, mindist, n, nb_iters, newCentroids, o, p, pb, pr, ref, ref1, ref10, ref11, ref12, ref13, ref14, ref2, ref3, ref4, ref5, ref6, ref7, ref8, ref9, repeat, sum, tmpKMeansBreaks, value, values, w;
+    if (mode == null) {
+      mode = 'equal';
+    }
+    if (num == null) {
+      num = 7;
+    }
+    if (type(data) === 'array') {
+      data = chroma.analyze(data);
+    }
+    min = data.min;
+    max = data.max;
+    sum = data.sum;
+    values = data.values.sort(function(a, b) {
+      return a - b;
+    });
+    limits = [];
+    if (mode.substr(0, 1) === 'c') {
+      limits.push(min);
+      limits.push(max);
+    }
+    if (mode.substr(0, 1) === 'e') {
+      limits.push(min);
+      for (i = o = 1, ref = num - 1; 1 <= ref ? o <= ref : o >= ref; i = 1 <= ref ? ++o : --o) {
+        limits.push(min + (i / num) * (max - min));
+      }
+      limits.push(max);
+    } else if (mode.substr(0, 1) === 'l') {
+      if (min <= 0) {
+        throw 'Logarithmic scales are only possible for values > 0';
+      }
+      min_log = Math.LOG10E * log(min);
+      max_log = Math.LOG10E * log(max);
+      limits.push(min);
+      for (i = w = 1, ref1 = num - 1; 1 <= ref1 ? w <= ref1 : w >= ref1; i = 1 <= ref1 ? ++w : --w) {
+        limits.push(pow(10, min_log + (i / num) * (max_log - min_log)));
+      }
+      limits.push(max);
+    } else if (mode.substr(0, 1) === 'q') {
+      limits.push(min);
+      for (i = aa = 1, ref2 = num - 1; 1 <= ref2 ? aa <= ref2 : aa >= ref2; i = 1 <= ref2 ? ++aa : --aa) {
+        p = values.length * i / num;
+        pb = floor(p);
+        if (pb === p) {
+          limits.push(values[pb]);
+        } else {
+          pr = p - pb;
+          limits.push(values[pb] * pr + values[pb + 1] * (1 - pr));
+        }
+      }
+      limits.push(max);
+    } else if (mode.substr(0, 1) === 'k') {
+
+      /*
+      implementation based on
+      http://code.google.com/p/figue/source/browse/trunk/figue.js#336
+      simplified for 1-d input values
+       */
+      n = values.length;
+      assignments = new Array(n);
+      clusterSizes = new Array(num);
+      repeat = true;
+      nb_iters = 0;
+      centroids = null;
+      centroids = [];
+      centroids.push(min);
+      for (i = ab = 1, ref3 = num - 1; 1 <= ref3 ? ab <= ref3 : ab >= ref3; i = 1 <= ref3 ? ++ab : --ab) {
+        centroids.push(min + (i / num) * (max - min));
+      }
+      centroids.push(max);
+      while (repeat) {
+        for (j = ac = 0, ref4 = num - 1; 0 <= ref4 ? ac <= ref4 : ac >= ref4; j = 0 <= ref4 ? ++ac : --ac) {
+          clusterSizes[j] = 0;
+        }
+        for (i = ad = 0, ref5 = n - 1; 0 <= ref5 ? ad <= ref5 : ad >= ref5; i = 0 <= ref5 ? ++ad : --ad) {
+          value = values[i];
+          mindist = Number.MAX_VALUE;
+          for (j = ae = 0, ref6 = num - 1; 0 <= ref6 ? ae <= ref6 : ae >= ref6; j = 0 <= ref6 ? ++ae : --ae) {
+            dist = abs(centroids[j] - value);
+            if (dist < mindist) {
+              mindist = dist;
+              best = j;
+            }
+          }
+          clusterSizes[best]++;
+          assignments[i] = best;
+        }
+        newCentroids = new Array(num);
+        for (j = af = 0, ref7 = num - 1; 0 <= ref7 ? af <= ref7 : af >= ref7; j = 0 <= ref7 ? ++af : --af) {
+          newCentroids[j] = null;
+        }
+        for (i = ag = 0, ref8 = n - 1; 0 <= ref8 ? ag <= ref8 : ag >= ref8; i = 0 <= ref8 ? ++ag : --ag) {
+          cluster = assignments[i];
+          if (newCentroids[cluster] === null) {
+            newCentroids[cluster] = values[i];
+          } else {
+            newCentroids[cluster] += values[i];
+          }
+        }
+        for (j = ah = 0, ref9 = num - 1; 0 <= ref9 ? ah <= ref9 : ah >= ref9; j = 0 <= ref9 ? ++ah : --ah) {
+          newCentroids[j] *= 1 / clusterSizes[j];
+        }
+        repeat = false;
+        for (j = ai = 0, ref10 = num - 1; 0 <= ref10 ? ai <= ref10 : ai >= ref10; j = 0 <= ref10 ? ++ai : --ai) {
+          if (newCentroids[j] !== centroids[i]) {
+            repeat = true;
+            break;
+          }
+        }
+        centroids = newCentroids;
+        nb_iters++;
+        if (nb_iters > 200) {
+          repeat = false;
+        }
+      }
+      kClusters = {};
+      for (j = aj = 0, ref11 = num - 1; 0 <= ref11 ? aj <= ref11 : aj >= ref11; j = 0 <= ref11 ? ++aj : --aj) {
+        kClusters[j] = [];
+      }
+      for (i = ak = 0, ref12 = n - 1; 0 <= ref12 ? ak <= ref12 : ak >= ref12; i = 0 <= ref12 ? ++ak : --ak) {
+        cluster = assignments[i];
+        kClusters[cluster].push(values[i]);
+      }
+      tmpKMeansBreaks = [];
+      for (j = al = 0, ref13 = num - 1; 0 <= ref13 ? al <= ref13 : al >= ref13; j = 0 <= ref13 ? ++al : --al) {
+        tmpKMeansBreaks.push(kClusters[j][0]);
+        tmpKMeansBreaks.push(kClusters[j][kClusters[j].length - 1]);
+      }
+      tmpKMeansBreaks = tmpKMeansBreaks.sort(function(a, b) {
+        return a - b;
+      });
+      limits.push(tmpKMeansBreaks[0]);
+      for (i = am = 1, ref14 = tmpKMeansBreaks.length - 1; am <= ref14; i = am += 2) {
+        if (!isNaN(tmpKMeansBreaks[i])) {
+          limits.push(tmpKMeansBreaks[i]);
+        }
+      }
+    }
+    return limits;
+  };
+
+  hsi2rgb = function(h, s, i) {
+
+    /*
+    borrowed from here:
+    http://hummer.stanford.edu/museinfo/doc/examples/humdrum/keyscape2/hsi2rgb.cpp
+     */
+    var args, b, g, r;
+    args = unpack(arguments);
+    h = args[0], s = args[1], i = args[2];
+    h /= 360;
+    if (h < 1 / 3) {
+      b = (1 - s) / 3;
+      r = (1 + s * cos(TWOPI * h) / cos(PITHIRD - TWOPI * h)) / 3;
+      g = 1 - (b + r);
+    } else if (h < 2 / 3) {
+      h -= 1 / 3;
+      r = (1 - s) / 3;
+      g = (1 + s * cos(TWOPI * h) / cos(PITHIRD - TWOPI * h)) / 3;
+      b = 1 - (r + g);
+    } else {
+      h -= 2 / 3;
+      g = (1 - s) / 3;
+      b = (1 + s * cos(TWOPI * h) / cos(PITHIRD - TWOPI * h)) / 3;
+      r = 1 - (g + b);
+    }
+    r = limit(i * r * 3);
+    g = limit(i * g * 3);
+    b = limit(i * b * 3);
+    return [r * 255, g * 255, b * 255, args.length > 3 ? args[3] : 1];
+  };
+
+  rgb2hsi = function() {
+
+    /*
+    borrowed from here:
+    http://hummer.stanford.edu/museinfo/doc/examples/humdrum/keyscape2/rgb2hsi.cpp
+     */
+    var b, g, h, i, min, r, ref, s;
+    ref = unpack(arguments), r = ref[0], g = ref[1], b = ref[2];
+    TWOPI = Math.PI * 2;
+    r /= 255;
+    g /= 255;
+    b /= 255;
+    min = Math.min(r, g, b);
+    i = (r + g + b) / 3;
+    s = 1 - min / i;
+    if (s === 0) {
+      h = 0;
+    } else {
+      h = ((r - g) + (r - b)) / 2;
+      h /= Math.sqrt((r - g) * (r - g) + (r - b) * (g - b));
+      h = Math.acos(h);
+      if (b > g) {
+        h = TWOPI - h;
+      }
+      h /= TWOPI;
+    }
+    return [h * 360, s, i];
+  };
+
+  chroma.hsi = function() {
+    return (function(func, args, ctor) {
+      ctor.prototype = func.prototype;
+      var child = new ctor, result = func.apply(child, args);
+      return Object(result) === result ? result : child;
+    })(Color, slice.call(arguments).concat(['hsi']), function(){});
+  };
+
+  _input.hsi = hsi2rgb;
+
+  Color.prototype.hsi = function() {
+    return rgb2hsi(this._rgb);
+  };
+
+  interpolate_hsx = function(col1, col2, f, m) {
+    var dh, hue, hue0, hue1, lbv, lbv0, lbv1, res, sat, sat0, sat1, xyz0, xyz1;
+    if (m === 'hsl') {
+      xyz0 = col1.hsl();
+      xyz1 = col2.hsl();
+    } else if (m === 'hsv') {
+      xyz0 = col1.hsv();
+      xyz1 = col2.hsv();
+    } else if (m === 'hsi') {
+      xyz0 = col1.hsi();
+      xyz1 = col2.hsi();
+    } else if (m === 'lch' || m === 'hcl') {
+      m = 'hcl';
+      xyz0 = col1.hcl();
+      xyz1 = col2.hcl();
+    }
+    if (m.substr(0, 1) === 'h') {
+      hue0 = xyz0[0], sat0 = xyz0[1], lbv0 = xyz0[2];
+      hue1 = xyz1[0], sat1 = xyz1[1], lbv1 = xyz1[2];
+    }
+    if (!isNaN(hue0) && !isNaN(hue1)) {
+      if (hue1 > hue0 && hue1 - hue0 > 180) {
+        dh = hue1 - (hue0 + 360);
+      } else if (hue1 < hue0 && hue0 - hue1 > 180) {
+        dh = hue1 + 360 - hue0;
+      } else {
+        dh = hue1 - hue0;
+      }
+      hue = hue0 + f * dh;
+    } else if (!isNaN(hue0)) {
+      hue = hue0;
+      if ((lbv1 === 1 || lbv1 === 0) && m !== 'hsv') {
+        sat = sat0;
+      }
+    } else if (!isNaN(hue1)) {
+      hue = hue1;
+      if ((lbv0 === 1 || lbv0 === 0) && m !== 'hsv') {
+        sat = sat1;
+      }
+    } else {
+      hue = Number.NaN;
+    }
+    if (sat == null) {
+      sat = sat0 + f * (sat1 - sat0);
+    }
+    lbv = lbv0 + f * (lbv1 - lbv0);
+    return res = chroma[m](hue, sat, lbv);
+  };
+
+  _interpolators = _interpolators.concat((function() {
+    var len, o, ref, results;
+    ref = ['hsv', 'hsl', 'hsi', 'hcl', 'lch'];
+    results = [];
+    for (o = 0, len = ref.length; o < len; o++) {
+      m = ref[o];
+      results.push([m, interpolate_hsx]);
+    }
+    return results;
+  })());
+
+  interpolate_num = function(col1, col2, f, m) {
+    var n1, n2;
+    n1 = col1.num();
+    n2 = col2.num();
+    return chroma.num(n1 + (n2 - n1) * f, 'num');
+  };
+
+  _interpolators.push(['num', interpolate_num]);
+
+  interpolate_lab = function(col1, col2, f, m) {
+    var res, xyz0, xyz1;
+    xyz0 = col1.lab();
+    xyz1 = col2.lab();
+    return res = new Color(xyz0[0] + f * (xyz1[0] - xyz0[0]), xyz0[1] + f * (xyz1[1] - xyz0[1]), xyz0[2] + f * (xyz1[2] - xyz0[2]), m);
+  };
+
+  _interpolators.push(['lab', interpolate_lab]);
+
+}).call(this);
diff --git a/chroma.min.js b/chroma.min.js
new file mode 100644
index 0000000..546051e
--- /dev/null
+++ b/chroma.min.js
@@ -0,0 +1,33 @@
+/*
+chroma.js - JavaScript library for color conversions
+
+Copyright (c) 2011-2015, Gregor Aisch
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this
+   list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright notice,
+   this list of conditions and the following disclaimer in the documentation
+   and/or other materials provided with the distribution.
+
+3. The name Gregor Aisch may not be used to endorse or promote products
+   derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL GREGOR AISCH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+*/
+(function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,$,_,aa,ba,ca,da,ea,fa,ga,ha,ia,ja,ka,la,ma,na,oa,pa,qa,ra,sa,ta,ua,va,wa,xa,ya,za=[].slice;ua=function(){var a,b,c,d,e;for(a={},e="Boolean Number String Function Array Date RegExp Undefined Null".split(" "),d=0,b=e.length;b>d;d++)c=e[d],a["[object "+c+"]"]=c.toLowerCase();return function(b){var c;return c=Object.prototype.toString.call(b),a[c]||"object"}}(),S=function(a [...]
+},k.push(["lab",J])}).call(this);
\ No newline at end of file
diff --git a/doc/api.md b/doc/api.md
new file mode 100644
index 0000000..3a63069
--- /dev/null
+++ b/doc/api.md
@@ -0,0 +1,389 @@
+
+THIS DOCUMENT IS OUTDATED.
+
+Please check the most current documentation here:
+https://github.com/gka/chroma.js/blob/gh-pages/src/index.md
+
+or here, for the interactive version:
+http://gka.github.io/chroma.js/
+
+----------
+
+# Initializing colors
+
+## chroma(a, b, c, [a], [mode])
+
+Generic color factory. Returns an instance of chroma.Color. mode defaults to "rgb".
+
+The following calls all return the same color (red #ff0000):
+
+```javascript
+chroma("red");
+chroma("#ff0000");
+chroma("#f00");
+chroma("FF0000");
+chroma(255, 0, 0);
+chroma([255, 0, 0]);
+chroma(0, 1, 0.5, 'hsl');
+chroma([0, 1, 0.5], 'hsl');
+chroma(0, 1, 1, 'hsv');
+chroma("rgb(255,0,0)");
+chroma("rgb(100%,0%,0%)");
+chroma("hsl(0,100%,50%)");
+chroma(53.24, 80.09, 67.20, 'lab');
+chroma(53.24, 104.55, 40, 'lch');
+chroma(1, 0, 0, 'gl');
+chroma(0xff0000);
+chroma(0xff0000, 'num');
+chroma(0,1,0,0, 'cmyk');
+```
+
+
+## chroma.hex() / chroma.css()
+
+Returns a color from a hex code or css color. Alias: **chroma.css()**
+
+```javascript
+chroma.hex("#ff0000");
+chroma.hex("red");
+chroma.hex("rgb(255, 0, 0)");
+```
+## chroma.*xyz*()
+
+Creates a chroma.Color instance from a specific color space. Shortcut to *chroma(…, mode)*.
+
+```javascript
+chroma.rgb(255, 0, 0);
+chroma.hsl(0, 1, 0.5);
+chroma.hsv(120, 0.5, 0.5);
+chroma.lab(53.24, 80.09, 67.20);
+chroma.lch(53.24, 104.55, 40);
+chroma.gl(1, 0, 0);
+chroma.num(0xff0000);
+chroma.cmyk(0,1,0,0);
+```
+
+## chroma.kelvin()
+
+Generates a color from Kelvin temperature scale
+
+chroma.kelvin(6000);
+
+
+## chroma.random()
+
+Generates a random chroma.Color.
+
+```javascript
+chroma.random(); // color in range #000000 - #ffffff
+```
+
+## chroma.interpolate(color1, color2, f, mode)
+
+Colors can be also be interpolates between two other colors in a given mode.
+
+```
+chroma.interpolate('white', 'black', 0)  // #ffffff
+chroma.interpolate('white', 'black', 1)  // #000000
+chroma.interpolate('white', 'black', 0.5)  // #7f7f7f
+chroma.interpolate('white', 'black', 0.5, 'hsv')  // #808080
+chroma.interpolate('white', 'black', 0.5, 'lab')  // #777777
+```
+
+This also works with colors with alpha channel:
+
+```
+chroma.interpolate('rgba(0,0,0,0)', 'rgba(255,0,0,1)', 0.5).css()  //"rgba(127.5,0,0,0.5)"
+```
+
+## chroma.mix(color1, color2, f, mode)
+
+Alias for interpolate.
+
+
+## chroma.interpolate.bezier(colors)
+
+Colors can be also be interpolates between two other colors in a given mode.
+
+```
+bezInterpolator = chroma.interpolate.bezier(['white', 'yellow', 'red', 'black']);
+bezInterpolator(0).hex()  // #ffffff
+bezInterpolator(0.33).hex()  // #ffcc67
+bezInterpolator(0.66).hex()  // #b65f1a
+bezInterpolator(1).hex()  // #000000
+```
+
+# Working with chroma.colors
+
+Here's what you can do with it:
+
+* [color.hex|css|rgb|hsv|hsl|lab|lch|num()](#colorxxx)
+* [color.alpha()](#coloralpha)
+* [color.darken()](#colordarkenamount)
+* [color.brighten()](#colorbrightenamount)
+* [color.saturate()](#colorsaturateamount)
+* [color.desaturate()](#colordesaturateamount)
+* [color.luminance()](#colorluminance)
+
+### color.*xxx*()
+
+Returns the color components for a specific color space:
+
+```javascript
+chroma('red').hex()  // "#FF0000""
+chroma('red').rgb()  // [255, 0, 0]
+chroma('red').hsv()  // [0, 1, 1]
+chroma('red').hsl()  // [0, 1, 0.5]
+chroma('red').num()  // 16711680 === 0xff0000
+chroma('red').lab()  // [53.2407, 80.0924, 67.2031]
+chroma('red').lch()  // [53.2407, 104.5517, 39.9990]
+chroma('red').rgba() // [255, 0, 0, 1]
+chroma('red').css()  // "rgb(255,0,0)"
+chroma('red').alpha(0.7).css()  // "rgba(255,0,0,0.7)"
+chroma('red').css('hsl')        // "hsl(0,100%,50%)"
+chroma('red').alpha(0.7).css('hsl')  // "hsla(0,100%,50%,0.7)"
+chroma('blue').css('hsla') // "hsla(240,100%,50%,1)"
+```
+
+### color.alpha()
+
+Returns or sets the colors alpha value.
+
+```
+var red = chroma('red');
+red.alpha(0.5);
+red.css();  // rgba(255,0,0,0.5);
+```
+
+### color.darken(*amount*)
+
+Decreases the lightness of the color in *Lab* color space.
+
+```javascript
+chroma('red').darken().hex()  // #BC0000
+```
+
+### color.brighten(*amount*)
+
+Increases the lightness of the color in *Lab* color space.
+
+```javascript
+chroma('red').brighten().hex()  // #FF603B
+```
+
+### color.saturate(*amount*)
+
+Returns a more saturated variation of the color.
+
+```javascript
+chroma('#eecc99').saturate().hex() // #fcc973
+```
+
+### color.desaturate(*amount*)
+
+Returns a less saturated variation of the color.
+
+```javascript
+chroma('red').desaturate().hex() // #ec3d23
+```
+
+### color.luminance()
+
+Returns the [relative luminance](http://www.w3.org/TR/WCAG20/#relativeluminancedef) of the color, which is a value between 0 (black) and 1 (white).
+
+```javascript
+chroma('black').luminance() // 0
+chroma('white').luminance() // 1
+chroma('red').luminance() // 0.2126
+```
+
+### color.mix(other, f, [mode])
+
+Mixes the color with another color. 
+
+```javascript
+chroma.mix(color, other, f, mode)
+```
+
+As of version 0.6.2 you can also set the luminance directly:
+
+```javascript
+chroma('#ff0000').luminance(0.4).hex() // #ff8585"
+```
+
+# Working with color scales
+
+## chroma.scale()
+
+Creates a color scale function from the given set of colors.
+
+```javascript
+var scale = chroma.scale(['lightyellow', 'navy']);
+scale(0.5);  // #7F7FB0
+```
+
+Need some advice for good colors? How about using a pre-defined [ColorBrewer](http://colorbrewer2.com) scale:
+
+```javascript
+chroma.scale('RdYlBu');
+```
+
+### scale.out()
+
+By default the color scale functions return instances of chroma.Color.
+
+```javascript
+var col = scale(0.5);
+col.hex();  // #7F7FB0
+col.rgb();  // [127.5, 127.5, 176]
+```
+
+Using **scale.out()** you can configure the color scale to automatically return colors in the desired format.
+
+```javascript
+scale = chroma.scale(['lightyellow', 'navy']).out('hex');
+scale(0.5);  // "#7F7FB0"
+```
+
+### scale.mode()
+
+Specify in which color space the colors should be interpolated. Defaults to "rgb". You can use any of the following spaces:
+
+```javascript
+var scale = chroma.scale(['lightyellow', 'navy']);
+scale.mode('hsv')(0.5);  // #54C08A
+scale.mode('hsl')(0.5);  // #31FF98
+scale.mode('num')(0.5);  // #54C08A
+scale.mode('lab')(0.5);  // #967CB2
+scale.mode('lch')(0.5);  // #D26662
+```
+
+### scale.domain()
+
+You can specify the input range of your data (defaults to [0..1]).
+
+```javascript
+var scale = chroma.scale(['lightyellow', 'navy']).domain([0, 400]);
+scale(200);  // #7F7FB0
+```
+
+Instead of just passing the minimum and maximum values you can specify custom "stops". chroma.js would now return a distinct set of four different colors:
+
+```javascript
+var scale = chroma.scale(['lightyellow', 'navy'])
+.domain([0, 100, 200, 300, 400]);
+scale(98);  // #7F7FB0
+scale(99);  // #7F7FB0
+scale(100);  // #AAAAC0
+scale(101);  // #AAAAC0
+```
+
+If you don't want to pick the stops by hand, you can auto-generate a set of *N* equidistant input classes:
+
+```javascript
+chroma.scale(['#eee', '#900']).domain([0, 400], 7);
+```
+
+Don't like linear scales? How about logarithmic stops?
+
+```javascript
+chroma.scale(['#eee', '#900']).domain([1, 1000000], 7, 'log');
+```
+
+For more advanced techniques you need the actual dataset
+
+```javascript
+chroma.scale(['#eee', '#900']).domain(values, 5, 'quantiles');
+chroma.scale(['#eee', '#900']).domain(values, 5, 'k-means');
+```
+
+Calling .domain() with no arguments will return the current domain.
+
+```
+chroma.scale(['white', 'red']).domain([0, 100], 4).domain() // [0, 25, 50, 75, 100]
+```
+
+### scale.range()
+
+If you need to change the color range after initializing the color scale.
+
+```javascript
+chroma.scale().range(['lightyellow', 'navy']);
+```
+
+### scale.correctLightness()
+
+As of version 0.5.2 chroma.scale supports automatic lightness correction of color scales.
+
+**Important note:** The lightness correction only works for sequential color scales, where the input colors are ordered by lightness. So this won’t work for diverging color scales, yet.
+
+```javascript
+chroma.scale(['lightyellow', 'navy']).correctLightness(true);
+```
+
+### scale.colors([numColors,] mode='hex')
+
+If your color scale has set a distinct number of classes, scale.colors() can be used to retreive all possible colors generated by this scale.
+
+```javascript
+chroma.scale('RdYlGn').domain([0,1], 5).colors()
+// returns ['#a50026', '#f88d52', '#ffffbf', '#86cb66', '#006837']
+```
+
+Since 1.0.1 the same can be achieved by just passing the number of colors:
+
+```javascript
+chroma.scale('RdYlGn').colors(5)
+```
+
+### chroma.cubehelix(start, rotations, hue, gamma, lightness)
+
+Dave Green's [cubehelix color scheme](http://www.mrao.cam.ac.uk/~dag/CUBEHELIX/)!!
+
+Parameters (description copied from Dave Green):
+
+* **start** color for [hue rotation](http://en.wikipedia.org/wiki/Hue#/media/File:HueScale.svg), default=300
+* **rotation**: number of rotations (e.g. 1=360°, 1.5=540°), default=-1.5
+* **hue**: controls how saturated the colour of all hues are. either single value or range, default=1
+* **gamma factor**: can be used to emphasise low or high intensity values, default=1
+* **lightness** range: default: [0,1]  (black -> white)
+
+```javascript
+helix = chroma.cubehelix(300, -1.5)
+helix(0).hex() // '#000000'
+helix(1).hex() // '#ffffff'
+```
+
+# Useful methods
+
+## chroma.luminance
+
+Shortcut for the color.luminance()
+
+```javascript
+chroma.luminance('black') // 0
+chroma.luminance('white') // 1
+chroma.luminance('#ff0000') // 0.2126
+```
+
+## chroma.contrast(a, b)
+
+Returns the [contrast ratio](http://www.w3.org/TR/WCAG20/#contrast-ratiodef) between two given colors. According to the [Web Content Accessibility Guidelines](http://www.w3.org/TR/WCAG20) the contrast between background and small text [should be at least](http://www.w3.org/TR/WCAG20/#visual-audio-contrast-contrast) 4.5 : 1.
+
+```javascript
+chroma.contrast('white', 'navy')  // 16.00 – ok
+chroma.contrast('white', 'yellow')  // 1.07 – not ok!
+```
+
+## chroma.blend.MODE(bottom, top)
+
+Blends two colors using one of the following blend modes: normal, multiply, screen, overlay, darken, lighten, dodge, burn
+
+```javascript
+chroma.blend.multiply('pink', 'cyan').name()  // '#00c0cb'
+chroma.blend.screen('pink', 'cyan').name()  // 'white'
+
+// alternative syntax
+chroma.blend('pink', 'cyan', 'multiply')
+chroma('pink').blend('cyan', 'multiply')
+```
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..3b6af7e
--- /dev/null
+++ b/package.json
@@ -0,0 +1,52 @@
+{
+  "name": "chroma-js",
+  "description": "JavaScript library for color conversions",
+  "version": "1.1.1",
+  "author": "Gregor Aisch",
+  "homepage": "https://github.com/gka/chroma.js",
+  "keywords": [
+    "color"
+  ],
+  "maintainers": [
+    {
+      "name": "Klemen Slavič",
+      "email": "klemen at celtra.com",
+      "web": "http://about.me/klemen.slavic"
+    },
+    {
+      "name": "Gregor Aisch",
+      "email": "mail at driven-by-data.net",
+      "web": "http://driven-by-data.net"
+    }
+  ],
+  "bugs": "https://github.com/gka/chroma.js/issues",
+  "repository": {
+    "type": "git",
+    "url": "git://github.com/gka/chroma.js.git"
+  },
+  "main": "chroma.js",
+  "scripts": {
+    "build": "grunt",
+    "test": "./node_modules/vows/bin/vows --spec"
+  },
+  "devDependencies": {
+    "coffee-script": "1.9.2",
+    "es6-shim": "^0.18.0",
+    "grunt": "^0.4.5",
+    "grunt-contrib-clean": "^0.6.0",
+    "grunt-contrib-coffee": "^0.13.0",
+    "grunt-contrib-uglify": "^0.9.1",
+    "grunt-replace": "^0.9.2",
+    "uglify-js": "2.x",
+    "vows": "0.8.x",
+    "catty": "gka/catty#coffeescript"
+  },
+  "spm": {
+    "main": "chroma.js",
+    "ignore": [
+      "src",
+      "doc",
+      "test"
+    ]
+  }
+}
diff --git a/readme.md b/readme.md
new file mode 100644
index 0000000..a72e797
--- /dev/null
+++ b/readme.md
@@ -0,0 +1,89 @@
+# Chroma.js
+
+Chroma.js is a tiny JavaScript library (12kB) for all kinds of color conversions and color scales.
+
+[![Build Status](https://travis-ci.org/gka/chroma.js.svg?branch=master)](https://travis-ci.org/gka/chroma.js)
+
+### Usage
+
+
+Initiate and manipulate colors:
+
+```javascript
+chroma('#D4F880').darken().hex();  // #9BC04B
+```
+
+Working with color scales is easy, too:
+
+```javascript
+scale = chroma.scale(['white', 'red']);
+scale(0.5).hex(); // #FF7F7F
+```
+
+Lab/Lch interpolation looks better than RGB
+
+```javascript
+chroma.scale(['white', 'red']).mode('lab');
+```
+
+Custom domains! Quantiles! Color Brewer!!
+
+```javascript
+chroma.scale('RdYlBu').domain(myValues, 7, 'quantiles');
+```
+
+And why not use logarithmic color scales once in your life?
+
+```javascript
+chroma.scale(['lightyellow', 'navy']).domain([1, 100000], 7, 'log');
+```
+
+### Like it?
+
+Please check the most current documentation here:
+
+or here, for the interactive version: 
+
+Why not dive into the interactive [API docs](http://gka.github.io/chroma.js/) (there's a [static version](https://github.com/gka/chroma.js/blob/gh-pages/src/index.md), too) and download [chroma.min.js](https://raw.github.com/gka/chroma.js/master/chroma.min.js) right away.
+
+You can use it in node.js, too!
+
+    npm install chroma-js
+
+
+### Build instructions
+
+To compile the coffee-script source files you have to run (might have to ``npm install` first)
+
+    grunt
+
+To run the tests simply run
+
+    npm test
+
+
+### Similar Libraries / Prior Art
+
+* [Chromatist](https://github.com/jrus/chromatist)
+* [GrapeFruit](https://github.com/xav/Grapefruit) (Python)
+* [colors.py](https://github.com/mattrobenolt/colors.py) (Python)
+* [d3.js](https://github.com/mbostock/d3)
+
+
+### Author
+
+Chroma.js is written by [Gregor Aisch](http://driven-by-data.net).
+
+### License
+
+Released under [BSD license](http://opensource.org/licenses/BSD-3-Clause).
+Versions prior to 0.4 were released under [GPL](http://www.gnu.org/licenses/gpl-3.0).
+
+### Known issues
+
+* HSI color conversion is experimental and produces weird results sometimes
+
+### Further reading
+
+* [How To Avoid Equidistant HSV Colors](https://vis4.net/blog/posts/avoid-equidistant-hsv-colors/)
+* [Mastering Multi-hued Color Scales with Chroma.js](https://vis4.net/blog/posts/mastering-multi-hued-color-scales/)
diff --git a/src/analyze.coffee b/src/analyze.coffee
new file mode 100644
index 0000000..f460cf6
--- /dev/null
+++ b/src/analyze.coffee
@@ -0,0 +1,24 @@
+
+
+chroma.analyze = (data) ->
+    r =
+        min: Number.MAX_VALUE
+        max: Number.MAX_VALUE*-1
+        sum: 0
+        values: []
+        count: 0
+
+    for val in data
+        if val? and not isNaN val
+            r.values.push val
+            r.sum += val
+            r.min = val if val < r.min
+            r.max = val if val > r.max
+            r.count += 1
+
+    r.domain = [r.min, r.max]
+
+    r.limits = (mode, num) ->
+        chroma.limits r, mode, num
+    
+    r
diff --git a/src/api.coffee b/src/api.coffee
new file mode 100644
index 0000000..0d4693c
--- /dev/null
+++ b/src/api.coffee
@@ -0,0 +1,20 @@
+
+chroma = () ->
+    return arguments[0] if arguments[0] instanceof Color
+    new Color arguments...
+
+_interpolators = []
+
+# CommonJS module is defined
+module.exports = chroma if module? and module.exports?
+
+if typeof define == 'function' and define.amd
+    define [], () -> chroma
+else
+    root = (exports ? this)
+    root.chroma = chroma
+
+
+chroma.version = '@@version'
+
+# exposing raw classes for testing purposes
diff --git a/src/color.coffee b/src/color.coffee
new file mode 100644
index 0000000..d9fb14a
--- /dev/null
+++ b/src/color.coffee
@@ -0,0 +1,83 @@
+###*
+    chroma.js
+
+    Copyright (c) 2011-2013, Gregor Aisch
+    All rights reserved.
+
+    Redistribution and use in source and binary forms, with or without
+    modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice, this
+      list of conditions and the following disclaimer.
+
+    * Redistributions in binary form must reproduce the above copyright notice,
+      this list of conditions and the following disclaimer in the documentation
+      and/or other materials provided with the distribution.
+
+    * The name Gregor Aisch may not be used to endorse or promote products
+      derived from this software without specific prior written permission.
+
+    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+    DISCLAIMED. IN NO EVENT SHALL GREGOR AISCH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+    INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+    BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+    DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+    OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+    NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+    EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+    @source: https://github.com/gka/chroma.js
+###
+
+# @require utils api
+
+_input = {}
+_guess_formats = []
+_guess_formats_sorted = false
+
+class Color
+
+    constructor: () ->
+        me = @
+
+        args = []
+        for arg in arguments
+            args.push arg if arg?
+
+        # last argument could be the mode
+        mode = args[args.length-1]
+        if _input[mode]?
+            me._rgb = clip_rgb _input[mode] unpack args[...-1]
+        else
+            # sort input type guess by desc priotity
+            if not _guess_formats_sorted
+                _guess_formats = _guess_formats.sort (a,b) ->
+                    b.p - a.p
+                _guess_formats_sorted = true
+            # guess format
+            for chk in _guess_formats
+                mode = chk.test args...
+                break if mode
+            if mode
+                me._rgb = clip_rgb _input[mode] args...
+
+        # by now we should have a color
+        console.warn 'unknown format: '+args if not me._rgb?
+        me._rgb = [0,0,0] if not me._rgb?
+
+        # add alpha
+        me._rgb.push 1 if me._rgb.length == 3
+
+    alpha: (alpha) ->
+        if arguments.length
+            @_rgb[3] = alpha
+            return @
+        @_rgb[3]
+
+    toString: ->
+        @name()
+
+
+chroma._input = _input
diff --git a/src/colors/colorbrewer.coffee b/src/colors/colorbrewer.coffee
new file mode 100644
index 0000000..04a2f9e
--- /dev/null
+++ b/src/colors/colorbrewer.coffee
@@ -0,0 +1,63 @@
+###*
+	ColorBrewer colors for chroma.js
+
+	Copyright (c) 2002 Cynthia Brewer, Mark Harrower, and The 
+	Pennsylvania State University.
+
+	Licensed under the Apache License, Version 2.0 (the "License"); 
+	you may not use this file except in compliance with the License.
+	You may obtain a copy of the License at	
+	http://www.apache.org/licenses/LICENSE-2.0
+
+	Unless required by applicable law or agreed to in writing, software distributed
+	under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+	CONDITIONS OF ANY KIND, either express or implied. See the License for the
+	specific language governing permissions and limitations under the License.
+
+    @preserve
+###
+
+
+chroma.brewer = brewer =
+	# sequential
+	OrRd: ['#fff7ec', '#fee8c8', '#fdd49e', '#fdbb84', '#fc8d59', '#ef6548', '#d7301f', '#b30000', '#7f0000']
+	PuBu: ['#fff7fb', '#ece7f2', '#d0d1e6', '#a6bddb', '#74a9cf', '#3690c0', '#0570b0', '#045a8d', '#023858']
+	BuPu: ['#f7fcfd', '#e0ecf4', '#bfd3e6', '#9ebcda', '#8c96c6', '#8c6bb1', '#88419d', '#810f7c', '#4d004b']
+	Oranges: ['#fff5eb', '#fee6ce', '#fdd0a2', '#fdae6b', '#fd8d3c', '#f16913', '#d94801', '#a63603', '#7f2704']
+	BuGn: ['#f7fcfd', '#e5f5f9', '#ccece6', '#99d8c9', '#66c2a4', '#41ae76', '#238b45', '#006d2c', '#00441b']
+	YlOrBr: ['#ffffe5', '#fff7bc', '#fee391', '#fec44f', '#fe9929', '#ec7014', '#cc4c02', '#993404', '#662506']
+	YlGn: ['#ffffe5', '#f7fcb9', '#d9f0a3', '#addd8e', '#78c679', '#41ab5d', '#238443', '#006837', '#004529']
+	Reds: ['#fff5f0', '#fee0d2', '#fcbba1', '#fc9272', '#fb6a4a', '#ef3b2c', '#cb181d', '#a50f15', '#67000d']
+	RdPu: ['#fff7f3', '#fde0dd', '#fcc5c0', '#fa9fb5', '#f768a1', '#dd3497', '#ae017e', '#7a0177', '#49006a']
+	Greens: ['#f7fcf5', '#e5f5e0', '#c7e9c0', '#a1d99b', '#74c476', '#41ab5d', '#238b45', '#006d2c', '#00441b']
+	YlGnBu: ['#ffffd9', '#edf8b1', '#c7e9b4', '#7fcdbb', '#41b6c4', '#1d91c0', '#225ea8', '#253494', '#081d58']
+	Purples: ['#fcfbfd', '#efedf5', '#dadaeb', '#bcbddc', '#9e9ac8', '#807dba', '#6a51a3', '#54278f', '#3f007d']
+	GnBu: ['#f7fcf0', '#e0f3db', '#ccebc5', '#a8ddb5', '#7bccc4', '#4eb3d3', '#2b8cbe', '#0868ac', '#084081']
+	Greys: ['#ffffff', '#f0f0f0', '#d9d9d9', '#bdbdbd', '#969696', '#737373', '#525252', '#252525', '#000000']
+	YlOrRd: ['#ffffcc', '#ffeda0', '#fed976', '#feb24c', '#fd8d3c', '#fc4e2a', '#e31a1c', '#bd0026', '#800026']
+	PuRd: ['#f7f4f9', '#e7e1ef', '#d4b9da', '#c994c7', '#df65b0', '#e7298a', '#ce1256', '#980043', '#67001f']
+	Blues: ['#f7fbff', '#deebf7', '#c6dbef', '#9ecae1', '#6baed6', '#4292c6', '#2171b5', '#08519c', '#08306b']
+	PuBuGn: ['#fff7fb', '#ece2f0', '#d0d1e6', '#a6bddb', '#67a9cf', '#3690c0', '#02818a', '#016c59', '#014636']
+
+	# diverging
+
+	Spectral: ['#9e0142', '#d53e4f', '#f46d43', '#fdae61', '#fee08b', '#ffffbf', '#e6f598', '#abdda4', '#66c2a5', '#3288bd', '#5e4fa2']
+	RdYlGn: ['#a50026', '#d73027', '#f46d43', '#fdae61', '#fee08b', '#ffffbf', '#d9ef8b', '#a6d96a', '#66bd63', '#1a9850', '#006837']
+	RdBu: ['#67001f', '#b2182b', '#d6604d', '#f4a582', '#fddbc7', '#f7f7f7', '#d1e5f0', '#92c5de', '#4393c3', '#2166ac', '#053061']
+	PiYG: ['#8e0152', '#c51b7d', '#de77ae', '#f1b6da', '#fde0ef', '#f7f7f7', '#e6f5d0', '#b8e186', '#7fbc41', '#4d9221', '#276419']
+	PRGn: ['#40004b', '#762a83', '#9970ab', '#c2a5cf', '#e7d4e8', '#f7f7f7', '#d9f0d3', '#a6dba0', '#5aae61', '#1b7837', '#00441b']
+	RdYlBu: ['#a50026', '#d73027', '#f46d43', '#fdae61', '#fee090', '#ffffbf', '#e0f3f8', '#abd9e9', '#74add1', '#4575b4', '#313695']
+	BrBG: ['#543005', '#8c510a', '#bf812d', '#dfc27d', '#f6e8c3', '#f5f5f5', '#c7eae5', '#80cdc1', '#35978f', '#01665e', '#003c30']
+	RdGy: ['#67001f', '#b2182b', '#d6604d', '#f4a582', '#fddbc7', '#ffffff', '#e0e0e0', '#bababa', '#878787', '#4d4d4d', '#1a1a1a']
+	PuOr: ['#7f3b08', '#b35806', '#e08214', '#fdb863', '#fee0b6', '#f7f7f7', '#d8daeb', '#b2abd2', '#8073ac', '#542788', '#2d004b']
+
+	# qualitative
+
+	Set2: ['#66c2a5', '#fc8d62', '#8da0cb', '#e78ac3', '#a6d854', '#ffd92f', '#e5c494', '#b3b3b3']
+	Accent: ['#7fc97f', '#beaed4', '#fdc086', '#ffff99', '#386cb0', '#f0027f', '#bf5b17', '#666666']
+	Set1: ['#e41a1c', '#377eb8', '#4daf4a', '#984ea3', '#ff7f00', '#ffff33', '#a65628', '#f781bf', '#999999']
+	Set3: ['#8dd3c7', '#ffffb3', '#bebada', '#fb8072', '#80b1d3', '#fdb462', '#b3de69', '#fccde5', '#d9d9d9', '#bc80bd', '#ccebc5', '#ffed6f']
+	Dark2: ['#1b9e77', '#d95f02', '#7570b3', '#e7298a', '#66a61e', '#e6ab02', '#a6761d', '#666666']
+	Paired: ['#a6cee3', '#1f78b4', '#b2df8a', '#33a02c', '#fb9a99', '#e31a1c', '#fdbf6f', '#ff7f00', '#cab2d6', '#6a3d9a', '#ffff99', '#b15928']
+	Pastel2: ['#b3e2cd', '#fdcdac', '#cbd5e8', '#f4cae4', '#e6f5c9', '#fff2ae', '#f1e2cc', '#cccccc']
+	Pastel1: ['#fbb4ae', '#b3cde3', '#ccebc5', '#decbe4', '#fed9a6', '#ffffcc', '#e5d8bd', '#fddaec', '#f2f2f2']
diff --git a/src/colors/w3cx11.coffee b/src/colors/w3cx11.coffee
new file mode 100644
index 0000000..70c5b5b
--- /dev/null
+++ b/src/colors/w3cx11.coffee
@@ -0,0 +1,157 @@
+###*
+	X11 color names
+
+	http://www.w3.org/TR/css3-color/#svg-color
+###
+
+w3cx11 =
+    indigo: "#4b0082"
+    gold: "#ffd700"
+    hotpink: "#ff69b4"
+    firebrick: "#b22222"
+    indianred: "#cd5c5c"
+    yellow: "#ffff00"
+    mistyrose: "#ffe4e1"
+    darkolivegreen: "#556b2f"
+    olive: "#808000"
+    darkseagreen: "#8fbc8f"
+    pink: "#ffc0cb"
+    tomato: "#ff6347"
+    lightcoral: "#f08080"
+    orangered: "#ff4500"
+    navajowhite: "#ffdead"
+    lime: "#00ff00"
+    palegreen: "#98fb98"
+    darkslategrey: "#2f4f4f"
+    greenyellow: "#adff2f"
+    burlywood: "#deb887"
+    seashell: "#fff5ee"
+    mediumspringgreen: "#00fa9a"
+    fuchsia: "#ff00ff"
+    papayawhip: "#ffefd5"
+    blanchedalmond: "#ffebcd"
+    chartreuse: "#7fff00"
+    dimgray: "#696969"
+    black: "#000000"
+    peachpuff: "#ffdab9"
+    springgreen: "#00ff7f"
+    aquamarine: "#7fffd4"
+    white: "#ffffff"
+    orange: "#ffa500"
+    lightsalmon: "#ffa07a"
+    darkslategray: "#2f4f4f"
+    brown: "#a52a2a"
+    ivory: "#fffff0"
+    dodgerblue: "#1e90ff"
+    peru: "#cd853f"
+    lawngreen: "#7cfc00"
+    chocolate: "#d2691e"
+    crimson: "#dc143c"
+    forestgreen: "#228b22"
+    darkgrey: "#a9a9a9"
+    lightseagreen: "#20b2aa"
+    cyan: "#00ffff"
+    mintcream: "#f5fffa"
+    silver: "#c0c0c0"
+    antiquewhite: "#faebd7"
+    mediumorchid: "#ba55d3"
+    skyblue: "#87ceeb"
+    gray: "#808080"
+    darkturquoise: "#00ced1"
+    goldenrod: "#daa520"
+    darkgreen: "#006400"
+    floralwhite: "#fffaf0"
+    darkviolet: "#9400d3"
+    darkgray: "#a9a9a9"
+    moccasin: "#ffe4b5"
+    saddlebrown: "#8b4513"
+    grey: "#808080"
+    darkslateblue: "#483d8b"
+    lightskyblue: "#87cefa"
+    lightpink: "#ffb6c1"
+    mediumvioletred: "#c71585"
+    slategrey: "#708090"
+    red: "#ff0000"
+    deeppink: "#ff1493"
+    limegreen: "#32cd32"
+    darkmagenta: "#8b008b"
+    palegoldenrod: "#eee8aa"
+    plum: "#dda0dd"
+    turquoise: "#40e0d0"
+    lightgrey: "#d3d3d3"
+    lightgoldenrodyellow: "#fafad2"
+    darkgoldenrod: "#b8860b"
+    lavender: "#e6e6fa"
+    maroon: "#800000"
+    yellowgreen: "#9acd32"
+    sandybrown: "#f4a460"
+    thistle: "#d8bfd8"
+    violet: "#ee82ee"
+    navy: "#000080"
+    magenta: "#ff00ff"
+    dimgrey: "#696969"
+    tan: "#d2b48c"
+    rosybrown: "#bc8f8f"
+    olivedrab: "#6b8e23"
+    blue: "#0000ff"
+    lightblue: "#add8e6"
+    ghostwhite: "#f8f8ff"
+    honeydew: "#f0fff0"
+    cornflowerblue: "#6495ed"
+    slateblue: "#6a5acd"
+    linen: "#faf0e6"
+    darkblue: "#00008b"
+    powderblue: "#b0e0e6"
+    seagreen: "#2e8b57"
+    darkkhaki: "#bdb76b"
+    snow: "#fffafa"
+    sienna: "#a0522d"
+    mediumblue: "#0000cd"
+    royalblue: "#4169e1"
+    lightcyan: "#e0ffff"
+    green: "#008000"
+    mediumpurple: "#9370db"
+    midnightblue: "#191970"
+    cornsilk: "#fff8dc"
+    paleturquoise: "#afeeee"
+    bisque: "#ffe4c4"
+    slategray: "#708090"
+    darkcyan: "#008b8b"
+    khaki: "#f0e68c"
+    wheat: "#f5deb3"
+    teal: "#008080"
+    darkorchid: "#9932cc"
+    deepskyblue: "#00bfff"
+    salmon: "#fa8072"
+    darkred: "#8b0000"
+    steelblue: "#4682b4"
+    palevioletred: "#db7093"
+    lightslategray: "#778899"
+    aliceblue: "#f0f8ff"
+    lightslategrey: "#778899"
+    lightgreen: "#90ee90"
+    orchid: "#da70d6"
+    gainsboro: "#dcdcdc"
+    mediumseagreen: "#3cb371"
+    lightgray: "#d3d3d3"
+    mediumturquoise: "#48d1cc"
+    lemonchiffon: "#fffacd"
+    cadetblue: "#5f9ea0"
+    lightyellow: "#ffffe0"
+    lavenderblush: "#fff0f5"
+    coral: "#ff7f50"
+    purple: "#800080"
+    aqua: "#00ffff"
+    whitesmoke: "#f5f5f5"
+    mediumslateblue: "#7b68ee"
+    darkorange: "#ff8c00"
+    mediumaquamarine: "#66cdaa"
+    darksalmon: "#e9967a"
+    beige: "#f5f5dc"
+    blueviolet: "#8a2be2"
+    azure: "#f0ffff"
+    lightsteelblue: "#b0c4de"
+    oldlace: "#fdf5e6"
+    rebeccapurple: "#663399"
+
+chroma.colors = colors = w3cx11
diff --git a/src/converter/in/cmyk2rgb.coffee b/src/converter/in/cmyk2rgb.coffee
new file mode 100644
index 0000000..194661e
--- /dev/null
+++ b/src/converter/in/cmyk2rgb.coffee
@@ -0,0 +1,10 @@
+
+cmyk2rgb = () ->
+    args = unpack arguments
+    [c,m,y,k] = args
+    alpha = if args.length > 4 then args[4] else 1
+    return [0,0,0,alpha] if k == 1
+    r = if c >= 1 then 0 else round 255 * (1-c) * (1-k)
+    g = if m >= 1 then 0 else round 255 * (1-m) * (1-k)
+    b = if y >= 1 then 0 else round 255 * (1-y) * (1-k)
+    [r,g,b,alpha]
\ No newline at end of file
diff --git a/src/converter/in/css2rgb.coffee b/src/converter/in/css2rgb.coffee
new file mode 100644
index 0000000..2d5a4ce
--- /dev/null
+++ b/src/converter/in/css2rgb.coffee
@@ -0,0 +1,45 @@
+# @requires utils hex2rgb hsl2rgb
+
+css2rgb = (css) ->
+    css = css.toLowerCase()
+    # named X11 colors
+    if chroma.colors? and chroma.colors[css]
+        return hex2rgb chroma.colors[css]
+    # rgb(250,20,0)
+    if m = css.match /rgb\(\s*(\-?\d+),\s*(\-?\d+)\s*,\s*(\-?\d+)\s*\)/
+        rgb = m.slice 1,4
+        for i in [0..2]
+            rgb[i] = +rgb[i]
+        rgb[3] = 1  # default alpha
+    # rgba(250,20,0,0.4)
+    else if m = css.match /rgba\(\s*(\-?\d+),\s*(\-?\d+)\s*,\s*(\-?\d+)\s*,\s*([01]|[01]?\.\d+)\)/
+        rgb = m.slice 1,5
+        for i in [0..3]
+            rgb[i] = +rgb[i]
+    # rgb(100%,0%,0%)
+    else if m = css.match /rgb\(\s*(\-?\d+(?:\.\d+)?)%,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*\)/
+        rgb = m.slice 1,4
+        for i in [0..2]
+            rgb[i] = round rgb[i] * 2.55
+        rgb[3] = 1  # default alpha
+    # rgba(100%,0%,0%,0.4)
+    else if m = css.match /rgba\(\s*(\-?\d+(?:\.\d+)?)%,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)/
+        rgb = m.slice 1,5
+        for i in [0..2]
+            rgb[i] = round rgb[i] * 2.55
+        rgb[3] = +rgb[3]
+    # hsl(0,100%,50%)
+    else if m = css.match /hsl\(\s*(\-?\d+(?:\.\d+)?),\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*\)/
+        hsl = m.slice 1,4
+        hsl[1] *= 0.01
+        hsl[2] *= 0.01
+        rgb = hsl2rgb hsl
+        rgb[3] = 1
+    # hsla(0,100%,50%,0.5)
+    else if m = css.match /hsla\(\s*(\-?\d+(?:\.\d+)?),\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)/
+        hsl = m.slice 1,4
+        hsl[1] *= 0.01
+        hsl[2] *= 0.01
+        rgb = hsl2rgb hsl
+        rgb[3] = +m[4]  # default alpha = 1
+    rgb
diff --git a/src/converter/in/hex2rgb.coffee b/src/converter/in/hex2rgb.coffee
new file mode 100644
index 0000000..5321d19
--- /dev/null
+++ b/src/converter/in/hex2rgb.coffee
@@ -0,0 +1,29 @@
+hex2rgb = (hex) ->
+    if hex.match /^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/
+        if hex.length == 4 or hex.length == 7
+            hex = hex.substr(1)
+        if hex.length == 3
+            hex = hex.split("")
+            hex = hex[0]+hex[0]+hex[1]+hex[1]+hex[2]+hex[2]
+        u = parseInt(hex, 16)
+        r = u >> 16
+        g = u >> 8 & 0xFF
+        b = u & 0xFF
+        return [r,g,b,1]
+
+    # match rgba hex format, eg #FF000077
+    if hex.match /^#?([A-Fa-f0-9]{8})$/
+        if hex.length == 9
+            hex = hex.substr(1)
+        u = parseInt(hex, 16)
+        r = u >> 24 & 0xFF
+        g = u >> 16 & 0xFF
+        b = u >> 8 & 0xFF
+        a = round((u & 0xFF) / 0xFF * 100) / 100
+        return [r,g,b,a]
+
+    # check for css colors, too
+    if _input.css? and rgb = _input.css hex
+        return rgb
+
+    throw "unknown color: "+hex
diff --git a/src/converter/in/hsi2rgb.coffee b/src/converter/in/hsi2rgb.coffee
new file mode 100644
index 0000000..3c5fc75
--- /dev/null
+++ b/src/converter/in/hsi2rgb.coffee
@@ -0,0 +1,32 @@
+# @requires utils
+
+hsi2rgb = (h,s,i) ->
+    ###
+    borrowed from here:
+    http://hummer.stanford.edu/museinfo/doc/examples/humdrum/keyscape2/hsi2rgb.cpp
+    ###
+    args = unpack arguments
+    [h,s,i] = args
+
+    # normalize hue
+    #h += 360 if h < 0
+    #h -= 360 if h > 360
+    h /= 360
+    if h < 1/3
+        b = (1-s)/3
+        r = (1+s*cos(TWOPI*h)/cos(PITHIRD-TWOPI*h))/3
+        g = 1 - (b+r)
+    else if h < 2/3
+        h -= 1/3
+        r = (1-s)/3
+        g = (1+s*cos(TWOPI*h)/cos(PITHIRD-TWOPI*h))/3
+        b = 1 - (r+g)
+    else
+        h -= 2/3
+        g = (1-s)/3
+        b = (1+s*cos(TWOPI*h)/cos(PITHIRD-TWOPI*h))/3
+        r = 1 - (g+b)
+    r = limit i*r*3
+    g = limit i*g*3
+    b = limit i*b*3
+    [r*255, g*255, b*255, if args.length > 3 then args[3] else 1]
diff --git a/src/converter/in/hsl2rgb.coffee b/src/converter/in/hsl2rgb.coffee
new file mode 100644
index 0000000..18ef67d
--- /dev/null
+++ b/src/converter/in/hsl2rgb.coffee
@@ -0,0 +1,29 @@
+# @requires utils
+
+hsl2rgb = () ->
+    args = unpack arguments
+    [h,s,l] = args
+    if s == 0
+        r = g = b = l*255
+    else
+        t3 = [0,0,0]
+        c = [0,0,0]
+        t2 = if l < 0.5 then l * (1+s) else l+s-l*s
+        t1 = 2 * l - t2
+        h /= 360
+        t3[0] = h + 1/3
+        t3[1] = h
+        t3[2] = h - 1/3
+        for i in [0..2]
+            t3[i] += 1 if t3[i] < 0
+            t3[i] -= 1 if t3[i] > 1
+            if 6 * t3[i] < 1
+                c[i] = t1 + (t2 - t1) * 6 * t3[i]
+            else if 2 * t3[i] < 1
+                c[i] = t2
+            else if 3 * t3[i] < 2
+                c[i] = t1 + (t2 - t1) * ((2 / 3) - t3[i]) * 6
+            else
+                c[i] = t1
+        [r,g,b] = [round(c[0]*255),round(c[1]*255),round(c[2]*255)]
+    if args.length > 3 then [r,g,b,args[3]] else [r,g,b]
diff --git a/src/converter/in/hsv2rgb.coffee b/src/converter/in/hsv2rgb.coffee
new file mode 100644
index 0000000..68b2441
--- /dev/null
+++ b/src/converter/in/hsv2rgb.coffee
@@ -0,0 +1,28 @@
+
+hsv2rgb = () ->
+    args = unpack arguments
+    [h,s,v] = args
+    v *= 255
+    if s is 0
+        r = g = b = v
+    else
+        h = 0 if h is 360
+        h -= 360 if h > 360
+        h += 360 if h < 0
+        h /= 60
+        i = floor h
+        f = h - i
+        p = v * (1 - s)
+        q = v * (1 - s * f)
+        t = v * (1 - s * (1 - f))
+        switch i
+            when 0 then [r,g,b] = [v, t, p]
+            when 1 then [r,g,b] = [q, v, p]
+            when 2 then [r,g,b] = [p, v, t]
+            when 3 then [r,g,b] = [p, q, v]
+            when 4 then [r,g,b] = [t, p, v]
+            when 5 then [r,g,b] = [v, p, q]
+    r = round r
+    g = round g
+    b = round b
+    [r, g, b, if args.length > 3 then args[3] else 1]
\ No newline at end of file
diff --git a/src/converter/in/lab2rgb.coffee b/src/converter/in/lab2rgb.coffee
new file mode 100644
index 0000000..37eb095
--- /dev/null
+++ b/src/converter/in/lab2rgb.coffee
@@ -0,0 +1,31 @@
+# requrie lab-constants
+
+lab2rgb = () ->
+    args = unpack arguments
+    [l,a,b] = args
+
+    y = (l + 16) / 116
+    x = if isNaN(a) then y else y + a / 500
+    z = if isNaN(b) then y else y - b / 200
+
+    y = LAB_CONSTANTS.Yn * lab_xyz y
+    x = LAB_CONSTANTS.Xn * lab_xyz x
+    z = LAB_CONSTANTS.Zn * lab_xyz z
+
+    r = xyz_rgb 3.2404542 * x - 1.5371385 * y - 0.4985314 * z  # D65 -> sRGB
+    g = xyz_rgb -0.9692660 * x + 1.8760108 * y + 0.0415560 * z
+    b = xyz_rgb 0.0556434 * x - 0.2040259 * y + 1.0572252 * z
+
+    r = limit r,0,255
+    g = limit g,0,255
+    b = limit b,0,255
+  
+    [r,g,b,if args.length > 3 then args[3] else 1]
+
+
+xyz_rgb = (r) ->
+    round(255 * (if r <= 0.00304 then 12.92 * r else 1.055 * pow(r, 1 / 2.4) - 0.055))
+
+lab_xyz = (t) ->
+    if t > LAB_CONSTANTS.t1 then t * t * t else LAB_CONSTANTS.t2 * (t - LAB_CONSTANTS.t0)
+
diff --git a/src/converter/in/lch2rgb.coffee b/src/converter/in/lch2rgb.coffee
new file mode 100644
index 0000000..2dd68d4
--- /dev/null
+++ b/src/converter/in/lch2rgb.coffee
@@ -0,0 +1,8 @@
+# @requires utils lch2lab
+
+lch2rgb = () ->
+    args = unpack arguments
+    [l,c,h] = args
+    [L,a,b] = lch2lab l,c,h
+    [r,g,b] = lab2rgb L,a,b
+    [limit(r,0,255), limit(g,0,255), limit(b,0,255), if args.length > 3 then args[3] else 1]
diff --git a/src/converter/in/num2rgb.coffee b/src/converter/in/num2rgb.coffee
new file mode 100644
index 0000000..250c5a9
--- /dev/null
+++ b/src/converter/in/num2rgb.coffee
@@ -0,0 +1,10 @@
+# @requires utils
+
+num2rgb = (num) ->
+    if type(num) == "number" && num >= 0 && num <= 0xFFFFFF
+        r = num >> 16
+        g = (num >> 8) & 0xFF
+        b = num & 0xFF
+        return [r,g,b,1]
+    console.warn "unknown num color: "+num
+    [0,0,0,1]
\ No newline at end of file
diff --git a/src/converter/in/temperature2rgb.coffee b/src/converter/in/temperature2rgb.coffee
new file mode 100644
index 0000000..9396de6
--- /dev/null
+++ b/src/converter/in/temperature2rgb.coffee
@@ -0,0 +1,18 @@
+#
+# Based on implementation by Neil Bartlett
+# https://github.com/neilbartlett/color-temperature
+#
+
+# @requires utils
+
+temperature2rgb = (kelvin) ->
+    temp = kelvin / 100
+    if temp < 66
+        r = 255
+        g = -155.25485562709179 - 0.44596950469579133 * (g = temp-2) + 104.49216199393888 * log(g)
+        b = if temp < 20 then 0 else -254.76935184120902 + 0.8274096064007395 * (b = temp-10) + 115.67994401066147 * log(b)
+    else
+        r = 351.97690566805693 + 0.114206453784165 * (r = temp-55) - 40.25366309332127 * log(r)
+        g = 325.4494125711974 + 0.07943456536662342 * (g = temp-50) - 28.0852963507957 * log(g)
+        b = 255
+    clip_rgb [r,g,b]
diff --git a/src/converter/misc/lab-constants.coffee b/src/converter/misc/lab-constants.coffee
new file mode 100644
index 0000000..3f6b33b
--- /dev/null
+++ b/src/converter/misc/lab-constants.coffee
@@ -0,0 +1,16 @@
+
+
+
+LAB_CONSTANTS =
+    # Corresponds roughly to RGB brighter/darker
+    Kn: 18
+
+    # D65 standard referent
+    Xn: 0.950470
+    Yn: 1
+    Zn: 1.088830
+
+    t0: 0.137931034  # 4 / 29
+    t1: 0.206896552  # 6 / 29
+    t2: 0.12841855   # 3 * t1 * t1
+    t3: 0.008856452  # t1 * t1 * t1
diff --git a/src/converter/misc/lab2lch.coffee b/src/converter/misc/lab2lch.coffee
new file mode 100644
index 0000000..2831386
--- /dev/null
+++ b/src/converter/misc/lab2lch.coffee
@@ -0,0 +1,8 @@
+# @requires utils
+
+lab2lch = () ->
+    [l, a, b] = unpack arguments
+    c = sqrt(a * a + b * b)
+    h = (atan2(b, a) * RAD2DEG + 360) % 360
+    h = Number.NaN if round(c*10000) == 0
+    [l, c, h]
diff --git a/src/converter/misc/lch2lab.coffee b/src/converter/misc/lch2lab.coffee
new file mode 100644
index 0000000..f4a0e8a
--- /dev/null
+++ b/src/converter/misc/lch2lab.coffee
@@ -0,0 +1,13 @@
+# @requires utils
+
+lch2lab = () ->
+    ###
+    Convert from a qualitative parameter h and a quantitative parameter l to a 24-bit pixel.
+    These formulas were invented by David Dalrymple to obtain maximum contrast without going
+    out of gamut if the parameters are in the range 0-1.
+
+    A saturation multiplier was added by Gregor Aisch
+    ###
+    [l,c,h] = unpack arguments
+    h = h * DEG2RAD
+    [l, cos(h) * c, sin(h) * c]
diff --git a/src/converter/out/hsl2css.coffee b/src/converter/out/hsl2css.coffee
new file mode 100644
index 0000000..8f63e91
--- /dev/null
+++ b/src/converter/out/hsl2css.coffee
@@ -0,0 +1,11 @@
+# @requires utils
+
+rnd = (a) -> round(a*100)/100
+
+hsl2css = (hsl, alpha) ->
+    mode = if alpha < 1 then 'hsla' else 'hsl'
+    hsl[0] = rnd(hsl[0] || 0)
+    hsl[1] = rnd(hsl[1]*100) + '%'
+    hsl[2] = rnd(hsl[2]*100) + '%'
+    hsl[3] = alpha if mode == 'hsla'
+    mode + '(' + hsl.join(',') + ')'
\ No newline at end of file
diff --git a/src/converter/out/rgb2cmyk.coffee b/src/converter/out/rgb2cmyk.coffee
new file mode 100644
index 0000000..54d56bb
--- /dev/null
+++ b/src/converter/out/rgb2cmyk.coffee
@@ -0,0 +1,12 @@
+
+rgb2cmyk = (mode='rgb') ->
+    [r,g,b] = unpack arguments
+    r = r / 255
+    g = g / 255
+    b = b / 255
+    k = 1 - Math.max(r,Math.max(g,b))
+    f = if k < 1 then 1 / (1-k) else 0
+    c = (1-r-k) * f
+    m = (1-g-k) * f
+    y = (1-b-k) * f
+    [c,m,y,k]
diff --git a/src/converter/out/rgb2css.coffee b/src/converter/out/rgb2css.coffee
new file mode 100644
index 0000000..5775aab
--- /dev/null
+++ b/src/converter/out/rgb2css.coffee
@@ -0,0 +1,10 @@
+# @requires utils
+
+rgb2css = (rgba) ->
+    mode = if rgba[3] < 1 then 'rgba' else 'rgb'
+    if mode == 'rgb'
+        mode+'('+rgba.slice(0,3).map(round).join(',')+')'
+    else if mode == 'rgba'
+        mode+'('+rgba.slice(0,3).map(round).join(',')+','+rgba[3]+')'
+    else
+
diff --git a/src/converter/out/rgb2hex.coffee b/src/converter/out/rgb2hex.coffee
new file mode 100644
index 0000000..159a4da
--- /dev/null
+++ b/src/converter/out/rgb2hex.coffee
@@ -0,0 +1,12 @@
+
+rgb2hex = (channels, mode='rgb') ->
+    [r,g,b,a] = channels
+    u = r << 16 | g << 8 | b
+    str = "000000" + u.toString(16) #.toUpperCase()
+    str = str.substr(str.length - 6)
+    hxa = '0' + round(a * 255).toString(16)
+    hxa = hxa.substr(hxa.length - 2)
+    "#" + switch mode.toLowerCase()
+          when 'rgba' then str + hxa
+          when 'argb' then hxa + str
+          else str
diff --git a/src/converter/out/rgb2hsi.coffee b/src/converter/out/rgb2hsi.coffee
new file mode 100644
index 0000000..8429aae
--- /dev/null
+++ b/src/converter/out/rgb2hsi.coffee
@@ -0,0 +1,26 @@
+# @requires utils
+
+rgb2hsi = () ->
+    ###
+    borrowed from here:
+    http://hummer.stanford.edu/museinfo/doc/examples/humdrum/keyscape2/rgb2hsi.cpp
+    ###
+    [r,g,b] = unpack arguments
+    TWOPI = Math.PI*2
+    r /= 255
+    g /= 255
+    b /= 255
+    min = Math.min(r,g,b)
+    i = (r+g+b) / 3
+    s = 1 - min/i
+    if s == 0
+        h = 0
+    else
+        h = ((r-g)+(r-b)) / 2
+        h /= Math.sqrt((r-g)*(r-g) + (r-b)*(g-b))
+        h = Math.acos(h)
+        if b > g
+            h = TWOPI - h
+        h /= TWOPI
+    [h*360,s,i]
+
diff --git a/src/converter/out/rgb2hsl.coffee b/src/converter/out/rgb2hsl.coffee
new file mode 100644
index 0000000..2b1cfaf
--- /dev/null
+++ b/src/converter/out/rgb2hsl.coffee
@@ -0,0 +1,26 @@
+
+rgb2hsl = (r,g,b) ->
+    if r != undefined and r.length >= 3
+        [r,g,b] = r
+    r /= 255
+    g /= 255
+    b /= 255
+
+    min = Math.min(r, g, b)
+    max = Math.max(r, g, b)
+
+    l = (max + min) / 2
+
+    if max == min
+        s = 0
+        h = Number.NaN
+    else
+        s = if l < 0.5 then (max - min) / (max + min) else (max - min) / (2 - max - min)
+
+    if r == max then h = (g - b) / (max - min)
+    else if (g == max) then h = 2 + (b - r) / (max - min)
+    else if (b == max) then h = 4 + (r - g) / (max - min)
+
+    h *= 60;
+    h += 360 if h < 0
+    [h,s,l]
diff --git a/src/converter/out/rgb2hsv.coffee b/src/converter/out/rgb2hsv.coffee
new file mode 100644
index 0000000..95b9e22
--- /dev/null
+++ b/src/converter/out/rgb2hsv.coffee
@@ -0,0 +1,18 @@
+
+rgb2hsv = () ->
+    [r,g,b] = unpack arguments
+    min = Math.min(r, g, b)
+    max = Math.max(r, g, b)
+    delta = max - min
+    v = max / 255.0
+    if max == 0
+        h = Number.NaN
+        s = 0
+    else
+        s = delta / max
+        if r is max then h = (g - b) / delta
+        if g is max then h = 2+(b - r) / delta
+        if b is max then h = 4+(r - g) / delta
+        h *= 60;
+        if h < 0 then h += 360
+    [h, s, v]
diff --git a/src/converter/out/rgb2lab.coffee b/src/converter/out/rgb2lab.coffee
new file mode 100644
index 0000000..305f031
--- /dev/null
+++ b/src/converter/out/rgb2lab.coffee
@@ -0,0 +1,22 @@
+# @requires utils lab-constants
+
+rgb2lab = () ->
+    [r,g,b] = unpack arguments
+    [x,y,z] = rgb2xyz r,g,b
+    [116 * y - 16, 500 * (x - y), 200 * (y - z)]
+
+rgb_xyz = (r) ->
+    if (r /= 255) <= 0.04045 then r / 12.92 else pow((r + 0.055) / 1.055, 2.4)
+
+xyz_lab = (t) ->
+    if t > LAB_CONSTANTS.t3 then pow(t, 1 / 3) else t / LAB_CONSTANTS.t2 + LAB_CONSTANTS.t0
+
+rgb2xyz = () ->
+    [r,g,b] = unpack arguments
+    r = rgb_xyz r
+    g = rgb_xyz g
+    b = rgb_xyz b
+    x = xyz_lab (0.4124564 * r + 0.3575761 * g + 0.1804375 * b) / LAB_CONSTANTS.Xn
+    y = xyz_lab (0.2126729 * r + 0.7151522 * g + 0.0721750 * b) / LAB_CONSTANTS.Yn
+    z = xyz_lab (0.0193339 * r + 0.1191920 * g + 0.9503041 * b) / LAB_CONSTANTS.Zn
+    [x,y,z]
diff --git a/src/converter/out/rgb2lch.coffee b/src/converter/out/rgb2lch.coffee
new file mode 100644
index 0000000..2cd1d06
--- /dev/null
+++ b/src/converter/out/rgb2lch.coffee
@@ -0,0 +1,6 @@
+# @requires rgb2lab lab2lch
+
+rgb2lch = () ->
+    [r,g,b] = unpack arguments
+    [l,a,b] = rgb2lab r,g,b
+    lab2lch l,a,b
diff --git a/src/converter/out/rgb2luminance.coffee b/src/converter/out/rgb2luminance.coffee
new file mode 100644
index 0000000..e179a0c
--- /dev/null
+++ b/src/converter/out/rgb2luminance.coffee
@@ -0,0 +1,16 @@
+# @requires utils
+
+rgb2luminance = (r,g,b) ->
+    # relative luminance
+    # see http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef
+    [r,g,b] = unpack arguments
+    r = luminance_x r
+    g = luminance_x g
+    b = luminance_x b
+    0.2126 * r + 0.7152 * g + 0.0722 * b
+
+
+luminance_x = (x) ->
+    x /= 255
+    if x <= 0.03928 then x/12.92 else pow((x+0.055)/1.055, 2.4)
+
diff --git a/src/converter/out/rgb2num.coffee b/src/converter/out/rgb2num.coffee
new file mode 100644
index 0000000..62d03ef
--- /dev/null
+++ b/src/converter/out/rgb2num.coffee
@@ -0,0 +1,4 @@
+
+rgb2num = () ->
+    [r,g,b] = unpack arguments
+    (r << 16) + (g << 8) + b
diff --git a/src/converter/out/rgb2temperature.coffee b/src/converter/out/rgb2temperature.coffee
new file mode 100644
index 0000000..a931670
--- /dev/null
+++ b/src/converter/out/rgb2temperature.coffee
@@ -0,0 +1,20 @@
+#
+# Based on implementation by Neil Bartlett
+# https://github.com/neilbartlett/color-temperature
+#
+
+# @requires utils temperature2rgb
+
+rgb2temperature = () ->
+    [r,g,b] = unpack arguments
+    minTemp = 1000
+    maxTemp = 40000
+    eps = 0.4
+    while maxTemp - minTemp > eps
+        temp = (maxTemp + minTemp) * 0.5
+        rgb = temperature2rgb temp
+        if (rgb[2] / rgb[0]) >= (b / r)
+            maxTemp = temp
+        else
+            minTemp = temp
+    round temp
diff --git a/src/generator/bezier.coffee b/src/generator/bezier.coffee
new file mode 100644
index 0000000..668c3b6
--- /dev/null
+++ b/src/generator/bezier.coffee
@@ -0,0 +1,43 @@
+#
+# interpolates between a set of colors uzing a bezier spline
+#
+
+# @requires utils lab
+
+bezier = (colors) ->
+    colors = (chroma(c) for c in colors)
+    if colors.length == 2
+        # linear interpolation
+        [lab0, lab1] = (c.lab() for c in colors)
+        I = (t) ->
+            lab = (lab0[i] + t * (lab1[i] - lab0[i]) for i in [0..2])
+            chroma.lab lab...
+    else if colors.length == 3
+        # quadratic bezier interpolation
+        [lab0, lab1, lab2] = (c.lab() for c in colors)
+        I = (t) ->
+            lab = ((1-t)*(1-t) * lab0[i] + 2 * (1-t) * t * lab1[i] + t * t * lab2[i] for i in [0..2])
+            chroma.lab lab...
+    else if colors.length == 4
+        # cubic bezier interpolation
+        [lab0, lab1, lab2, lab3] = (c.lab() for c in colors)
+        I = (t) ->
+            lab = ((1-t)*(1-t)*(1-t) * lab0[i] + 3 * (1-t) * (1-t) * t * lab1[i] + 3 * (1-t) * t * t * lab2[i] + t*t*t * lab3[i] for i in [0..2])
+            chroma.lab lab...
+    else if colors.length == 5
+        I0 = bezier colors[0..2]
+        I1 = bezier colors[2..4]
+        I = (t) ->
+            if t < 0.5
+                I0 t*2
+            else
+                I1 (t-0.5)*2
+    I
+
+chroma.bezier = (colors) ->
+    f = bezier colors
+    
+    f.scale = () ->
+        chroma.scale f
+    
+    f
\ No newline at end of file
diff --git a/src/generator/cubehelix.coffee b/src/generator/cubehelix.coffee
new file mode 100644
index 0000000..b232e47
--- /dev/null
+++ b/src/generator/cubehelix.coffee
@@ -0,0 +1,94 @@
+###
+    chroma.js
+
+    Copyright (c) 2011-2013, Gregor Aisch
+    All rights reserved.
+
+    Redistribution and use in source and binary forms, with or without
+    modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice, this
+      list of conditions and the following disclaimer.
+
+    * Redistributions in binary form must reproduce the above copyright notice,
+      this list of conditions and the following disclaimer in the documentation
+      and/or other materials provided with the distribution.
+
+    * The name Gregor Aisch may not be used to endorse or promote products
+      derived from this software without specific prior written permission.
+
+    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+    DISCLAIMED. IN NO EVENT SHALL GREGOR AISCH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+    INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+    BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+    DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+    OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+    NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+    EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+    @source: https://github.com/gka/chroma.js
+###
+
+# cubehelix interpolation
+# based on D.A. Green "A colour scheme for the display of astronomical intensity images"
+# http://astron-soc.in/bulletin/11June/289392011.pdf
+
+chroma.cubehelix = (start=300, rotations=-1.5, hue=1, gamma=1, lightness=[0,1]) ->
+    dl = lightness[1] - lightness[0]
+    dh = 0
+
+    f = (fract) ->
+        a = TWOPI * ((start+120)/360 + rotations * fract)
+        l = pow(lightness[0] + dl * fract, gamma)
+        h = if dh != 0 then hue[0] + fract * dh else hue
+        amp = h * l * (1-l) / 2
+        cos_a = cos a
+        sin_a = sin a
+        r = l + amp * (-0.14861 * cos_a + 1.78277* sin_a)
+        g = l + amp * (-0.29227 * cos_a - 0.90649* sin_a)
+        b = l + amp * (+1.97294 * cos_a)
+        chroma clip_rgb [r*255,g*255,b*255]
+    
+    f.start = (s) ->
+        if not s? then return start
+        start = s
+        f
+    
+    f.rotations = (r) ->
+        if not r? then return rotations
+        rotations = r
+        f
+
+    f.gamma = (g) ->
+        if not g? then return gamma
+        gamma = g
+        f
+
+    f.hue = (h) ->
+        if not h? then return hue
+        hue = h
+        if type(hue) == 'array'
+            dh = hue[1] - hue[0]
+            hue = hue[1] if dh == 0
+        else
+            dh = 0
+        f
+
+    f.lightness = (h) ->
+        if not h? then return lightness
+        lightness = h
+        if type(lightness) == 'array'
+            dl = lightness[1] - lightness[0]
+            lightness = lightness[1] if dl == 0
+        else
+            dl = 0
+        f
+    
+    f.scale = () ->
+        chroma.scale f
+
+    f.hue hue
+
+    f
diff --git a/src/generator/random.coffee b/src/generator/random.coffee
new file mode 100644
index 0000000..df92963
--- /dev/null
+++ b/src/generator/random.coffee
@@ -0,0 +1,7 @@
+
+
+chroma.random = ->
+    digits = '0123456789abcdef'
+    code = '#'
+    code += digits.charAt(floor(Math.random() * 16)) for i in [0...6]
+    new Color code
\ No newline at end of file
diff --git a/src/index.coffee b/src/index.coffee
new file mode 100644
index 0000000..2ee21f1
--- /dev/null
+++ b/src/index.coffee
@@ -0,0 +1,34 @@
+
+###
+ at requires
+    
+    color
+
+    colorbrewer
+    w3cx11
+
+    bezier
+    cubehelix
+    random
+
+    rgb hex hsl hsv num
+    css named
+    lch lab
+    cmyk
+    gl
+    luminance
+    temperature
+    contrast
+
+    get set
+
+    darken saturate premultiply blend    
+
+    scale
+    limits
+    
+    interpolate-hsx
+    interpolate-rgb
+    interpolate-num
+    interpolate-lab
+###
\ No newline at end of file
diff --git a/src/interpolator/interpolate-hsx.coffee b/src/interpolator/interpolate-hsx.coffee
new file mode 100644
index 0000000..469b2a0
--- /dev/null
+++ b/src/interpolator/interpolate-hsx.coffee
@@ -0,0 +1,44 @@
+# @requires interpolate hsl hsv hsi lch
+
+interpolate_hsx = (col1, col2, f, m) ->
+    if m == 'hsl'
+        xyz0 = col1.hsl()
+        xyz1 = col2.hsl()
+    else if m == 'hsv'
+        xyz0 = col1.hsv()
+        xyz1 = col2.hsv()
+    else if m == 'hsi'
+        xyz0 = col1.hsi()
+        xyz1 = col2.hsi()
+    else if m == 'lch' or m == 'hcl'
+        m = 'hcl'
+        xyz0 = col1.hcl()
+        xyz1 = col2.hcl()
+
+    if m.substr(0, 1) == 'h'
+        [hue0, sat0, lbv0] = xyz0
+        [hue1, sat1, lbv1] = xyz1
+
+    if not isNaN(hue0) and not isNaN(hue1)
+        if hue1 > hue0 and hue1 - hue0 > 180
+            dh = hue1-(hue0+360)
+        else if hue1 < hue0 and hue0 - hue1 > 180
+            dh = hue1+360-hue0
+        else
+            dh = hue1 - hue0
+        hue = hue0+f*dh
+    else if not isNaN(hue0)
+        hue = hue0
+        sat = sat0 if (lbv1 == 1 or lbv1 == 0) and m != 'hsv'
+    else if not isNaN(hue1)
+        hue = hue1
+        sat = sat1 if (lbv0 == 1 or lbv0 == 0) and m != 'hsv'
+    else
+        hue = Number.NaN
+
+    sat ?= sat0 + f*(sat1 - sat0)
+    lbv = lbv0 + f*(lbv1-lbv0)
+    res = chroma[m](hue, sat, lbv)
+
+    
+_interpolators = _interpolators.concat ([m, interpolate_hsx] for m in ['hsv','hsl','hsi','hcl','lch'])
diff --git a/src/interpolator/interpolate-lab.coffee b/src/interpolator/interpolate-lab.coffee
new file mode 100644
index 0000000..cf761d4
--- /dev/null
+++ b/src/interpolator/interpolate-lab.coffee
@@ -0,0 +1,13 @@
+# @requires interpolate lab
+
+interpolate_lab = (col1, col2, f, m) ->
+	xyz0 = col1.lab()
+	xyz1 = col2.lab()
+	res = new Color(
+	    xyz0[0] + f * (xyz1[0]-xyz0[0]),
+	    xyz0[1] + f * (xyz1[1]-xyz0[1]),
+	    xyz0[2] + f * (xyz1[2]-xyz0[2]),
+	    m
+	)
+
+_interpolators.push ['lab', interpolate_lab]
diff --git a/src/interpolator/interpolate-num.coffee b/src/interpolator/interpolate-num.coffee
new file mode 100644
index 0000000..15e9f85
--- /dev/null
+++ b/src/interpolator/interpolate-num.coffee
@@ -0,0 +1,8 @@
+# @requires interpolate num
+
+interpolate_num = (col1, col2, f, m) ->
+    n1 = col1.num()
+    n2 = col2.num()
+    chroma.num n1 + (n2-n1) * f, 'num'
+
+_interpolators.push ['num', interpolate_num]
diff --git a/src/interpolator/interpolate-rgb.coffee b/src/interpolator/interpolate-rgb.coffee
new file mode 100644
index 0000000..607fa71
--- /dev/null
+++ b/src/interpolator/interpolate-rgb.coffee
@@ -0,0 +1,13 @@
+# @requires interpolate rgb
+
+interpolate_rgb = (col1, col2, f, m) ->
+    xyz0 = col1._rgb
+    xyz1 = col2._rgb
+    new Color(
+        xyz0[0] + f * (xyz1[0]-xyz0[0]),
+        xyz0[1] + f * (xyz1[1]-xyz0[1]),
+        xyz0[2] + f * (xyz1[2]-xyz0[2]),
+        m
+    )
+
+_interpolators.push ['rgb', interpolate_rgb]
diff --git a/src/interpolator/interpolate.coffee b/src/interpolator/interpolate.coffee
new file mode 100644
index 0000000..90c79c2
--- /dev/null
+++ b/src/interpolator/interpolate.coffee
@@ -0,0 +1,35 @@
+###
+ at requires
+    color
+    utils
+###
+
+_interpolators = []
+
+interpolate = (col1, col2, f=0.5, m='rgb') ->
+    ###
+    interpolates between colors
+    f = 0 --> me
+    f = 1 --> col
+    ###
+    col1 = chroma col1 if type(col1) != 'object'
+    col2 = chroma col2 if type(col2) != 'object'
+
+    for interpol in _interpolators
+        if m == interpol[0]
+            res = interpol[1] col1, col2, f, m
+            break
+
+    throw "color mode "+m+" is not supported" if not res?
+
+    # interpolate alpha at last
+    res.alpha col1.alpha() + f * (col2.alpha() - col1.alpha())
+    res
+
+chroma.interpolate = interpolate
+
+Color::interpolate = (col2, f, m) ->
+    interpolate @, col2, f, m
+
+chroma.mix = interpolate
+Color::mix = Color::interpolate
\ No newline at end of file
diff --git a/src/io/cmyk.coffee b/src/io/cmyk.coffee
new file mode 100644
index 0000000..a2baef8
--- /dev/null
+++ b/src/io/cmyk.coffee
@@ -0,0 +1,11 @@
+# @require utils rgb2cmyk cmyk2rgb
+
+_input.cmyk = () ->
+    cmyk2rgb unpack arguments
+
+
+chroma.cmyk = () ->
+    new Color arguments..., 'cmyk'
+
+Color::cmyk = () ->
+    rgb2cmyk @_rgb
\ No newline at end of file
diff --git a/src/io/contrast.coffee b/src/io/contrast.coffee
new file mode 100644
index 0000000..f8c195b
--- /dev/null
+++ b/src/io/contrast.coffee
@@ -0,0 +1,9 @@
+
+chroma.contrast = (a, b) ->
+    # WCAG contrast ratio
+    # see http://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef
+    a = new Color a if type(a) in ['string', 'number']
+    b = new Color b if type(b) in ['string', 'number']
+    l1 = a.luminance()
+    l2 = b.luminance()
+    if l1 > l2 then (l1 + 0.05) / (l2 + 0.05) else (l2 + 0.05) / (l1 + 0.05)
diff --git a/src/io/css.coffee b/src/io/css.coffee
new file mode 100644
index 0000000..8073057
--- /dev/null
+++ b/src/io/css.coffee
@@ -0,0 +1,13 @@
+# @requires utils css2rgb rgb2css hsl2css
+
+_input.css = (h) ->
+    css2rgb h
+
+chroma.css = () ->
+    new Color arguments..., 'css'
+
+Color::css = (mode='rgb') ->
+    if mode[0..2] == 'rgb'
+        rgb2css @_rgb
+    else if mode[0..2] == 'hsl'
+        hsl2css @hsl(), @alpha()
diff --git a/src/io/gl.coffee b/src/io/gl.coffee
new file mode 100644
index 0000000..58e4647
--- /dev/null
+++ b/src/io/gl.coffee
@@ -0,0 +1,14 @@
+# @require utils
+
+_input.gl = () ->
+    rgb = (v for k,v of unpack arguments)
+    for i in [0..2]
+        rgb[i] *= 255
+    rgb
+
+chroma.gl = () ->
+    new Color arguments..., 'gl'
+
+Color::gl = () ->
+    rgb = @_rgb
+    [rgb[0]/255, rgb[1]/255, rgb[2]/255, rgb[3]]
diff --git a/src/io/hex.coffee b/src/io/hex.coffee
new file mode 100644
index 0000000..64a8df0
--- /dev/null
+++ b/src/io/hex.coffee
@@ -0,0 +1,15 @@
+# @require hex2rgb rgb2hex
+
+_input.hex = (h) ->
+    hex2rgb h
+
+chroma.hex = () ->
+    new Color arguments..., 'hex'
+
+Color::hex = (mode='rgb') ->
+    rgb2hex @_rgb, mode
+
+_guess_formats.push
+    p: 10,
+    test: (n) ->
+        'hex' if arguments.length == 1 and type(n) == "string"
\ No newline at end of file
diff --git a/src/io/hsi.coffee b/src/io/hsi.coffee
new file mode 100644
index 0000000..de06a7d
--- /dev/null
+++ b/src/io/hsi.coffee
@@ -0,0 +1,11 @@
+# @require utils hsi2rgb rgb2hsi
+
+chroma.hsi = () ->
+    new Color arguments..., 'hsi'
+
+_input.hsi = hsi2rgb
+
+Color::hsi = () ->
+    rgb2hsi @_rgb
+
+
diff --git a/src/io/hsl.coffee b/src/io/hsl.coffee
new file mode 100644
index 0000000..5807472
--- /dev/null
+++ b/src/io/hsl.coffee
@@ -0,0 +1,11 @@
+# @require utils hsl2rgb rgb2hsl
+
+chroma.hsl = () ->
+    new Color arguments..., 'hsl'
+
+_input.hsl = hsl2rgb
+
+Color::hsl = () ->
+    rgb2hsl @_rgb
+
+
diff --git a/src/io/hsv.coffee b/src/io/hsv.coffee
new file mode 100644
index 0000000..2ce2fc3
--- /dev/null
+++ b/src/io/hsv.coffee
@@ -0,0 +1,9 @@
+# @require utils hsv2rgb rgb2hsv
+
+chroma.hsv = () ->
+    new Color arguments..., 'hsv'
+
+_input.hsv = hsv2rgb
+
+Color::hsv = () ->
+    rgb2hsv @_rgb
\ No newline at end of file
diff --git a/src/io/lab.coffee b/src/io/lab.coffee
new file mode 100644
index 0000000..e9c6a02
--- /dev/null
+++ b/src/io/lab.coffee
@@ -0,0 +1,11 @@
+# @require utils lab2rgb rgb2lab
+
+chroma.lab = () ->
+    new Color arguments..., 'lab'
+
+_input.lab = lab2rgb
+
+Color::lab = () ->
+    rgb2lab @_rgb
+
+
diff --git a/src/io/lch.coffee b/src/io/lch.coffee
new file mode 100644
index 0000000..e6ca385
--- /dev/null
+++ b/src/io/lch.coffee
@@ -0,0 +1,23 @@
+# @require utils lch2rgb rgb2lch
+
+chroma.lch = () ->
+    args = unpack arguments
+    new Color args, 'lch'
+
+chroma.hcl = () ->
+    args = unpack arguments
+    new Color args, 'hcl'
+
+_input.lch = lch2rgb
+
+_input.hcl = () ->
+    [h,c,l] = unpack arguments
+    lch2rgb [l,c,h]
+
+Color::lch = () ->
+    rgb2lch @_rgb
+
+Color::hcl = () ->
+    rgb2lch(@_rgb).reverse()
+
+
diff --git a/src/io/luminance.coffee b/src/io/luminance.coffee
new file mode 100644
index 0000000..2314896
--- /dev/null
+++ b/src/io/luminance.coffee
@@ -0,0 +1,23 @@
+# @requires rgb2luminance interpolate-rgb
+
+Color::luminance = (lum, mode='rgb') ->
+    return rgb2luminance @_rgb if !arguments.length
+    # set luminance
+    if lum == 0 then @_rgb = [0,0,0, at _rgb[3]]
+    else if lum == 1 then @_rgb = [255,255,255, at _rgb[3]]
+    else
+        eps = 1e-7
+        max_iter = 20
+        test = (l,h) ->
+            m = l.interpolate(h, 0.5, mode)
+            lm = m.luminance()
+            if Math.abs(lum - lm) < eps or not max_iter--
+                return m
+            if lm > lum
+                return test(l, m)
+            return test(m, h)
+
+        cur_lum = rgb2luminance @_rgb
+        @_rgb = (if cur_lum > lum then test(chroma('black'), @) else test(@, chroma('white'))).rgba()
+
+    @
diff --git a/src/io/named.coffee b/src/io/named.coffee
new file mode 100644
index 0000000..56ff4f3
--- /dev/null
+++ b/src/io/named.coffee
@@ -0,0 +1,23 @@
+#
+# @requires hex hex2rgb w3cx11
+#
+
+_input.named = (name) ->
+    hex2rgb w3cx11[name]
+
+_guess_formats.push
+    p: 20,
+    test: (n) ->
+        'named' if arguments.length == 1 and w3cx11[n]?
+
+Color::name = (n) ->
+    if arguments.length
+        @_rgb = hex2rgb w3cx11[n] if w3cx11[n]
+        @_rgb[3] = 1
+        @
+    # resolve name from hex
+    h = @hex()
+    for k of w3cx11
+        if h == w3cx11[k]
+            return k
+    h
diff --git a/src/io/num.coffee b/src/io/num.coffee
new file mode 100644
index 0000000..fbcaafa
--- /dev/null
+++ b/src/io/num.coffee
@@ -0,0 +1,14 @@
+# @require utils num2rgb rgb2num
+
+chroma.num = (num) ->
+    new Color num, 'num'
+
+Color::num = (mode='rgb') ->
+    rgb2num @_rgb, mode
+
+_input.num = num2rgb
+
+_guess_formats.push
+    p: 10,
+    test: (n) ->
+        'num' if arguments.length == 1 and type(n) == "number" and n >= 0 and n <= 0xFFFFFF
\ No newline at end of file
diff --git a/src/io/rgb.coffee b/src/io/rgb.coffee
new file mode 100644
index 0000000..52957ec
--- /dev/null
+++ b/src/io/rgb.coffee
@@ -0,0 +1,20 @@
+# @require utils
+
+_input.rgb = () ->
+    (v for k,v of unpack arguments)
+
+chroma.rgb = () ->
+    new Color arguments..., 'rgb'
+
+Color::rgb = ->
+    @_rgb.slice 0,3
+
+Color::rgba = ->
+    @_rgb
+
+_guess_formats.push
+    p: 15
+    test: (n) ->
+        a = unpack arguments
+        return 'rgb' if type(a) == 'array' and a.length == 3
+        return 'rgb' if a.length == 4 and type(a[3]) == "number" and a[3] >= 0 and a[3] <= 1
diff --git a/src/io/temperature.coffee b/src/io/temperature.coffee
new file mode 100644
index 0000000..69f5758
--- /dev/null
+++ b/src/io/temperature.coffee
@@ -0,0 +1,12 @@
+
+# @requires utils rgb2temperature temperature2rgb
+
+chroma.temperature = chroma.kelvin = () ->
+    new Color arguments..., 'temperature'
+
+_input.temperature = _input.kelvin = _input.K = temperature2rgb
+
+Color::temperature = () ->
+    rgb2temperature @_rgb
+
+Color::kelvin = Color::temperature
diff --git a/src/limits.coffee b/src/limits.coffee
new file mode 100644
index 0000000..c05e308
--- /dev/null
+++ b/src/limits.coffee
@@ -0,0 +1,169 @@
+
+
+chroma.analyze = (data, key, filter) ->
+    r =
+        min: Number.MAX_VALUE
+        max: Number.MAX_VALUE*-1
+        sum: 0
+        values: []
+        count: 0
+
+    if not filter?
+        filter = ->
+            true
+
+    add = (val) ->
+        if val? and not isNaN val
+            r.values.push val
+            r.sum += val
+            r.min = val if val < r.min
+            r.max = val if val > r.max
+            r.count += 1
+        return
+
+    visit = (val, k) ->
+        if filter val, k
+            if key? and type(key) == 'function'
+                add key val
+            else if key? and type(key) == 'string' or type(key) == 'number'
+                add val[key]
+            else
+                add val
+
+    if type(data) == 'array'
+        for val in data
+            visit val
+    else
+        for k, val of data
+            visit val, k
+    r.domain = [r.min, r.max]
+    r.limits = (mode, num) ->
+        chroma.limits r, mode, num
+    r
+
+
+
+chroma.limits = (data, mode='equal', num=7) ->
+    if type(data) == 'array'
+        data = chroma.analyze data
+    min = data.min
+    max = data.max
+    sum = data.sum
+    values = data.values.sort (a,b)->
+        a-b
+
+    limits = []
+
+    if mode.substr(0,1) == 'c' # continuous
+        limits.push min
+        limits.push max
+
+    if mode.substr(0,1) == 'e' # equal interval
+        limits.push min
+        for i in [1..num-1]
+            limits.push min+(i/num)*(max-min)
+        limits.push max
+
+    else if mode.substr(0,1) == 'l' # log scale
+        if min <= 0
+            throw 'Logarithmic scales are only possible for values > 0'
+        min_log = Math.LOG10E * log min
+        max_log = Math.LOG10E * log max
+        limits.push min
+        for i in [1..num-1]
+            limits.push pow 10, min_log + (i/num) * (max_log - min_log)
+        limits.push max
+
+    else if mode.substr(0,1) == 'q' # quantile scale
+        limits.push min
+        for i in [1..num-1]
+            p = values.length * i/num
+            pb = floor p
+            if pb == p
+                limits.push values[pb]
+            else # p > pb
+                pr = p - pb
+                limits.push values[pb]*pr + values[pb+1]*(1-pr)
+        limits.push max
+
+    else if mode.substr(0,1) == 'k' # k-means clustering
+        ###
+        implementation based on
+        http://code.google.com/p/figue/source/browse/trunk/figue.js#336
+        simplified for 1-d input values
+        ###
+        n = values.length
+        assignments = new Array n
+        clusterSizes = new Array num
+        repeat = true
+        nb_iters = 0
+        centroids = null
+
+        # get seed values
+        centroids = []
+        centroids.push min
+        for i in [1..num-1]
+            centroids.push min + (i/num) * (max-min)
+        centroids.push max
+
+        while repeat
+            # assignment step
+            for j in [0..num-1]
+                clusterSizes[j] = 0
+            for i in [0..n-1]
+                value = values[i]
+                mindist = Number.MAX_VALUE
+                for j in [0..num-1]
+                    dist = abs centroids[j]-value
+                    if dist < mindist
+                        mindist = dist
+                        best = j
+                clusterSizes[best]++
+                assignments[i] = best
+
+            # update centroids step
+            newCentroids = new Array num
+            for j in [0..num-1]
+                newCentroids[j] = null
+            for i in [0..n-1]
+                cluster = assignments[i]
+                if newCentroids[cluster] == null
+                    newCentroids[cluster] = values[i]
+                else
+                    newCentroids[cluster] += values[i]
+            for j in [0..num-1]
+                newCentroids[j] *= 1/clusterSizes[j]
+
+            # check convergence
+            repeat = false
+            for j in [0..num-1]
+                if newCentroids[j] != centroids[i]
+                    repeat = true
+                    break
+
+            centroids = newCentroids
+            nb_iters++
+
+            if nb_iters > 200
+                repeat = false
+
+        # finished k-means clustering
+        # the next part is borrowed from gabrielflor.it
+        kClusters = {}
+        for j in [0..num-1]
+            kClusters[j] = []
+        for i in [0..n-1]
+            cluster = assignments[i]
+            kClusters[cluster].push values[i]
+        tmpKMeansBreaks = []
+        for j in [0..num-1]
+            tmpKMeansBreaks.push kClusters[j][0]
+            tmpKMeansBreaks.push kClusters[j][kClusters[j].length-1]
+        tmpKMeansBreaks = tmpKMeansBreaks.sort (a,b)->
+            a-b
+        limits.push tmpKMeansBreaks[0]
+        for i in [1..tmpKMeansBreaks.length-1] by 2
+            if not isNaN(tmpKMeansBreaks[i])
+                limits.push tmpKMeansBreaks[i]
+    limits
+
diff --git a/src/ops/blend.coffee b/src/ops/blend.coffee
new file mode 100644
index 0000000..d3b12be
--- /dev/null
+++ b/src/ops/blend.coffee
@@ -0,0 +1,68 @@
+#
+# interpolates between a set of colors uzing a bezier spline
+# blend mode formulas taken from http://www.venture-ware.com/kevin/coding/lets-learn-math-photoshop-blend-modes/
+#
+
+# @require utils color
+
+blend = (bottom, top, mode) ->
+    if !blend[mode]
+        throw 'unknown blend mode ' + mode
+    blend[mode](bottom, top)
+
+blend_f = (f) ->
+    (bottom,top) ->
+        c0 = chroma(top).rgb()
+        c1 = chroma(bottom).rgb()
+        chroma(f(c0,c1), 'rgb')
+
+each = (f) ->
+    (c0, c1) ->
+        out = []
+        for i in [0..3]
+            out[i] = f(c0[i], c1[i])
+        out
+
+normal = (a,b) ->
+    a
+
+multiply = (a,b) ->
+    a * b / 255
+
+darken = (a,b) ->
+    if a > b then b else a
+
+lighten = (a,b) ->
+    if a > b then a else b
+
+screen = (a,b) ->
+    255 * (1 - (1-a/255) * (1-b/255))
+
+overlay = (a,b) ->
+    if b < 128
+        2 * a * b / 255
+    else
+        255 * (1 - 2 * (1 - a / 255 ) * ( 1 - b / 255 ))
+
+burn = (a,b) ->
+    255 * (1 - (1 - b / 255) / (a/255))
+
+dodge = (a,b) ->
+    return 255 if a == 255
+    a = 255 * (b / 255) / (1 - a / 255)
+    if a > 255 then 255 else a
+
+# add = (a,b) ->
+#     if (a + b > 255) then 255 else a + b
+
+blend.normal = blend_f each normal
+blend.multiply = blend_f each multiply
+blend.screen = blend_f each screen
+blend.overlay = blend_f each overlay
+blend.darken = blend_f each darken
+blend.lighten = blend_f each lighten
+blend.dodge = blend_f each dodge
+blend.burn = blend_f each burn
+# blend.add = blend_f each add
+
+chroma.blend = blend
\ No newline at end of file
diff --git a/src/ops/darken.coffee b/src/ops/darken.coffee
new file mode 100644
index 0000000..297967c
--- /dev/null
+++ b/src/ops/darken.coffee
@@ -0,0 +1,13 @@
+# @requires color lab lab-constants
+
+Color::darken = (amount=1) ->
+    me = @
+    lab = me.lab()
+    lab[0] -= LAB_CONSTANTS.Kn * amount
+    chroma.lab(lab).alpha(me.alpha())
+
+Color::brighten = (amount=1) ->
+    @darken -amount
+
+Color::darker = Color::darken
+Color::brighter = Color::brighten
diff --git a/src/ops/get.coffee b/src/ops/get.coffee
new file mode 100644
index 0000000..27d54eb
--- /dev/null
+++ b/src/ops/get.coffee
@@ -0,0 +1,14 @@
+
+Color::get = (modechan) ->
+    me = @
+    [mode,channel] = modechan.split '.'
+    src = me[mode]()
+    if channel
+        i = mode.indexOf channel
+        if i > -1
+            return src[i]
+        else
+            console.warn 'unknown channel '+channel+' in mode '+mode
+    else
+        return src
+
diff --git a/src/ops/premultiply.coffee b/src/ops/premultiply.coffee
new file mode 100644
index 0000000..cd22587
--- /dev/null
+++ b/src/ops/premultiply.coffee
@@ -0,0 +1,6 @@
+# @requires color rgb
+
+Color::premultiply = ->
+    rgb = @rgb()
+    a = @alpha()
+    chroma(rgb[0]*a, rgb[1]*a, rgb[2]*a, a)
diff --git a/src/ops/saturate.coffee b/src/ops/saturate.coffee
new file mode 100644
index 0000000..406bfbe
--- /dev/null
+++ b/src/ops/saturate.coffee
@@ -0,0 +1,11 @@
+# requrie lab-constants lch
+
+Color::saturate = (amount=1) ->
+    me = @
+    lch = me.lch()
+    lch[1] += amount * LAB_CONSTANTS.Kn
+    lch[1] = 0 if lch[1] < 0 
+    chroma.lch(lch).alpha(me.alpha())
+
+Color::desaturate = (amount=1) ->
+	@saturate -amount
\ No newline at end of file
diff --git a/src/ops/set.coffee b/src/ops/set.coffee
new file mode 100644
index 0000000..dd01d8e
--- /dev/null
+++ b/src/ops/set.coffee
@@ -0,0 +1,24 @@
+
+Color::set = (modechan, value) ->
+    me = @
+    [mode,channel] = modechan.split '.'
+    if channel
+        src = me[mode]()
+        i = mode.indexOf channel
+        if i > -1
+            if type(value) == 'string'
+                switch value.charAt(0)
+                    when '+' then src[i] += +value
+                    when '-' then src[i] += +value
+                    when '*' then src[i] *= +(value.substr(1))
+                    when '/' then src[i] /= +(value.substr(1))
+                    else src[i] = +value
+            else
+                src[i] = value
+        else
+            console.warn 'unknown channel '+channel+' in mode '+mode
+    else
+        src = value
+    me._rgb = chroma(src, mode).alpha(me.alpha())._rgb
+    me
+
diff --git a/src/scale.coffee b/src/scale.coffee
new file mode 100644
index 0000000..2bd0f97
--- /dev/null
+++ b/src/scale.coffee
@@ -0,0 +1,249 @@
+
+# minimal multi-purpose interface
+
+# @requires utils color analyze
+
+chroma.scale = (colors, positions) ->
+
+    # constructor
+    _mode = 'rgb'
+    _nacol = chroma '#ccc'
+    _spread = 0
+    _fixed = false
+    _domain = [0, 1]
+    _pos = []
+    _padding = [0,0]
+    _classes = false
+    _colors = []
+    _out = false
+    _min = 0
+    _max = 1
+    _correctLightness = false
+    _colorCache = {}
+
+    # private methods
+
+    setColors = (colors) ->
+        if not colors?
+            colors = ['#fff', '#000']
+        if colors? and type(colors) == 'string' and chroma.brewer?[colors]?
+            colors = chroma.brewer[colors]
+        if type(colors) == 'array'
+            # make a copy of the colors
+            colors = colors.slice(0)
+            # convert to chroma classes
+            for c in [0..colors.length-1]
+                col = colors[c]
+                colors[c] = chroma(col) if type(col) == "string"
+            # auto-fill color position
+            _pos.length = 0
+            for c in [0..colors.length-1]
+                _pos.push c/(colors.length-1)
+        resetCache()
+        _colors = colors
+
+    getClass = (value) ->
+        if _classes?
+            n = _classes.length-1
+            i = 0
+            while i < n and value >= _classes[i]
+                i++
+            return i-1
+        return 0
+
+    tmap = (t) -> t
+
+    classifyValue = (value) ->
+        val = value
+        if _classes.length > 2
+            n = _classes.length-1
+            i = getClass(value)
+            minc = _classes[0] + (_classes[1]-_classes[0]) * (0 + _spread * 0.5)  # center of 1st class
+            maxc = _classes[n-1] + (_classes[n]-_classes[n-1]) * (1 - _spread * 0.5)  # center of last class
+            val = _min + ((_classes[i] + (_classes[i+1] - _classes[i]) * 0.5 - minc) / (maxc-minc)) * (_max - _min)
+        val
+
+    getColor = (val, bypassMap=false) ->
+        if isNaN(val) then return _nacol
+        if not bypassMap
+            if _classes and _classes.length > 2
+                # find the class
+                c = getClass val
+                t = c / (_classes.length-2)
+                t = _padding[0] + (t * (1 - _padding[0] - _padding[1]))
+            else if _max != _min
+                # just interpolate between min/max
+                t = (val - _min) / (_max - _min)
+                t = _padding[0] + (t * (1 - _padding[0] - _padding[1]))
+                t = Math.min(1, Math.max(0, t))
+            else
+                t = 1
+        else
+            t = val
+
+        if not bypassMap
+            t = tmap t  # lightness correction
+
+        k = Math.floor(t * 10000)
+
+        if _colorCache[k]
+            col = _colorCache[k]
+        else
+            if type(_colors) == 'array'
+                for i in [0.._pos.length-1]
+                    p = _pos[i]
+                    if t <= p
+                        col = _colors[i]
+                        break
+                    if t >= p and i == _pos.length-1
+                        col = _colors[i]
+                        break
+                    if t > p and t < _pos[i+1]
+                        t = (t-p)/(_pos[i+1]-p)
+                        col = chroma.interpolate _colors[i], _colors[i+1], t, _mode
+                        break
+            else if type(_colors) == 'function'
+                col = _colors t
+            _colorCache[k] = col
+        col
+
+    resetCache = () ->
+        _colorCache = {}
+
+    setColors colors
+
+    # public interface
+
+    f = (v) ->
+        c = chroma getColor v
+        if _out and c[_out] then c[_out]() else c
+
+    f.classes = (classes) ->
+        if classes?
+            if type(classes) == 'array'
+                _classes = classes
+                _domain = [classes[0], classes[classes.length-1]]
+            else
+                d = chroma.analyze _domain
+                if classes == 0
+                    _classes = [d.min, d.max]
+                else
+                    _classes = chroma.limits d, 'e', classes
+            return f
+        _classes
+
+
+    f.domain = (domain) ->
+        if not arguments.length
+            return _domain
+        _min = domain[0]
+        _max = domain[domain.length-1]
+        _pos = []
+        k = _colors.length
+        if domain.length == k and _min != _max
+            # update positions
+            for d in domain
+                _pos.push (d-_min) / (_max-_min)
+        else
+            for c in [0..k-1]
+                _pos.push c/(k-1)
+        _domain = [_min, _max]
+        f
+
+    f.mode = (_m) ->
+        if not arguments.length
+            return _mode
+        _mode = _m
+        resetCache()
+        f
+
+    f.range = (colors, _pos) ->
+        setColors colors, _pos
+        f
+
+    f.out = (_o) ->
+        _out = _o
+        f
+
+    f.spread = (val) ->
+        if not arguments.length
+            return _spread
+        _spread = val
+        f
+
+    f.correctLightness = (v=true) ->
+        _correctLightness = v
+        resetCache()
+        if _correctLightness
+            tmap = (t) ->
+                L0 = getColor(0, true).lab()[0]
+                L1 = getColor(1, true).lab()[0]
+                pol = L0 > L1
+                L_actual = getColor(t, true).lab()[0]
+                L_ideal = L0 + (L1 - L0) * t
+                L_diff = L_actual - L_ideal
+                t0 = 0
+                t1 = 1
+                max_iter = 20
+                while Math.abs(L_diff) > 1e-2 and max_iter-- > 0
+                    do () ->
+                        L_diff *= -1 if pol
+                        if L_diff < 0
+                            t0 = t
+                            t += (t1 - t) * 0.5
+                        else
+                            t1 = t
+                            t += (t0 - t) * 0.5
+                        L_actual = getColor(t, true).lab()[0]
+                        L_diff = L_actual - L_ideal
+                t
+        else
+            tmap = (t) -> t
+        f
+
+    f.padding = (p) ->
+        if p?
+            if type(p) == 'number'
+                p = [p,p]
+            _padding = p
+            f
+        else
+            _padding
+
+    f.colors = () ->
+        numColors = 0
+        out = 'hex'
+        if arguments.length == 1
+            if type(arguments[0]) == 'string'
+                out = arguments[0]
+            else
+                numColors = arguments[0]
+        if arguments.length == 2
+            [numColors, out] = arguments
+        
+        if numColors
+            dm = _domain[0]
+            dd = _domain[1] - dm
+            return [0...numColors].map (i) -> f( dm + i/(numColors-1) * dd )[out]()
+        
+        # returns all colors based on the defined classes
+        colors = []
+        samples = []
+        if _classes and _classes.length > 2
+            for i in [1..._classes.length]
+                samples.push (_classes[i-1]+_classes[i])*0.5
+        else
+            samples = _domain
+        samples.map (v) -> f(v)[out]()
+
+    f
+
+# some pre-defined color scales:
+chroma.scales ?= {}
+
+chroma.scales.cool = ->
+    chroma.scale [chroma.hsl(180,1,.9), chroma.hsl(250,.7,.4)]
+
+chroma.scales.hot = ->
+    chroma.scale(['#000','#f00','#ff0','#fff'], [0,.25,.75,1]).mode('rgb')
+
diff --git a/src/utils.coffee b/src/utils.coffee
new file mode 100644
index 0000000..2c12f28
--- /dev/null
+++ b/src/utils.coffee
@@ -0,0 +1,41 @@
+
+type = do ->
+    ###
+    for browser-safe type checking+
+    ported from jQuery's $.type
+    ###
+    classToType = {}
+    for name in "Boolean Number String Function Array Date RegExp Undefined Null".split(" ")
+        classToType["[object " + name + "]"] = name.toLowerCase()
+
+    (obj) ->
+        strType = Object::toString.call(obj)
+        classToType[strType] or "object"
+
+
+limit = (x, min=0, max=1) ->
+    x = min if x < min
+    x = max if x > max
+    x
+
+unpack = (args) ->
+    if args.length >= 3
+        [].slice.call args
+    else
+        args[0]
+
+clip_rgb = (rgb) ->
+    for i of rgb
+        if i < 3
+            rgb[i] = 0 if rgb[i] < 0
+            rgb[i] = 255 if rgb[i] > 255
+        else if i == 3
+            rgb[i] = 0 if rgb[i] < 0
+            rgb[i] = 1 if rgb[i] > 1
+    rgb
+
+{PI, round, cos, floor, pow, log, sin, sqrt, atan2, max, abs} = Math
+TWOPI = PI*2
+PITHIRD = PI/3
+DEG2RAD = PI / 180
+RAD2DEG = 180 / PI
diff --git a/test/alpha-test.coffee b/test/alpha-test.coffee
new file mode 100644
index 0000000..b6ce5a5
--- /dev/null
+++ b/test/alpha-test.coffee
@@ -0,0 +1,112 @@
+require 'es6-shim'
+vows = require 'vows'
+assert = require 'assert'
+chroma = require '../chroma'
+
+
+vows
+    .describe('Tests for the alpha channel')
+
+    .addBatch
+
+        'setting & getting alpha channel':
+            topic: chroma 'red'
+            'default alpha is 1': (topic) -> assert.equal topic.alpha(), 1
+            'setting alpha to 0.5': (topic) -> assert.equal topic.alpha(0.5), topic
+            'alpha is now 0.5': (topic) -> assert.equal topic.alpha(), 0.5
+
+        'interpolating alpha channel':
+            topic: chroma.mix chroma('white').alpha(0), chroma('black').alpha(1), 0.3
+            'color is grey': (topic) -> assert.equal topic.hex(), '#b2b2b2'
+            'alpha is 50%': (topic) -> assert.equal topic.alpha(), 0.3
+
+        'constructing rgba color':
+            topic: new chroma 255,0,0,0.5,'rgb'
+            'alpha is 50%': (topic) -> assert.equal topic.alpha(), 0.5
+
+        'constructing rgba color, rgb shorthand':
+            topic: chroma.rgb(255,0,0,0.5)
+            'alpha is 50%': (topic) -> assert.equal topic.alpha(), 0.5
+
+        'constructing rgba color, hsl shorthand':
+            topic: chroma.hsl(0,1,0.5).alpha(0.5)
+            'color is red': (topic) -> assert.equal topic.name(), 'red'
+            'alpha is 50%': (topic) -> assert.equal topic.alpha(), 0.5
+
+        'parsing hex rgba colors':
+            topic: chroma '#ff00004d'
+            'color is red': (topic) -> assert.equal topic.name(), 'red'
+            'alpha is 30%': (topic) -> assert.equal topic.alpha(), 0.3
+            'rgba output': (topic) -> assert.deepEqual topic.rgba(), [255,0,0,0.3]
+
+        'parsing rgba colors':
+            topic: chroma.css 'rgba(255,0,0,.3)'
+            'color is red': (topic) -> assert.equal topic.name(), 'red'
+            'alpha is 30%': (topic) -> assert.equal topic.alpha(), 0.3
+            'rgba output': (topic) -> assert.deepEqual topic.rgba(), [255,0,0,0.3]
+
+        'parsing rgba colors (percentage)':
+            topic: chroma.css 'rgba(100%,0%,0%,0.2)'
+            'color is red': (topic) -> assert.equal topic.name(), 'red'
+            'alpha is 20%': (topic) -> assert.equal topic.alpha(), 0.2
+            'rgb output': (topic) -> assert.deepEqual topic.rgb(), [255,0,0]
+            'rgba output': (topic) -> assert.deepEqual topic.rgba(), [255,0,0,0.2]
+
+        'parsing hsla colors':
+            topic: chroma.css 'hsla(0,100%,50%,0.25)'
+            'color is red': (topic) -> assert.equal topic.name(), 'red'
+            'alpha is 25%': (topic) -> assert.equal topic.alpha(), 0.25
+            'rgb output': (topic) -> assert.deepEqual topic.rgb(), [255,0,0]
+            'rgba output': (topic) -> assert.deepEqual topic.rgba(), [255,0,0,0.25]
+
+        'constructing hsla color':
+            topic: chroma 0,1,0.5,0.25,'hsl'
+            'color is red': (topic) -> assert.equal topic.name(), 'red'
+            'alpha is 25%': (topic) -> assert.equal topic.alpha(), 0.25            
+
+        'constructing hsva color':
+            topic: chroma 0,1,1,0.25,'hsv'
+            'color is red': (topic) -> assert.equal topic.name(), 'red'
+            'alpha is 25%': (topic) -> assert.equal topic.alpha(), 0.25            
+
+        'constructing hsia color':
+            topic: chroma 0,1,0.3333334,0.25,'hsi'
+            'color is red': (topic) -> assert.equal topic.name(), 'red'
+            'alpha is 25%': (topic) -> assert.equal topic.alpha(), 0.25            
+
+        'constructing laba color':
+            topic: chroma 53.24079414130722, 80.09245959641109, 67.20319651585301,0.25,'lab'
+            'color is red': (topic) -> assert.equal topic.name(), 'red'
+            'alpha is 25%': (topic) -> assert.equal topic.alpha(), 0.25            
+
+        'constructing lcha color':
+            topic: chroma 53.24079414130722, 104.55176567686985, 39.99901061253297,0.25,'lch'
+            'color is red': (topic) -> assert.equal topic.name(), 'red'
+            'alpha is 25%': (topic) -> assert.equal topic.alpha(), 0.25            
+
+        'constructing cmyka color':
+            topic: chroma 0,1,1,0,0.25,'cmyk'
+            'color is red': (topic) -> assert.equal topic.name(), 'red'
+            'alpha is 25%': (topic) -> assert.equal topic.alpha(), 0.25            
+
+        'gl output':
+            topic: chroma.gl 1, 0, 0, 0.25
+            'color is red': (topic) -> assert.equal topic.name(), 'red'
+            'alpha is 25%': (topic) -> assert.equal topic.alpha(), 0.25            
+            'gloutput': (topic) -> assert.deepEqual topic.gl(), [1, 0, 0, 0.25]
+
+        'rgba css output':
+            topic: chroma.css 'hsla(0,100%,50%,0.25)'
+            'cssoutput': -> (topic) -> assert.equal topic.css(), 'rgba(255,0,0,0.25)'
+
+        'hex output':
+            topic: chroma.gl 1, 0, 0, 0.25
+            'hex': (topic) -> assert.equal topic.hex(), '#ff0000'
+            'rgba': (topic) -> assert.equal topic.hex('rgba'), '#ff000040'
+            'argb': (topic) -> assert.equal topic.hex('argb'), '#40ff0000'
+
+        'num output':
+            topic: chroma.gl 1, 0, 0, 0.25
+            'num ignores alpha': (topic) -> assert.equal topic.num(), 0xff0000
+
+    .export(module)
diff --git a/test/analyze-test.coffee b/test/analyze-test.coffee
new file mode 100644
index 0000000..7263cb9
--- /dev/null
+++ b/test/analyze-test.coffee
@@ -0,0 +1,42 @@
+require 'es6-shim'
+vows = require 'vows'
+assert = require 'assert'
+chroma = require '../chroma'
+
+vows
+    .describe('Some tests for chroma.analyze()')
+
+    .addBatch
+        'analyze an array of numbers':
+            topic: chroma.analyze [1,2,2,3,4,5]
+            'sum is 17': (topic) -> assert.equal topic.sum, 17
+            'count is 6': (topic) -> assert.equal topic.count, 6
+            'maximum is 5': (topic) -> assert.equal topic.max, 5
+            'minumum is 1': (topic) -> assert.equal topic.min, 1
+            'domain is [1,5]': (topic) -> assert.deepEqual topic.domain, [1,5]
+
+        'analyze an object of numbers':
+            topic: chroma.analyze {a: 1, b: 2, c: 2, d: 3, e: 4, f: 5}
+            'sum is 17': (topic) -> assert.equal topic.sum, 17
+            'count is 6': (topic) -> assert.equal topic.count, 6
+            'maximum is 5': (topic) -> assert.equal topic.max, 5
+            'minumum is 1': (topic) -> assert.equal topic.min, 1
+            'domain is [1,5]': (topic) -> assert.deepEqual topic.domain, [1,5]
+
+        'analyze an array of objects':
+            topic: chroma.analyze [{ k: 1 }, { k: 2 }, { k: 2 }, { k: 3 }, { k: 4 }, { k: 5 }], 'k'
+            'sum is 17': (topic) -> assert.equal topic.sum, 17
+            'count is 6': (topic) -> assert.equal topic.count, 6
+            'maximum is 5': (topic) -> assert.equal topic.max, 5
+            'minumum is 1': (topic) -> assert.equal topic.min, 1
+            'domain is [1,5]': (topic) -> assert.deepEqual topic.domain, [1,5]
+
+        'analyze an object of objects':
+            topic: chroma.analyze { a: { k: 1 }, b: { k: 2 }, c: { k: 2 }, d: { k: 3 }, e: { k: 4 }, f: { k: 5 }}, 'k'
+            'sum is 17': (topic) -> assert.equal topic.sum, 17
+            'count is 6': (topic) -> assert.equal topic.count, 6
+            'maximum is 5': (topic) -> assert.equal topic.max, 5
+            'minumum is 1': (topic) -> assert.equal topic.min, 1
+            'domain is [1,5]': (topic) -> assert.deepEqual topic.domain, [1,5]
+
+    .export(module)
\ No newline at end of file
diff --git a/test/bezier-test.coffee b/test/bezier-test.coffee
new file mode 100644
index 0000000..6f06ee1
--- /dev/null
+++ b/test/bezier-test.coffee
@@ -0,0 +1,54 @@
+require 'es6-shim'
+vows = require 'vows'
+assert = require 'assert'
+chroma = require '../chroma'
+
+
+vows
+    .describe('Testing bezier interpolation')
+
+    .addBatch
+
+        'simple two color linear interpolation':
+            topic:
+                f: chroma.bezier ['white', 'black']
+            'starts from white': (topic) -> assert.equal topic.f(0).hex(), '#ffffff'
+            'ends in black': (topic) -> assert.equal topic.f(1).hex(), '#000000'
+            'center is grey': (topic) -> assert.equal topic.f(0.5).hex(), '#777777'
+
+        'three color quadratic bezier interpolation':
+            topic:
+                f: chroma.bezier ['white', 'red', 'black']
+            'starts from white': (topic) -> assert.equal topic.f(0).hex(), '#ffffff'
+            'ends in black': (topic) -> assert.equal topic.f(1).hex(), '#000000'
+            'center is a greyish red': (topic) -> assert.equal topic.f(0.5).hex(), '#c45c44'
+
+        'four color cubic bezier interpolation':
+            topic:
+                f: chroma.bezier ['white', 'yellow', 'red', 'black']
+            'starts from white': (topic) -> assert.equal topic.f(0).hex(), '#ffffff'
+            'ends in black': (topic) -> assert.equal topic.f(1).hex(), '#000000'
+            '1st quarter': (topic) -> assert.equal topic.f(0.25).hex(), '#ffe085'
+            'center': (topic) -> assert.equal topic.f(0.5).hex(), '#e69735'
+            '3rd quarter': (topic) -> assert.equal topic.f(0.75).hex(), '#914213'
+
+        'five color diverging quadratic bezier interpolation':
+            topic:
+                f: chroma.bezier ['darkred', 'orange', 'snow', 'lightgreen', 'royalblue']
+            'starts from darkred': (topic) -> assert.equal topic.f(0).hex(), '#8b0000'
+            'ends in royalblue': (topic) -> assert.equal topic.f(1).hex(), '#4169e1'
+            'center is snow': (topic) -> assert.equal topic.f(0.5).hex(), '#fffafa'
+            '1st quarter': (topic) -> assert.equal topic.f(0.25).hex(), '#e9954e'
+            '3rd quarter': (topic) -> assert.equal topic.f(0.75).hex(), '#a6cfc1'
+
+        'using bezier in a chroma.scale':
+            topic:
+                f: chroma.scale(chroma.bezier(['darkred', 'orange', 'snow', 'lightgreen', 'royalblue'])).domain([0,1],5).out('hex')
+            'starts from darkred': (topic) -> assert.equal topic.f(0), '#8b0000'
+            'ends in royalblue': (topic) -> assert.equal topic.f(1), '#4169e1'
+            'center is snow': (topic) -> assert.equal topic.f(0.5), '#fffafa'
+            '1st quarter': (topic) -> assert.equal topic.f(0.25), '#e9954e'
+            '3rd quarter': (topic) -> assert.equal topic.f(0.75), '#a6cfc1'
+
+
+    .export(module)
\ No newline at end of file
diff --git a/test/blend-test.coffee b/test/blend-test.coffee
new file mode 100644
index 0000000..1f1a30b
--- /dev/null
+++ b/test/blend-test.coffee
@@ -0,0 +1,25 @@
+require 'es6-shim'
+vows = require 'vows'
+assert = require 'assert'
+chroma = require '../chroma'
+
+vows
+    .describe('Testing blend modes')
+    .addBatch
+        'multiply 1':
+            topic: chroma.blend 'red', '#5a9f37', 'multiply'
+            'is #5a0000': (topic) -> assert.equal topic.hex(), '#5a0000'
+
+        'multiply 2':
+            topic: chroma.blend '#33b16f', '#857590', 'multiply'
+            'is #1a513e': (topic) -> assert.equal topic.hex(), '#1a513e'
+
+        'screen':
+            topic: chroma.blend '#b83d31', '#0da671', 'screen'
+            'is #bbbb8c': (topic) -> assert.equal topic.hex(), '#bbbb8c'
+
+        'overlay':
+            topic: chroma.blend '#b83d31', '#0da671', 'overlay'
+            'is #784f2b': (topic) -> assert.equal topic.hex(), '#784f2b'
+
+    .export(module)
diff --git a/test/cache-performance.coffee b/test/cache-performance.coffee
new file mode 100644
index 0000000..7400598
--- /dev/null
+++ b/test/cache-performance.coffee
@@ -0,0 +1,19 @@
+require 'es6-shim'
+vows = require 'vows'
+assert = require 'assert'
+chroma = require '../chroma'
+
+
+
+s = chroma.scale('RdYlGn')
+    .mode('lab')
+    .domain([0,100000], 10)
+
+t0 = new Date().getTime()
+
+for i in [1..100000]
+    s(i).hex()
+
+t1 = new Date().getTime()
+
+console.log (t1 - t0) + "ms"
diff --git a/test/cmyk-test.coffee b/test/cmyk-test.coffee
new file mode 100644
index 0000000..686731b
--- /dev/null
+++ b/test/cmyk-test.coffee
@@ -0,0 +1,45 @@
+require 'es6-shim'
+vows = require 'vows'
+assert = require 'assert'
+chroma = require '../chroma'
+
+round = (digits) ->
+    d = Math.pow 10,digits
+    return (v) ->
+        Math.round(v*d) / d
+
+vows
+    .describe('Testing CMYK color conversions')
+    .addBatch
+
+        'export simple colors to CMYK':
+            topic: ['black','white','red','#0f0','blue','yellow','cyan','magenta','gray']
+            'black':   (t) -> assert.deepEqual chroma(t[0]).cmyk(), [0,0,0,1]
+            'white':   (t) -> assert.deepEqual chroma(t[1]).cmyk(), [0,0,0,0]
+            'red':     (t) -> assert.deepEqual chroma(t[2]).cmyk(), [0,1,1,0]
+            'green':   (t) -> assert.deepEqual chroma(t[3]).cmyk(), [1,0,1,0]
+            'blue':    (t) -> assert.deepEqual chroma(t[4]).cmyk(), [1,1,0,0]
+            'yellow':  (t) -> assert.deepEqual chroma(t[5]).cmyk(), [0,0,1,0]
+            'cyan':    (t) -> assert.deepEqual chroma(t[6]).cmyk(), [1,0,0,0]
+            'magenta': (t) -> assert.deepEqual chroma(t[7]).cmyk(), [0,1,0,0]
+            'gray': (t) -> assert.deepEqual chroma(t[8]).cmyk().map(round(4)), [0,0,0,0.498]
+
+        'parse simple CMYK colors':
+            topic: [[0,0,0,1],[0,0,0,0],[0,1,1,0],[1,0,1,0],[1,1,0,0],[0,0,1,0],[1,0,0,0],[0,1,0,0]]
+            'black':   (t) -> assert.equal chroma(t[0], 'cmyk').hex(), '#000000'
+            'white':   (t) -> assert.equal chroma(t[1], 'cmyk').hex(), '#ffffff'
+            'red':     (t) -> assert.equal chroma(t[2], 'cmyk').hex(), '#ff0000'
+            'green':   (t) -> assert.equal chroma(t[3], 'cmyk').hex(), '#00ff00'
+            'blue':    (t) -> assert.equal chroma(t[4], 'cmyk').hex(), '#0000ff'
+            'yellow':  (t) -> assert.equal chroma(t[5], 'cmyk').hex(), '#ffff00'
+            'cyan':    (t) -> assert.equal chroma(t[6], 'cmyk').hex(), '#00ffff'
+            'magenta': (t) -> assert.equal chroma(t[7], 'cmyk').hex(), '#ff00ff'
+
+        'alternative syntax':
+            topic: [1,0,1,0]
+            'array-mode': (cmyk) -> assert.equal chroma(cmyk, 'cmyk').hex(), '#00ff00'
+            'values-mode': (cmyk) -> assert.equal chroma(cmyk...,'cmyk').hex(), '#00ff00'
+            'shortcut 1': (cmyk) -> assert.equal chroma.cmyk(cmyk).hex(), '#00ff00'
+            'shortcut 2': (cmyk) -> assert.equal chroma.cmyk(cmyk...).hex(), '#00ff00'
+
+    .export(module)
diff --git a/test/colors-test.coffee b/test/colors-test.coffee
new file mode 100644
index 0000000..57178f8
--- /dev/null
+++ b/test/colors-test.coffee
@@ -0,0 +1,70 @@
+require 'es6-shim'
+vows = require 'vows'
+assert = require 'assert'
+chroma = require '../chroma'
+
+round = (digits) ->
+    d = Math.pow 10,digits
+    return (v) ->
+        Math.round(v*d) / d
+
+vows
+    .describe('Some tests for chroma.color()')
+
+    .addBatch
+
+        'hsv black':
+            topic: chroma('black').hsv()
+            'hue is NaN': (topic) -> assert isNaN topic[0]
+            'but hue is defined': (topic) -> assert topic[0]?
+
+        'toString':
+            topic: chroma '#adff2f'
+            'explicit': (topic) -> assert.equal topic.toString(), 'greenyellow'
+            'implicit': (topic) -> assert.equal ''+topic, 'greenyellow'
+            'implicit2': (topic) -> assert.equal String(topic), 'greenyellow'
+
+        'constructing numeric color':
+            topic: chroma.num 0xff0000
+            'color is red': (topic) -> assert.equal topic.name(), 'red'
+            'alpha is 100%': (topic) -> assert.equal topic.alpha(), 1
+
+        'normalize hue':
+            topic: chroma.rgb(0,255,255).lch()
+            'hue > 0': (topic) -> assert topic[2] >= 0
+            'hue < 360': (topic) -> assert topic[2] <= 360
+
+        'lab conversion red':
+            topic: chroma('red').lab().map(round(3))
+            'is right': (topic) -> assert.deepEqual topic, [53.241, 80.092, 67.203]
+
+        'lab conversion blue':
+            topic: chroma('blue').lab().map(round(3))
+            'is right': (topic) -> assert.deepEqual topic, [32.297, 79.188, -107.86]
+
+        'lab conversion green':
+            topic: chroma('green').lab().map(round(3))
+            'is right': (topic) -> assert.deepEqual topic, [46.227, -51.698, 49.897]
+
+        'lab conversion yellow':
+            topic: chroma('yellow').lab().map(round(3))
+            'is right': (topic) -> assert.deepEqual topic, [97.139, -21.554, 94.478]
+
+        'lab conversion magenta':
+            topic: chroma('magenta').lab().map(round(3))
+            'is right': (topic) -> assert.deepEqual topic, [60.324, 98.234, -60.825]
+
+        'hueless css hsl colors':
+            topic: [chroma('black'), chroma('gray'), chroma('white')]
+            'black': (topic) -> assert.equal topic[0].css('hsl'), 'hsl(0,0%,0%)'
+            'gray': (topic) -> assert.equal topic[1].css('hsl'), 'hsl(0,0%,50.2%)'
+            'white': (topic) -> assert.equal topic[2].css('hsl'), 'hsl(0,0%,100%)'
+
+        'hcl.h is NaN for hue-less colors':
+            topic: [chroma('black'), chroma('gray'), chroma('white')]
+            'black': (topic) -> assert.isNaN topic[0].hcl()[0]
+            'gray': (topic) -> assert.isNaN topic[1].hcl()[0]
+            'white': (topic) -> assert.isNaN topic[2].hcl()[0]
+            
+
+    .export(module)
diff --git a/test/contrast-test.coffee b/test/contrast-test.coffee
new file mode 100644
index 0000000..e4c0864
--- /dev/null
+++ b/test/contrast-test.coffee
@@ -0,0 +1,24 @@
+require 'es6-shim'
+vows = require 'vows'
+assert = require 'assert'
+chroma = require '../chroma'
+
+
+vows
+    .describe('Testing contrast ratio')
+
+    .addBatch
+
+        'maximum contrast':
+            topic: chroma.contrast 'black', 'white'
+            'is 21:1': (topic) -> assert.equal topic, 21
+
+        'minimum contrast':
+            topic: chroma.contrast 'white', 'white'
+            'is 1:1': (topic) -> assert.equal topic, 1
+
+        'contrast between white and red':
+            topic: chroma.contrast 'red', 'white'
+            'is 4:1': (topic) -> assert.equal Math.round(topic,5), 4
+
+    .export(module)
\ No newline at end of file
diff --git a/test/cubehelix-test.coffee b/test/cubehelix-test.coffee
new file mode 100644
index 0000000..6a74797
--- /dev/null
+++ b/test/cubehelix-test.coffee
@@ -0,0 +1,61 @@
+require 'es6-shim'
+vows = require 'vows'
+assert = require 'assert'
+chroma = require '../chroma'
+
+
+vows
+    .describe('Testing cubehelix scales')
+
+    .addBatch
+
+        'default helix':
+            topic: () -> chroma.cubehelix()
+            'starts in black': (t) -> assert.equal t(0).hex(), '#000000'
+            'at 0.25': (t) -> assert.equal t(0.25).hex(), '#15524b'
+            'at 0.5': (t) -> assert.equal t(0.5).hex(), '#a07949'
+            'at 0.75': (t) -> assert.equal t(0.75).hex(), '#c6b2ec'
+            'ends in white': (t) -> assert.equal t(1).hex(), '#ffffff'
+
+        'red helix':
+            topic: () -> chroma.cubehelix(0, 1, 1, 1)
+            'starts in black': (t) -> assert.equal t(0).hex(), '#000000'
+            'at 0.25': (t) -> assert.equal t(0.25).hex(), '#2d5016'
+            'at 0.5': (t) -> assert.equal t(0.5).hex(), '#4b939e'
+            'at 0.75': (t) -> assert.equal t(0.75).hex(), '#d1aee8'
+            'ends in white': (t) -> assert.equal t(1).hex(), '#ffffff'
+
+        'red helix - partial l range':
+            topic: () -> chroma.cubehelix(0, 1, 1, 1, [0.25, 0.75])
+            'starts in black': (t) -> assert.equal t(0).hex(), '#663028'
+            'at 0.25': (t) -> assert.equal t(0.25).hex(), '#48742c'
+            'at 0.5': (t) -> assert.equal t(0.5).hex(), '#4b939e'
+            'at 0.75': (t) -> assert.equal t(0.75).hex(), '#b68ad2'
+            'ends in white': (t) -> assert.equal t(1).hex(), '#e5afa7'
+
+        'red helix - gamma':
+            topic: () -> chroma.cubehelix(0, 1, 1, 0.8)
+            'starts in black': (t) -> assert.equal t(0).hex(), '#000000'
+            'at 0.25': (t) -> assert.equal t(0.25).hex(), '#3e6823'
+            'at 0.5': (t) -> assert.equal t(0.5).hex(), '#60a6b1'
+            'at 0.75': (t) -> assert.equal t(0.75).hex(), '#dabbee'
+            'ends in white': (t) -> assert.equal t(1).hex(), '#ffffff'
+
+        'red helix - no saturation':
+            topic: () -> chroma.cubehelix(0, 1, 0, 1)
+            'starts in black': (t) -> assert.equal t(0).hex(), '#000000'
+            'at 0.25': (t) -> assert.equal t(0.25).hex(), '#3f3f3f'
+            'at 0.5': (t) -> assert.equal t(0.5).hex(), '#7f7f7f'
+            'at 0.75': (t) -> assert.equal t(0.75).hex(), '#bfbfbf'
+            'ends in white': (t) -> assert.equal t(1).hex(), '#ffffff'
+
+        'red helix - saturation range':
+            topic: () -> chroma.cubehelix(0, 1, [1,0], 1)
+            'starts in black': (t) -> assert.equal t(0).hex(), '#000000'
+            'at 0.25': (t) -> assert.equal t(0.25).hex(), '#324c21'
+            'at 0.5': (t) -> assert.equal t(0.5).hex(), '#65898f'
+            'at 0.75': (t) -> assert.equal t(0.75).hex(), '#c3bbc9'
+            'ends in white': (t) -> assert.equal t(1).hex(), '#ffffff'
+            'saturation decreases': (t) -> assert t(0.33).hsl()[1] > t(0.66).hsl()[1]
+
+    .export(module)
\ No newline at end of file
diff --git a/test/get-test.coffee b/test/get-test.coffee
new file mode 100644
index 0000000..7e51cce
--- /dev/null
+++ b/test/get-test.coffee
@@ -0,0 +1,14 @@
+require 'es6-shim'
+vows = require 'vows'
+assert = require 'assert'
+chroma = require '../chroma'
+
+vows
+    .describe('Testing color.get')
+    .addBatch
+        'get hue':
+            topic: chroma 'hotpink'
+            'hue not zero': (topic) -> assert.equal topic.hsl()[0], topic.get('hsl.h')
+
+
+    .export(module)
diff --git a/test/gl-test.coffee b/test/gl-test.coffee
new file mode 100644
index 0000000..fd3fcba
--- /dev/null
+++ b/test/gl-test.coffee
@@ -0,0 +1,27 @@
+require 'es6-shim'
+vows = require 'vows'
+assert = require 'assert'
+chroma = require '../chroma'
+
+
+vows
+    .describe('Some tests for gl colors')
+
+    .addBatch
+
+        'gl color':
+            topic: chroma.gl 1,0,0
+            'name': (topic) -> assert.equal topic.name(), 'red'
+            'hex': (topic) -> assert.equal topic.hex(), '#ff0000'
+            'rgb': (topic) -> assert.deepEqual topic.rgb(), [255,0,0]
+
+        'gl color non-1':
+            topic: chroma.gl 1,0.5,0.2
+            'hex': (topic) -> assert.equal topic.hex(), '#ff7f33'
+            'rgb': (topic) -> assert.deepEqual topic.rgb(), [255,127.5,51]
+
+        'gl color w/ alpha':
+            topic: chroma.gl 0,0,1,0.5
+            'rgba': (topic) -> assert.deepEqual topic.rgba(), [0,0,255,0.5]
+
+    .export(module)
diff --git a/test/guess-format-test.coffee b/test/guess-format-test.coffee
new file mode 100644
index 0000000..baff222
--- /dev/null
+++ b/test/guess-format-test.coffee
@@ -0,0 +1,91 @@
+require 'es6-shim'
+vows = require 'vows'
+assert = require 'assert'
+chroma = require '../chroma'
+
+round = (digits) ->
+    d = Math.pow 10,digits
+    return (v) ->
+        Math.round(v*d) / d
+
+vows
+    .describe('Some tests for chroma.color()')
+
+    .addBatch
+
+        'named colors':
+            topic: chroma 'red'
+            'hex': (topic) -> assert.equal topic.hex(), '#ff0000'
+            'rgb': (topic) -> assert.deepEqual topic.rgb(), [255,0,0]
+
+        'hex colors':
+            topic: chroma '#f00'
+            'name': (topic) -> assert.equal topic.name(), 'red'
+            'hex': (topic) -> assert.equal topic.hex(), '#ff0000'
+            'hex rgba': (topic) -> assert.equal topic.hex('rgba'), '#ff0000ff'
+            'hex argb': (topic) -> assert.equal topic.hex('argb'), '#ffff0000'
+            'rgb': (topic) -> assert.deepEqual topic.rgb(), [255,0,0]
+
+        'hex color, no #':
+            topic: chroma 'F00'
+            'name': (topic) -> assert.equal topic.name(), 'red'
+            'hex': (topic) -> assert.equal topic.hex(), '#ff0000'
+            'rgb': (topic) -> assert.deepEqual topic.rgb(), [255,0,0]
+
+        'css color rgb':
+            topic: chroma 'rgb(255,0,0)'
+            'hex': (topic) -> assert.equal topic.hex(), '#ff0000'
+
+        'rgba css color':
+            topic: chroma 'rgba(128,0,128,0.5)'
+            'hex': (topic) -> assert.equal topic.hex(), '#800080'
+            'alpha': (topic) -> assert.equal topic.alpha(), 0.5
+            'css': (topic) -> assert.equal topic.css(), 'rgba(128,0,128,0.5)'
+
+        'hsla css color':
+            topic: chroma 'hsla(240,100%,50%,0.5)'
+            'hex': (topic) -> assert.equal topic.hex(), '#0000ff'
+            'alpha': (topic) -> assert.equal topic.alpha(), 0.5
+            'css': (topic) -> assert.equal topic.css(), 'rgba(0,0,255,0.5)'
+
+        'hsla color':
+            topic: chroma 'lightsalmon'
+            'css (default)': (topic) -> assert.equal topic.css(), 'rgb(255,160,122)'
+            'css (rgb)': (topic) -> assert.equal topic.css('rgb'), 'rgb(255,160,122)'
+            'css (hsl)': (topic) -> assert.equal chroma(topic.css('hsl')).name(), 'lightsalmon'
+            'css (rgb-css)': (topic) -> assert.equal chroma(topic.css('rgb')).name(), 'lightsalmon'
+
+        'rgb color':
+            topic: chroma 255,0,0
+            'hex': (topic) -> assert.equal topic.hex(), '#ff0000'
+
+        'hsv black':
+            topic: chroma('black').hsv()
+            'hue is NaN': (topic) -> assert isNaN topic[0]
+            'but hue is defined': (topic) -> assert topic[0]?
+
+        'hsl black':
+            topic: chroma('black').hsl()
+            'hue is NaN': (topic) -> assert isNaN topic[0]
+            'but hue is defined': (topic) -> assert topic[0]?
+            'sat is 0': (topic) -> assert.equal topic[1], 0
+            'lightness is 0': (topic) -> assert.equal topic[2], 0
+
+        'constructing with array, but no mode':
+            topic: chroma [255, 0, 0]
+            'falls back to rgb': (topic) -> assert.equal topic.hex(), chroma([255, 0, 0],'rgb').hex()
+
+        'num color':
+            topic: [chroma(0xff0000), chroma(0x000000), chroma(0xffffff), chroma(0x31ff98), chroma('red')]
+            'hex': (topic) -> assert.equal topic[0].hex(), '#ff0000'
+            'num': (topic) -> assert.equal topic[0].num(), 0xff0000
+            'hex-black': (topic) -> assert.equal topic[1].hex(), '#000000'
+            'num-black': (topic) -> assert.equal topic[1].num(), 0x000000
+            'hex-white': (topic) -> assert.equal topic[2].hex(), '#ffffff'
+            'num-white': (topic) -> assert.equal topic[2].num(), 0xffffff
+            'hex-rand': (topic) -> assert.equal topic[3].hex(), '#31ff98'
+            'num-rand': (topic) -> assert.equal topic[3].num(), 0x31ff98
+            'rum-red': (topic) -> assert.equal topic[4].num(), 0xff0000
+
+
+    .export(module)
diff --git a/test/html/bezier.html b/test/html/bezier.html
new file mode 100644
index 0000000..b01a522
--- /dev/null
+++ b/test/html/bezier.html
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <title>Bezier Interpolation</title>
+    <script type="text/javascript" src="../../chroma.js"></script>
+</head>
+<body>
+
+    <script type="text/javascript">
+
+    function showGradient(I, outerdiv, steps) {
+        var I = chroma.interpolate.bezier(c),
+            c = document.createElement('div'),
+            totalW = 800;
+        for (var i=0; i < steps; i++) {
+            var d = document.createElement('div');
+            d.style.display = 'inline-block';
+            d.style.width = (totalW / steps) + 'px';
+            d.style.height = '60px';
+            d.style.background = I(i/(steps-1)).hex();
+            c.appendChild(d);
+        }
+        outerdiv.appendChild(c);
+    }
+
+    var colors = [
+        ['white', 'black'],
+        ['white', 'red', 'black'],
+        ['white', 'yellow', 'red', 'black'],
+        ['red', 'white', 'blue'],
+        ['#fdfdf9', 'darkred'],
+        ['#fdfdf9', 'orange', 'darkred'],
+        ['#fdfdf9', 'yellow', 'orange', 'darkred'],
+        ['darkred', 'orange', 'snow', 'lightgreen', 'royalblue'],
+    ];
+
+    for (var c in colors) {
+        c = colors[c];
+        d = document.createElement('div');
+        d.style.position = 'relative';
+        document.body.appendChild(d);
+        d.innerHTML = "<div style='position:absolute;top:5px;left:10px;opacity:0.9;color:#000;text-shadow:-1px -1px 0px rgba(255,255,255,0.3), 1px 1px 0px rgba(255,255,255,0.3), -1px 1px 0px rgba(255,255,255,0.3), 1px -1px 0px rgba(255,255,255,0.3)'><code>" + c + "</code></div>";
+        showGradient(colors, d, 13);
+    }
+
+
+
+    </script>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/test/html/blend.html b/test/html/blend.html
new file mode 100644
index 0000000..90b87b5
--- /dev/null
+++ b/test/html/blend.html
@@ -0,0 +1,70 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <title>Chroma.js</title>
+    <script type="text/javascript" src="../../chroma.js"></script>
+</head>
+<style type="text/css">
+    body { font-family: Helvetica; }
+    h1 { font-size: 18px; }
+    .row { margin-bottom: 10px; }
+    .left, .right { display: inline-block; margin-right: 20px; position: relative; }
+    .swatch { display: inline-block; width: 60px; height: 50px; }
+    .swatch.overlay { position: absolute; left: 60px; }
+</style>
+<body>
+
+
+    <script type="text/javascript">
+
+    var names = Object.keys(chroma.colors), l = names.length;
+
+    var cssMap = {
+        dodge: 'color-dodge',
+        burn: 'color-burn'
+    };
+
+    Object.keys(chroma.blend).forEach(function(mode) {
+
+        document.write('<h1>'+mode+'</h1>');
+        for (var i=0; i<10; i++) {
+            var row = el('div.row'),
+                left = el('div.left'),
+                right = el('div.right');
+
+            var bottom = names[Math.floor(Math.random()*l)],
+                top = names[Math.floor(Math.random()*l)];
+
+            swatch(bottom, left);
+            swatch(chroma.blend(bottom, top, mode).hex(), left);
+            swatch(top, left);
+
+            swatch(bottom, right);
+            swatch(bottom, right);
+            var s = swatch(top, right);
+            s.className = 'swatch overlay';
+            s.style.mixBlendMode = cssMap[mode] || mode;
+            swatch(top, right);
+        }
+
+    });
+
+    function swatch(color, parent) {
+        var s = el('div.swatch', parent);
+        s.setAttribute('title', color);
+        s.style.background = color;
+        return s;
+    }
+
+    function el(t, parent) {
+        var p = t.split('.');
+        var e = document.createElement(p[0]);
+        if (p[1]) e.className = p[1];
+        (parent || document.body).appendChild(e);
+        return e;
+    }
+
+    </script>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/test/html/colorscales.html b/test/html/colorscales.html
new file mode 100644
index 0000000..869ca57
--- /dev/null
+++ b/test/html/colorscales.html
@@ -0,0 +1,73 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <title>Chroma.js</title>
+    <script type="text/javascript" src="../chroma.js"></script>
+</head>
+<body>
+
+    <script type="text/javascript">
+
+    function showScale(cs, outerdiv, log) {
+        cs.out('hex');
+        var c = document.createElement('div');
+        for (var i=0; i<= 1; i += 0.002) {
+            var d = document.createElement('div');
+            d.style.display = 'inline-block';
+            d.style.width = '2px';
+            d.style.height = '60px';
+            d.style.background = cs(log ? Math.pow(10, i * 3): i);
+            c.appendChild(d);
+        }
+        outerdiv.appendChild(c);
+    }
+
+    var scales = [
+        "scale(['lightyellow', 'navy'])",
+        "scale(['lightyellow', 'navy']).mode('lab')",
+        "scale(['lightyellow', 'navy']).mode('lch')",
+        "scale(['lightyellow', 'navy']).mode('hsv')",
+        "scale(['lightyellow', 'navy']).mode('hsl')",
+        "scale(['lightyellow', 'navy']).mode('hsi')",
+        "scale(['white', 'darkred']).mode('lab')",
+        "scale(['white', 'yellow', 'orange', 'darkred']).mode('lab')",
+        "scale(['darkred', 'orange', 'snow', 'lightgreen', 'royalblue']).mode('lab')",
+        "scale('RdYlGn').domain([0, 1], 9)",
+        "scale('RdYlGn')",
+        "scale(['#A50026', '#FFFFBF', '#006837']).mode('lab')",
+        "scale(['#A50026', '#FFFFBF', '#006837']).mode('lch')",
+        "scale(['#A50026', '#FFFFBF', '#006837']).mode('hsv')",
+        "scale(['#A50026', '#FFFFBF', '#006837']).mode('rgb')",
+        "scale(['#A50026', '#FFFFBF', '#006837']).mode('hsl')",
+        "scale(['#A50026', '#FFFFBF', '#006837']).mode('hsi')",
+        "scale(['#ffeeef', '#CD002F', '#400001']).domain([0,1], 9).mode('lab')",
+        "scale(['#ffeeef', '#CD002F', '#400001']).domain([0,1], 9).mode('lch')",
+        "scale(['#ffeeef', '#CD002F', '#400001']).domain([0,1], 9).mode('rgb')",
+        "scale(['#ffeeef', '#CD002F', '#400001']).domain([0,1], 9).mode('hsv')",
+        "scale(['#ffeeef', '#CD002F', '#400001']).domain([0,1], 9).mode('hsl')",
+        "scale(['#ffffff', '#000000']).domain([0,1], 9).mode('lab')",
+        "scale(['#ffffff', '#000000']).domain([0,1], 9).mode('lch')",
+        "scale(['#ffffff', '#000000']).domain([0,1], 9).mode('rgb')",
+        "scale(['#ffffff', '#000000']).domain([0,1], 9).mode('hsv')",
+        "scale(['#ffffff', '#000000']).domain([1,1000], 9, 'log').mode('hsl')",
+        "scale('RdYlGn').domain([0,1], 7).mode('lab')",
+        "scale(['a01','F7F7F7','25a']).domain([0, 0.14285714285714285, 0.2857142857142857, 0.42857142857142855, 0.5714285714285714, 0.7142857142857143, 0.8571428571428571, 1]).mode('lab')",
+        "scale(['a01','F7F7F7','25a']).domain([0,.05,.13,.2,.4,.6,.8,1]).mode('lab')",
+        "scale(['a01','F7F7F7','25a']).domain([0,.05,.13,.2,.4,.6,.8,1]).fixed(true).mode('lab')",
+    ];
+
+    for (var s in scales) {
+        s = scales[s];
+        d = document.createElement('div');
+        d.style.position = 'relative';
+        document.body.appendChild(d);
+        d.innerHTML = "<div style='position:absolute;top:5px;left:10px;opacity:0.9;color:#000;text-shadow:-1px -1px 0px rgba(255,255,255,0.3), 1px 1px 0px rgba(255,255,255,0.3), -1px 1px 0px rgba(255,255,255,0.3), 1px -1px 0px rgba(255,255,255,0.3)'><code>chroma." + s + "</code></div>";
+        showScale(eval("chroma." + s), d, s.indexOf("log") > 0);
+    }
+
+
+
+    </script>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/test/html/cubehelix.html b/test/html/cubehelix.html
new file mode 100644
index 0000000..e9d3b86
--- /dev/null
+++ b/test/html/cubehelix.html
@@ -0,0 +1,58 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <title>Cubejelix Interpolation</title>
+    <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
+    <script type="text/javascript" src="../../chroma.js"></script>
+    <style type="text/css">
+input[type=number] { width: 40px; }
+    </style>
+</head>
+<body>
+    start <input type="number" id="start" value="300"  step="20" />
+    rotations <input type="number" id="rot" value="-1.5" step="0.1" />
+    gamma <input type="number" id="gamma" value="1" step="0.1" />
+    l min/max <input type="number" id="lmin" value="0" step="0.1" min="0" />
+              <input type="number" id="lmax" value="1" step="0.1" max="1" />
+    sat min/max <input type="number" id="smin" value="1" step="0.1" min="0" />
+                <input type="number" id="smax" value="1" step="0.1" min="0" />
+
+<hr>
+    <script type="text/javascript">
+
+    $('input').on('change', update);
+
+    function v(id) { return +$('#'+id).val(); }
+
+    var j = 0;
+
+    function update() {
+        var steps = 200,
+            totalW = 800;
+        var sat = [v('smin'), v('smax')];
+        $('.scale').remove();
+        var ch = chroma.cubehelix(
+                v('start'),
+                v('rot'),
+                sat[0] != sat[1] ? sat : sat[0],
+                v('gamma'),
+                [v('lmin'), v('lmax')]
+            );
+        var c = $('<div />').addClass('scale').appendTo('body');
+        for (var i=0; i < steps; i++) {
+            $('<div/>').css({
+                display: 'inline-block',
+                width: (totalW / steps) + 'px',
+                height: '100px',
+                background: ch(i/(steps-1)).hex()
+            })
+            .appendTo(c);
+        }
+    }
+
+    update();
+
+    </script>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/test/html/luminance.html b/test/html/luminance.html
new file mode 100644
index 0000000..1ecee89
--- /dev/null
+++ b/test/html/luminance.html
@@ -0,0 +1,50 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <title>Chroma.js</title>
+    <script type="text/javascript" src="../../chroma.js"></script>
+</head>
+<body>
+
+    <script type="text/javascript">
+
+    function showScale(color, mode, odiv) {
+        var c = document.createElement('div');
+        for (var i=0; i <= 1; i += 0.01) {
+            var col = chroma(color).luminance(i, mode);
+            var d = document.createElement('div');
+            d.style.display = 'inline-block';
+            d.style.width = '10px';
+            d.style.height = '60px';
+            d.style.background = col.hex();
+            c.appendChild(d);
+        }
+        odiv.appendChild(c);
+    }
+
+    var scales = [
+        ['red', 'rgb'],
+        ['red', 'lab'],
+        ['yellow', 'lab'],
+        ['black', 'rgb'],
+        ['blue', 'rgb'],
+        ['green', 'rgb'],
+        ['green', 'lab'],
+        ['orange', 'rgb']
+    ];
+
+    for (var s in scales) {
+        s = scales[s];
+        d = document.createElement('div');
+        d.style.position = 'relative';
+        document.body.appendChild(d);
+        d.innerHTML = "<div style='position:absolute;top:5px;left:10px;opacity:0.9;color:#000;text-shadow:-1px -1px 0px rgba(255,255,255,0.3), 1px 1px 0px rgba(255,255,255,0.3), -1px 1px 0px rgba(255,255,255,0.3), 1px -1px 0px rgba(255,255,255,0.3)'><code>" + s.join(' / ') + "</code></div>";
+        showScale(s[0], s[1], d);
+    }
+
+
+
+    </script>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/test/interpolate-test.coffee b/test/interpolate-test.coffee
new file mode 100644
index 0000000..f13e058
--- /dev/null
+++ b/test/interpolate-test.coffee
@@ -0,0 +1,80 @@
+require 'es6-shim'
+vows = require 'vows'
+assert = require 'assert'
+chroma = require '../chroma'
+
+
+vows
+    .describe('Some tests for chroma.color()')
+
+    .addBatch
+
+        'hsv interpolation white <-> red':
+            topic: chroma('white').interpolate('red', 0.5, 'hsv')
+            'works': (topic) -> assert.deepEqual topic.hex(), '#ff8080'
+
+        'use mix as alias':
+            topic: chroma('white').mix('red', 0.5, 'hsv')
+            'works': (topic) -> assert.deepEqual topic.hex(), '#ff8080'
+
+        'alternative mix syntax':
+            topic: chroma.mix('red', 'blue', 0.25)
+            'works': (topic) -> assert.deepEqual topic.hex(), '#bf003f'
+
+        'hsl interpolation white <-> red':
+            topic: chroma('white').interpolate('red', 0.5, 'hsl')
+            'works': (topic) -> assert.deepEqual topic.hex(), '#ff8080'
+
+        'rgb interpolation white <-> red':
+            topic: chroma('white').interpolate('red', 0.5, 'rgb')
+            'works': (topic) -> assert.deepEqual topic.hex(), '#ff7f7f'
+
+        'hsv interpolation red <-> white':
+            topic: chroma('red').interpolate('white', 0.5, 'hsv')
+            'works': (topic) -> assert.deepEqual topic.hex(), '#ff8080'
+
+        'hsl interpolation red <-> white':
+            topic: chroma('red').interpolate('white', 0.5, 'hsl')
+            'works': (topic) -> assert.deepEqual topic.hex(), '#ff8080'
+
+        'rgb interpolation red <-> white':
+            topic: chroma('red').interpolate('white', 0.5, 'rgb')
+            'works': (topic) -> assert.deepEqual topic.hex(), '#ff7f7f'
+
+        'interpolation short function':
+            topic:
+                f: (t) -> chroma.interpolate('#ff0000', '#ffffff', t, 'hsv').hex()
+            'starts at red': (topic) -> assert.equal topic.f(0), '#ff0000'
+            'goes over light red': (topic) -> assert.equal topic.f(0.5), '#ff8080'
+            'ends at white': (topic) -> assert.equal topic.f(1), '#ffffff'
+
+        'num interpolation white <-> red':
+            topic: chroma(0xffffff).interpolate(0xff0000, 0.5, 'num')
+            'works': (topic) -> assert.deepEqual topic.hex(), '#ff7fff'
+
+        'num interpolation red <-> white':
+            topic: chroma(0xff0000).interpolate(0xffffff, 0.5, 'num')
+            'works': (topic) -> assert.deepEqual topic.hex(), '#ff7fff'
+
+        'interpolation short function with num provided':
+            topic:
+                f: (t) -> chroma.interpolate(0xff0000, 0xffffff, t, 'num').hex()
+            'starts at red': (topic) -> assert.equal topic.f(0), '#ff0000'
+            'goes over light red': (topic) -> assert.equal topic.f(0.5), '#ff7fff'
+            'ends at white': (topic) -> assert.equal topic.f(1), '#ffffff'
+
+        'interpolate in num':
+            topic: chroma.interpolate chroma.num(0xffffe0), chroma.num(0x102180), 0.5, 'num'
+            'hex': (topic) -> assert.equal topic.hex(), '#8810b0'
+            'num': (topic) -> assert.equal topic.num(), 8917168
+
+        'interpolate in hsv':
+            topic: chroma.interpolate 'white', 'black', 0.5, 'hsv'
+            'hex': (topic) -> assert.equal topic.hex(), '#808080'
+
+        'interpolate in hsl':
+            topic: chroma.interpolate 'lightyellow', 'navy', 0.5, 'hsl'
+            'hex': (topic) -> assert.equal topic.hex(), '#31ff98'
+
+
+    .export(module)
diff --git a/test/lch-test.coffee b/test/lch-test.coffee
new file mode 100644
index 0000000..b68252f
--- /dev/null
+++ b/test/lch-test.coffee
@@ -0,0 +1,28 @@
+require 'es6-shim'
+vows = require 'vows'
+assert = require 'assert'
+chroma = require '../chroma'
+
+vows
+    .describe('Some tests for chroma.lch()')
+
+    .addBatch
+
+        'lch grayscale':
+            topic: ([l,0,0] for l in [0,100,25,50,75])
+            'black': (t) -> assert.equal chroma.lch(t[0]).hex(), '#000000'
+            'white': (t) -> assert.equal chroma.lch(t[1]).hex(), '#ffffff'
+            'gray 1': (t) -> assert.equal chroma.lch(t[2]).hex(), '#3b3b3b'
+            'gray 2': (t) -> assert.equal chroma.lch(t[3]).hex(), '#777777'
+            'gray 3': (t) -> assert.equal chroma.lch(t[4]).hex(), '#b9b9b9'
+
+        'lch hues':
+            topic: ([50,70,h] for h in [0,60,120,180,240,300])
+            'red-ish': (t) -> assert.equal chroma.lch(t[0]).hex(), '#dc2c7a'
+            'yellow-ish': (t) -> assert.equal chroma.lch(t[1]).hex(), '#bd5c00'
+            'green-ish': (t) -> assert.equal chroma.lch(t[2]).hex(), '#548400'
+            'teal-ish': (t) -> assert.equal chroma.lch(t[3]).hex(), '#009175'
+            'blue-ish': (t) -> assert.equal chroma.lch(t[4]).hex(), '#008cde'
+            'purple-ish': (t) -> assert.equal chroma.lch(t[5]).hex(), '#6f67df'
+
+    .export(module)
diff --git a/test/lcorrection-test.coffee b/test/lcorrection-test.coffee
new file mode 100644
index 0000000..4e6eec0
--- /dev/null
+++ b/test/lcorrection-test.coffee
@@ -0,0 +1,54 @@
+require 'es6-shim'
+vows = require 'vows'
+assert = require 'assert'
+chroma = require '../chroma'
+
+
+vows
+    .describe('Testing lightess correction')
+
+    .addBatch
+
+        'simple two color linear interpolation':
+            topic:
+                f: chroma.scale(['white', 'black']).mode('lab')
+            'center L is 50': (topic) ->
+                assert.equal Math.round(topic.f(0.5).lab()[0]), 50
+
+        'hot - w/o correction':
+            topic:
+                f: chroma.scale(['white', 'yellow', 'red', 'black']).mode('lab')
+            'center L is 74': (topic) ->
+                assert.equal Math.round(topic.f(0.5).lab()[0]), 74
+
+        'hot - with correction':
+            topic:
+                f: chroma.scale(['white', 'yellow', 'red', 'black']).mode('lab').correctLightness(true)
+            'center L is 50': (topic) ->
+                assert.equal Math.round(topic.f(0.5).lab()[0]), 50
+
+        'hot - w/o correction - domained [0,100]':
+            topic:
+                f: chroma.scale(['white', 'yellow', 'red', 'black']).domain([0,100]).mode('lab')
+            'center L is 74': (topic) ->
+                assert.equal Math.round(topic.f(50).lab()[0]), 74
+
+        'hot - with correction - domained [0,100]':
+            topic:
+                f: chroma.scale(['white', 'yellow', 'red', 'black']).domain([0,100]).mode('lab').correctLightness(true)
+            'center L is 50': (topic) ->
+                assert.equal Math.round(topic.f(50).lab()[0]), 50
+
+        'hot - w/o correction - domained [0,20,40,60,80,100]':
+            topic:
+                f: chroma.scale(['white', 'yellow', 'red', 'black']).domain([0,20,40,60,80,100]).mode('lab')
+            'center L is 74': (topic) ->
+                assert.equal Math.round(topic.f(50).lab()[0]), 74
+
+        'hot - with correction - domained [0,20,40,60,80,100]':
+            topic:
+                f: chroma.scale(['white', 'yellow', 'red', 'black']).domain([0,20,40,60,80,100]).mode('lab').correctLightness(true)
+            'center L is 50': (topic) ->
+                assert.equal Math.round(topic.f(50).lab()[0]), 50
+
+    .export(module)
\ No newline at end of file
diff --git a/test/limits-test.coffee b/test/limits-test.coffee
new file mode 100644
index 0000000..5ff673f
--- /dev/null
+++ b/test/limits-test.coffee
@@ -0,0 +1,46 @@
+require 'es6-shim'
+vows = require 'vows'
+assert = require 'assert'
+chroma = require '../chroma'
+
+vows
+    .describe('Some tests for chroma.limits()')
+
+    .addBatch
+
+        'simple continuous domain':
+            topic: chroma.limits [1,2,3,4,5], 'continuous'
+            'domain': (topic) -> assert.deepEqual topic, [1,5]
+
+        'continuous domain, negative values':
+            topic: chroma.limits [1,-2, -3,4,5], 'continuous'
+            'domain': (topic) -> assert.deepEqual topic, [-3,5]
+
+        'continuous domain, null values':
+            topic: chroma.limits [1, undefined, null, 4, 5], 'continuous'
+            'domain': (topic) -> assert.deepEqual topic, [1,5]
+
+        'equidistant domain':
+            topic: chroma.limits [0,10], 'equidistant', 5
+            'domain': (topic) -> assert.deepEqual topic, [0, 2, 4, 6, 8, 10]
+
+        'equidistant domain, NaN values':
+            topic: chroma.limits [0,9,3,6,3,5,undefined,Number.NaN,10], 'equidistant', 5
+            'domain': (topic) -> assert.deepEqual topic, [0, 2, 4, 6, 8, 10]
+
+        'logarithmic domain':
+            topic: chroma.limits [1,10000], 'log', 4
+            'domain': (topic) -> assert.deepEqual topic, [1, 10, 100, 1000, 10000]
+
+        'logarithmic domain - non-positive values':
+            topic: [-1,10000]
+            'domain': (topic) ->
+                assert.throws () ->
+                    chroma.limits topic, 'log', 4
+                , 'Logarithmic scales are only possible for values > 0'
+
+        'quantiles domain':
+            topic: chroma.limits [1,2,3,4,5,10,20,100], 'quantiles', 2
+            'domain': (topic) -> assert.deepEqual topic, [1, 5, 100]
+
+    .export(module)
\ No newline at end of file
diff --git a/test/luminance-test.coffee b/test/luminance-test.coffee
new file mode 100644
index 0000000..94ba583
--- /dev/null
+++ b/test/luminance-test.coffee
@@ -0,0 +1,60 @@
+require 'es6-shim'
+vows = require 'vows'
+assert = require 'assert'
+chroma = require '../chroma'
+
+
+rnd = (f,d) ->
+    d = Math.pow(10,d)
+    Math.round(f*d) / d
+
+vows
+    .describe('Testing relative luminance')
+
+    .addBatch
+
+        'black':
+            topic: chroma 'black'
+            'lum = 0': (topic) -> assert.equal topic.luminance(), 0
+
+        'white':
+            topic: chroma 'white'
+            'lum = 1': (topic) -> assert.equal topic.luminance(), 1
+
+        'red':
+            topic: chroma 'red'
+            'lum = 0.21': (topic) -> assert.equal topic.luminance(), 0.2126
+
+        'yellow brighter than blue':
+            topic: [chroma('yellow').luminance(), chroma('blue').luminance()]
+            'yellow > blue': (topic) -> assert topic[0] > topic[1]
+
+        'green darker than red':
+            topic: [chroma('green').luminance(), chroma('red').luminance()]
+            'green < red': (topic) -> assert topic[0] < topic[1]
+
+        # setting luminance
+        'set red luminance to 0.4':
+            topic: chroma('red').luminance 0.4
+            'lum = 0.4': (topic) -> assert.equal rnd(topic.luminance(),3), 0.4
+
+        # setting luminance
+        'set red luminance to 0':
+            topic: chroma('red').luminance 0
+            'lum = 0': (topic) -> assert.equal rnd(topic.luminance(),2), 0
+            'hex = #000': (topic) -> assert.equal topic.hex(), '#000000'
+
+        # setting luminance
+        'set black luminance to 0.5':
+            topic: chroma('black').luminance 0.5
+            'lum = 0.5': (topic) -> assert.equal rnd(topic.luminance(), 2), 0.5
+            'hex = #999': (topic) -> assert.equal '#bbbbbb', topic.hex()
+
+            # setting luminance
+        'set black luminance to 0.5 (lab)':
+            topic: chroma('black').luminance 0.5, 'lab'
+            'lum = 0.5': (topic) -> assert.equal rnd(topic.luminance(),2), 0.5
+            'hex = #999': (topic) -> assert.equal '#bbbbbb', topic.hex()
+
+
+    .export(module)
\ No newline at end of file
diff --git a/test/manipulate-test.coffee b/test/manipulate-test.coffee
new file mode 100644
index 0000000..2662e34
--- /dev/null
+++ b/test/manipulate-test.coffee
@@ -0,0 +1,36 @@
+require 'es6-shim'
+vows = require 'vows'
+assert = require 'assert'
+chroma = require '../chroma'
+
+round = (digits) ->
+    d = Math.pow 10,digits
+    return (v) ->
+        Math.round(v*d) / d
+
+vows
+    .describe('Some tests for chroma.color()')
+
+    .addBatch
+
+        'modify colors':
+            topic: () -> chroma '#ff0000'
+            'darken': (topic) -> assert.equal topic.darken().hex(), '#c20000'
+            'darker': (topic) -> assert.equal topic.darker().hex(), '#c20000'
+            'darken more': (topic) -> assert.equal topic.darker(2).hex(), '#890000'
+            'darken too much': (topic) -> assert.equal topic.darker(10).hex(), '#000000'
+            'brighten': (topic) -> assert.equal topic.brighten().hex(), '#ff5a36'
+            'brighten too much': (topic) -> assert.equal topic.brighten(10).hex(), '#ffffff'
+            'brighter': (topic) -> assert.equal topic.brighter().hex(), '#ff5a36'
+            'saturate': (topic) -> assert.equal topic.saturate().hex(), '#ff0000'
+            'desaturate': (topic) -> assert.equal topic.desaturate().hex(), '#ee3a20'
+            'desaturate more': (topic) -> assert.equal topic.desaturate(2).hex(), '#db5136'
+            'desaturate too much': (topic) -> assert.equal topic.desaturate(400).hex(), '#7f7f7f'
+
+        'premultiply':
+            topic: chroma 'rgba(32, 48, 96, 0.5)'
+            'premultiply rgba': (topic) -> assert.deepEqual topic.premultiply().rgba(), [16, 24, 48, 0.5]
+            'premultiply hex': (topic) -> assert.equal topic.premultiply().hex(), '#101830'
+            'premultiply num': (topic) -> assert.equal topic.premultiply().num(), 0x101830
+
+    .export(module)
diff --git a/test/num-test.coffee b/test/num-test.coffee
new file mode 100644
index 0000000..8bcbe23
--- /dev/null
+++ b/test/num-test.coffee
@@ -0,0 +1,27 @@
+require 'es6-shim'
+vows = require 'vows'
+assert = require 'assert'
+chroma = require '../chroma'
+
+vows
+    .describe('Some tests for chroma.num()')
+
+    .addBatch
+
+        'number output':
+            topic: chroma.hsl 0,1,0.5,0.5
+            'numoutput': -> (topic) -> assert.equal topic.num(), 0xff0000
+
+        'num color':
+            topic: [chroma(0xff0000), chroma(0x000000), chroma(0xffffff), chroma(0x31ff98), chroma('red')]
+            'hex': (topic) -> assert.equal topic[0].hex(), '#ff0000'
+            'num': (topic) -> assert.equal topic[0].num(), 0xff0000
+            'hex-black': (topic) -> assert.equal topic[1].hex(), '#000000'
+            'num-black': (topic) -> assert.equal topic[1].num(), 0x000000
+            'hex-white': (topic) -> assert.equal topic[2].hex(), '#ffffff'
+            'num-white': (topic) -> assert.equal topic[2].num(), 0xffffff
+            'hex-rand': (topic) -> assert.equal topic[3].hex(), '#31ff98'
+            'num-rand': (topic) -> assert.equal topic[3].num(), 0x31ff98
+            'rum-red': (topic) -> assert.equal topic[4].num(), 0xff0000
+
+    .export(module)
diff --git a/test/random-test.coffee b/test/random-test.coffee
new file mode 100644
index 0000000..012361f
--- /dev/null
+++ b/test/random-test.coffee
@@ -0,0 +1,16 @@
+require 'es6-shim'
+vows = require 'vows'
+assert = require 'assert'
+chroma = require '../chroma'
+
+
+vows
+    .describe('Some tests for random colors')
+
+    .addBatch
+
+        'random colors':
+            topic: chroma.random()
+            'valid hex code': (topic) -> assert /^#[0-9a-f]{6}$/i.test(topic.hex())
+
+    .export(module)
diff --git a/test/scales-test.coffee b/test/scales-test.coffee
new file mode 100644
index 0000000..efa7bdc
--- /dev/null
+++ b/test/scales-test.coffee
@@ -0,0 +1,140 @@
+require 'es6-shim'
+vows = require 'vows'
+assert = require 'assert'
+chroma = require '../chroma'
+
+
+vows
+    .describe('Some tests for chroma.scale()')
+
+    .addBatch
+
+        'simple rgb scale (white-->black)':
+            topic:
+                f: chroma.scale ['white','black']
+            'starts white': (topic) -> assert.equal topic.f(0).hex(), '#ffffff'
+            'mid gray': (topic) -> assert.equal topic.f(0.5).hex(), '#7f7f7f'
+            'ends black': (topic) -> assert.equal topic.f(1).hex(), '#000000'
+
+        'simple hsv scale (white-->black)':
+            topic:
+                f: chroma.scale(['white','black']).mode('hsv')
+            'starts white': (topic) -> assert.equal topic.f(0).hex(), '#ffffff'
+            'mid gray': (topic) -> assert.equal topic.f(0.5).hex(), '#808080'
+            'ends black': (topic) -> assert.equal topic.f(1).hex(), '#000000'
+            'colors': (topic) -> assert.deepEqual topic.f.colors(), ['#ffffff', '#000000']
+
+        'simple hsv scale (white-->black), classified':
+            topic:
+                f: chroma.scale(['white','black']).classes(7).mode('hsv')
+            'starts white': (topic) -> assert.equal topic.f(0).hex(), '#ffffff'
+            'mid gray': (topic) -> assert.equal topic.f(0.5).hex(), '#808080'
+            'ends black': (topic) -> assert.equal topic.f(1).hex(), '#000000'
+            'colors': (topic) -> assert.deepEqual topic.f.colors(7), ['#ffffff', '#d5d5d5', '#aaaaaa', '#808080', '#555555', '#2a2a2a', '#000000']
+
+        'simple lab scale (white-->black)':
+            topic:
+                f: chroma.scale(['white','black']).mode('lab')
+            'starts white': (topic) -> assert.equal topic.f(0).hex(), '#ffffff'
+            'mid gray': (topic) -> assert.equal topic.f(0.5).hex(), '#777777'
+            'ends black': (topic) -> assert.equal topic.f(1).hex(), '#000000'
+
+        'colorbrewer scale':
+            topic:
+                f: chroma.scale 'RdYlGn'
+            'starts white': (topic) -> assert.equal topic.f(0).hex(), '#a50026'
+            'mid gray': (topic) -> assert.equal topic.f(0.5).hex(), '#ffffbf'
+            'ends black': (topic) -> assert.equal topic.f(1).hex(), '#006837'
+
+        'colorbrewer scale - domained':
+            topic:
+                f: chroma.scale('RdYlGn').domain([0, 100])
+            'starts white': (topic) -> assert.equal topic.f(0).hex(), '#a50026'
+            'foo': (topic) -> assert.notEqual topic.f(10).hex(), '#ffffbf'
+            'mid gray': (topic) -> assert.equal topic.f(50).hex(), '#ffffbf'
+            'ends black': (topic) -> assert.equal topic.f(100).hex(), '#006837'
+
+        'colorbrewer scale - domained - classified':
+            topic:
+                f: chroma.scale('RdYlGn').domain([0, 100]).classes(5)
+            'starts white': (topic) -> assert.equal topic.f(0).hex(), '#a50026'
+            '10': (topic) -> assert.equal topic.f(10).hex(), '#a50026'
+            'mid gray': (topic) -> assert.equal topic.f(50).hex(), '#ffffbf'
+            'ends black': (topic) -> assert.equal topic.f(100).hex(), '#006837'
+            'get colors': (topic) -> assert.deepEqual topic.f.colors(5), ['#a50026', '#f88d52', '#ffffbf', '#86cb66', '#006837']
+
+        'calling domain with no arguments':
+            topic:
+                f: chroma.scale('RdYlGn').domain([0, 100]).classes(5)
+            'returns domain': (topic) -> assert.deepEqual topic.f.domain(), [0, 100]
+            'returns classes': (topic) -> assert.deepEqual topic.f.classes(), [0, 20, 40, 60, 80, 100]
+
+        'source array keeps untouched':
+            topic: chroma.brewer.Blues.slice(0)
+            'colors are an array': (colors) ->
+                assert.equal colors.length, 9
+            'colors are strings': (colors) ->
+                assert.equal typeof colors[0], 'string'
+            'creating a color scale': (colors) ->
+                chroma.scale(colors)
+                assert true
+            'colors are still strings': (colors) ->
+                assert.equal typeof colors[0], 'string'
+
+
+        'domain with same min and max':
+            topic:
+                f: chroma.scale(['white','black']).domain([1, 1])
+            'returns color': (topic) -> assert.deepEqual topic.f(1).hex(), '#000000'
+
+        'simple num scale (white-->black)':
+            topic:
+                f: chroma.scale(['white','black']).mode('num')
+            'starts white': (topic) -> assert.equal topic.f(0).hex(), '#ffffff'
+            '25%': (topic) -> assert.equal topic.f(0.25).hex(), '#bfffff'
+            '50%': (topic) -> assert.equal topic.f(0.5).hex(), '#7fffff'
+            '75%': (topic) -> assert.equal topic.f(0.75).hex(), '#3fffff'
+            '95%': (topic) -> assert.equal topic.f(0.95).hex(), '#0ccccc'
+            'ends black': (topic) -> assert.equal topic.f(1).hex(), '#000000'
+
+        'css rgb colors':
+            topic: chroma.scale("YlGnBu")(0.3).css()
+            'have rounded rgb() values': (topic) -> assert.equal topic, 'rgb(170,222,183)'
+
+        'css rgba colors':
+            topic: chroma.scale("YlGnBu")(0.3).alpha(0.675).css()
+            'dont round alpha value': (topic) -> assert.equal topic, 'rgba(170,222,183,0.675)'
+
+        'get colors from a scale':
+            topic: 
+                f: chroma.scale(['yellow','darkgreen'])
+            'just colors': (topic) -> assert.deepEqual topic.f.colors(), ['#ffff00', '#006400']
+            'five hex colors': (topic) -> assert.deepEqual topic.f.colors(5), ['#ffff00', '#bfd800', '#7fb100', '#3f8a00', '#006400']
+            'three css colors': (topic) -> assert.deepEqual topic.f.colors(3,'css'), ['rgb(255,255,0)', 'rgb(128,178,0)', 'rgb(0,100,0)' ]
+
+        'test example in readme':
+            topic: 
+                f: chroma.scale('RdYlGn')
+            'five hex colors (new)': (topic) -> assert.deepEqual topic.f.colors(5),           ['#a50026', '#f88d52', '#ffffbf', '#86cb66', '#006837']
+
+        'weird result':
+            topic:
+                f: chroma.scale([[ 0, 0, 0, 1 ], [ 255, 255, 255, 1 ]]).domain([0,10]).mode('rgb')
+            'has hex function at 0.5': (topic) -> assert.equal typeof topic.f(0.5).hex, 'function' 
+            'has hex function at 0': (topic) -> assert.equal typeof topic.f(0).hex, 'function' 
+
+        'scale padding, simple':
+            topic:
+                f: chroma.scale('RdYlBu').padding(0.15)
+            '0': (topic) -> assert.equal topic.f(0).hex(), '#e54e35'
+            '0.5': (topic) -> assert.equal topic.f(0.5).hex(), '#ffffbf'
+            '1': (topic) -> assert.equal topic.f(1).hex(), '#5c91c2'
+
+        'scale padding, one-sided':
+            topic:
+                f: chroma.scale('OrRd').padding([0.2, 0])
+            '0': (topic) -> assert.equal topic.f(0).hex(), '#fddcae'
+            '0.5': (topic) -> assert.equal topic.f(0.5).hex(), '#f16c4b'
+            '1': (topic) -> assert.equal topic.f(1).hex(), '#7f0000'
+
+    .export(module)
\ No newline at end of file
diff --git a/test/set-test.coffee b/test/set-test.coffee
new file mode 100644
index 0000000..79a71e4
--- /dev/null
+++ b/test/set-test.coffee
@@ -0,0 +1,15 @@
+require 'es6-shim'
+vows = require 'vows'
+assert = require 'assert'
+chroma = require '../chroma'
+
+vows
+    .describe('Testing color.set')
+    .addBatch
+        'set hue':
+            topic: chroma 'hotpink'
+            'hue not zero': (topic) -> assert.equal topic.hsl()[0], 330
+            'hue zero': (topic) -> assert.equal topic.set('hsl.h', 0).hsl()[0], 0
+
+
+    .export(module)
diff --git a/test/temperature-test.coffee b/test/temperature-test.coffee
new file mode 100644
index 0000000..cfc4c55
--- /dev/null
+++ b/test/temperature-test.coffee
@@ -0,0 +1,29 @@
+require 'es6-shim'
+vows = require 'vows'
+assert = require 'assert'
+chroma = require '../chroma'
+
+
+vows
+    .describe('Testing color temperature')
+
+    .addBatch
+
+        'generate colors by temperatures':
+            topic: [4000,5000,10000,20000,30000,1000]
+            '1k': (t) -> assert.equal chroma.kelvin(t[5]).hex(), '#ff3a00'
+            '4k': (t) -> assert.equal chroma.kelvin(t[0]).hex(), '#ffcfa3'
+            '5k': (t) -> assert.equal chroma.kelvin(t[1]).hex(), '#ffe3cd'
+            '7k': (t) -> assert.equal chroma.kelvin(t[1]).hex(), '#ffe3cd'
+            '10k': (t) -> assert.equal chroma.kelvin(t[2]).hex(), '#cbdbff'
+            '20k': (t) -> assert.equal chroma.kelvin(t[3]).hex(), '#a8c4ff'
+            '30k': (t) -> assert.equal chroma.kelvin(t[4]).hex(), '#9ebeff'
+
+        'color --> temp':
+            topic: ['#ff3a00', 'ffcfa3', 'cbdbff', '9ebeff']
+            '1k': (t) -> assert.equal chroma(t[0]).kelvin(), 1000
+            '4k': (t) -> assert.equal chroma(t[1]).kelvin(), 3989
+            '10k': (t) -> assert.equal chroma(t[2]).kelvin(), 10115
+            '30k': (t) -> assert.equal chroma(t[3]).kelvin(), 31100
+
+    .export(module)
\ No newline at end of file
diff --git a/test/utils-test.coffee b/test/utils-test.coffee
new file mode 100644
index 0000000..3348f60
--- /dev/null
+++ b/test/utils-test.coffee
@@ -0,0 +1,23 @@
+require 'es6-shim'
+vows = require 'vows'
+assert = require 'assert'
+chroma = require '../chroma'
+
+unpack = (args) ->
+    if args.length >= 3
+        [].slice.call args
+    else
+        args[0]
+
+vows
+    .describe('Some tests for utils')
+
+    .addBatch
+
+        'unpack arguments':
+            topic: [1,2,3]
+            'unpacked from array': (t) -> assert.deepEqual unpack(t), [1,2,3]
+            'unpacked from single values': (t) -> assert.deepEqual unpack([t]), [1,2,3]
+            
+
+    .export(module)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-chroma-js.git



More information about the Pkg-javascript-commits mailing list