pax_global_header00006660000000000000000000000064135053137730014521gustar00rootroot0000000000000052 comment=8366f763b582f7b8c0eb5efc027f2b0652ec560e d3-color-1.2.8/000077500000000000000000000000001350531377300131535ustar00rootroot00000000000000d3-color-1.2.8/.eslintrc.json000066400000000000000000000003421350531377300157460ustar00rootroot00000000000000{ "extends": "eslint:recommended", "parserOptions": { "sourceType": "module", "ecmaVersion": 8 }, "env": { "es6": true, "node": true, "browser": true }, "rules": { "no-cond-assign": 0 } } d3-color-1.2.8/.gitignore000066400000000000000000000000771350531377300151470ustar00rootroot00000000000000*.sublime-workspace .DS_Store dist/ node_modules npm-debug.log d3-color-1.2.8/.npmignore000066400000000000000000000000421350531377300151460ustar00rootroot00000000000000*.sublime-* dist/*.zip img/ test/ d3-color-1.2.8/LICENSE000066400000000000000000000027031350531377300141620ustar00rootroot00000000000000Copyright 2010-2016 Mike Bostock 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. * Neither the name of the author nor the names of contributors may 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 THE COPYRIGHT OWNER 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. d3-color-1.2.8/README.md000066400000000000000000000267361350531377300144500ustar00rootroot00000000000000# d3-color Even though your browser understands a lot about colors, it doesn’t offer much help in manipulating colors through JavaScript. The d3-color module therefore provides representations for various color spaces, allowing specification, conversion and manipulation. (Also see [d3-interpolate](https://github.com/d3/d3-interpolate) for color interpolation.) For example, take the color named “steelblue”: ```js var c = d3.color("steelblue"); // {r: 70, g: 130, b: 180, opacity: 1} ``` Let’s try converting it to HSL: ```js var c = d3.hsl("steelblue"); // {h: 207.27…, s: 0.44, l: 0.4902…, opacity: 1} ``` Now rotate the hue by 90°, bump up the saturation, and format as a string for CSS: ```js c.h += 90; c.s += 0.2; c + ""; // rgb(198, 45, 205) ``` To fade the color slightly: ```js c.opacity = 0.8; c + ""; // rgba(198, 45, 205, 0.8) ``` In addition to the ubiquitous and machine-friendly [RGB](#rgb) and [HSL](#hsl) color space, d3-color supports two color spaces that are designed for humans: * Dave Green’s [Cubehelix](#cubehelix) * [Lab (CIELAB)](#lab) and [HCL (CIELCH)](#hcl) Cubehelix features monotonic lightness, while Lab and HCL are perceptually uniform. Note that HCL is the cylindrical form of Lab, similar to how HSL is the cylindrical form of RGB. For additional color spaces, see: * [d3-cam16](https://github.com/d3/d3-cam16) * [d3-cam02](https://github.com/connorgr/d3-cam02) * [d3-hsv](https://github.com/d3/d3-hsv) * [d3-hcg](https://github.com/d3/d3-hcg) ## Installing If you use NPM, `npm install d3-color`. Otherwise, download the [latest release](https://github.com/d3/d3-color/releases/latest). You can also load directly from [d3js.org](https://d3js.org), either as a [standalone library](https://d3js.org/d3-color.v1.min.js) or as part of [D3 4.0](https://github.com/d3/d3). AMD, CommonJS, and vanilla environments are supported. In vanilla, a `d3` global is exported: ```html ``` [Try d3-color in your browser.](https://tonicdev.com/npm/d3-color) ## API Reference # d3.color(specifier) [<>](https://github.com/d3/d3-color/blob/master/src/color.js "Source") Parses the specified [CSS Color Module Level 3](http://www.w3.org/TR/css3-color/#colorunits) *specifier* string, returning an [RGB](#rgb) or [HSL](#hsl) color. If the specifier was not valid, null is returned. Some examples: * `rgb(255, 255, 255)` * `rgb(10%, 20%, 30%)` * `rgba(255, 255, 255, 0.4)` * `rgba(10%, 20%, 30%, 0.4)` * `hsl(120, 50%, 20%)` * `hsla(120, 50%, 20%, 0.4)` * `#ffeeaa` * `#fea` * `steelblue` The list of supported [named colors](http://www.w3.org/TR/SVG/types.html#ColorKeywords) is specified by CSS. Note: this function may also be used with `instanceof` to test if an object is a color instance. The same is true of color subclasses, allowing you to test whether a color is in a particular color space. # *color*.opacity This color’s opacity, typically in the range [0, 1]. # *color*.rgb() [<>](https://github.com/d3/d3-color/blob/master/src/color.js "Source") Returns the [RGB equivalent](#rgb) of this color. For RGB colors, that’s `this`. # *color*.brighter([k]) [<>](https://github.com/d3/d3-color/blob/master/src/color.js "Source") Returns a brighter copy of this color. If *k* is specified, it controls how much brighter the returned color should be. If *k* is not specified, it defaults to 1. The behavior of this method is dependent on the implementing color space. # *color*.darker([k]) [<>](https://github.com/d3/d3-color/blob/master/src/color.js "Source") Returns a darker copy of this color. If *k* is specified, it controls how much darker the returned color should be. If *k* is not specified, it defaults to 1. The behavior of this method is dependent on the implementing color space. # *color*.displayable() [<>](https://github.com/d3/d3-color/blob/master/src/color.js "Source") Returns true if and only if the color is displayable on standard hardware. For example, this returns false for an RGB color if any channel value is less than zero or greater than 255 when rounded, or if the opacity is not in the range [0, 1]. # *color*.hex() [<>](https://github.com/d3/d3-color/blob/master/src/color.js "Source") Returns a hexadecimal string representing this color in RGB space, such as `#f7eaba`. If this color is not displayable, a suitable displayable color is returned instead. For example, RGB channel values greater than 255 are clamped to 255. # *color*.toString() [<>](https://github.com/d3/d3-color/blob/master/src/color.js "Source") Returns a string representing this color according to the [CSS Object Model specification](https://drafts.csswg.org/cssom/#serialize-a-css-component-value), such as `rgb(247, 234, 186)` or `rgba(247, 234, 186, 0.2)`. If this color is not displayable, a suitable displayable color is returned instead. For example, RGB channel values greater than 255 are clamped to 255. # d3.rgb(r, g, b[, opacity]) [<>](https://github.com/d3/d3-color/blob/master/src/color.js "Source")
# d3.rgb(specifier)
# d3.rgb(color)
Constructs a new [RGB](https://en.wikipedia.org/wiki/RGB_color_model) color. The channel values are exposed as `r`, `g` and `b` properties on the returned instance. Use the [RGB color picker](http://bl.ocks.org/mbostock/78d64ca7ef013b4dcf8f) to explore this color space. If *r*, *g* and *b* are specified, these represent the channel values of the returned color; an *opacity* may also be specified. If a CSS Color Module Level 3 *specifier* string is specified, it is parsed and then converted to the RGB color space. See [color](#color) for examples. If a [*color*](#color) instance is specified, it is converted to the RGB color space using [*color*.rgb](#color_rgb). Note that unlike [*color*.rgb](#color_rgb) this method *always* returns a new instance, even if *color* is already an RGB color. # d3.hsl(h, s, l[, opacity]) [<>](https://github.com/d3/d3-color/blob/master/src/color.js "Source")
# d3.hsl(specifier)
# d3.hsl(color)
Constructs a new [HSL](https://en.wikipedia.org/wiki/HSL_and_HSV) color. The channel values are exposed as `h`, `s` and `l` properties on the returned instance. Use the [HSL color picker](http://bl.ocks.org/mbostock/debaad4fcce9bcee14cf) to explore this color space. If *h*, *s* and *l* are specified, these represent the channel values of the returned color; an *opacity* may also be specified. If a CSS Color Module Level 3 *specifier* string is specified, it is parsed and then converted to the HSL color space. See [color](#color) for examples. If a [*color*](#color) instance is specified, it is converted to the RGB color space using [*color*.rgb](#color_rgb) and then converted to HSL. (Colors already in the HSL color space skip the conversion to RGB.) # d3.lab(l, a, b[, opacity]) [<>](https://github.com/d3/d3-color/blob/master/src/lab.js "Source")
# d3.lab(specifier)
# d3.lab(color)
Constructs a new [Lab](https://en.wikipedia.org/wiki/Lab_color_space#CIELAB) color. The channel values are exposed as `l`, `a` and `b` properties on the returned instance. Use the [Lab color picker](http://bl.ocks.org/mbostock/9f37cc207c0cb166921b) to explore this color space. The value of *l* is typically in the range [0, 100], while *a* and *b* are typically in [-160, +160]. If *l*, *a* and *b* are specified, these represent the channel values of the returned color; an *opacity* may also be specified. If a CSS Color Module Level 3 *specifier* string is specified, it is parsed and then converted to the Lab color space. See [color](#color) for examples. If a [*color*](#color) instance is specified, it is converted to the RGB color space using [*color*.rgb](#color_rgb) and then converted to Lab. (Colors already in the Lab color space skip the conversion to RGB, and colors in the HCL color space are converted directly to Lab.) # d3.gray(l[, opacity]) [<>](https://github.com/d3/d3-color/blob/master/src/lab.js "Source")
Constructs a new [Lab](#lab) color with the specified *l* value and *a* = *b* = 0. # d3.hcl(h, c, l[, opacity]) [<>](https://github.com/d3/d3-color/blob/master/src/lab.js "Source")
# d3.hcl(specifier)
# d3.hcl(color)
Constructs a new [HCL](https://en.wikipedia.org/wiki/HCL_color_space) color. The channel values are exposed as `h`, `c` and `l` properties on the returned instance. Use the [HCL color picker](http://bl.ocks.org/mbostock/3e115519a1b495e0bd95) to explore this color space. The value of *l* is typically in the range [0, 100], *c* is typically in [0, 230], and *h* is typically in [0, 360). If *h*, *c* and *l* are specified, these represent the channel values of the returned color; an *opacity* may also be specified. If a CSS Color Module Level 3 *specifier* string is specified, it is parsed and then converted to the HCL color space. See [color](#color) for examples. If a [*color*](#color) instance is specified, it is converted to the RGB color space using [*color*.rgb](#color_rgb) and then converted to HCL. (Colors already in the HCL color space skip the conversion to RGB, and colors in the Lab color space are converted directly to HCL.) # d3.lch(l, c, h[, opacity]) [<>](https://github.com/d3/d3-color/blob/master/src/lab.js "Source")
# d3.lch(specifier)
# d3.lch(color)
Equivalent to [d3.hcl](#hcl), but with reversed argument order. # d3.cubehelix(h, s, l[, opacity]) [<>](https://github.com/d3/d3-color/blob/master/src/cubehelix.js "Source")
# d3.cubehelix(specifier)
# d3.cubehelix(color)
Constructs a new [Cubehelix](https://www.mrao.cam.ac.uk/~dag/CUBEHELIX/) color. The channel values are exposed as `h`, `s` and `l` properties on the returned instance. Use the [Cubehelix color picker](http://bl.ocks.org/mbostock/ba8d75e45794c27168b5) to explore this color space. If *h*, *s* and *l* are specified, these represent the channel values of the returned color; an *opacity* may also be specified. If a CSS Color Module Level 3 *specifier* string is specified, it is parsed and then converted to the Cubehelix color space. See [color](#color) for examples. If a [*color*](#color) instance is specified, it is converted to the RGB color space using [*color*.rgb](#color_rgb) and then converted to Cubehelix. (Colors already in the Cubehelix color space skip the conversion to RGB.) d3-color-1.2.8/d3-color.sublime-project000066400000000000000000000005241350531377300176240ustar00rootroot00000000000000{ "folders": [ { "path": ".", "file_exclude_patterns": ["*.sublime-workspace"], "folder_exclude_patterns": ["dist"] } ], "build_systems": [ { "name": "yarn test", "cmd": ["yarn", "test"], "file_regex": "\\((...*?):([0-9]*):([0-9]*)\\)", "working_dir": "$project_path" } ] } d3-color-1.2.8/package.json000066400000000000000000000030011350531377300154330ustar00rootroot00000000000000{ "name": "d3-color", "version": "1.2.8", "description": "Color spaces! RGB, HSL, Cubehelix, Lab and HCL (Lch).", "keywords": [ "d3", "d3-module", "color", "rgb", "hsl", "lab", "hcl", "lch", "cubehelix" ], "homepage": "https://d3js.org/d3-color/", "license": "BSD-3-Clause", "author": { "name": "Mike Bostock", "url": "http://bost.ocks.org/mike" }, "main": "dist/d3-color.js", "unpkg": "dist/d3-color.min.js", "jsdelivr": "dist/d3-color.min.js", "module": "src/index.js", "repository": { "type": "git", "url": "https://github.com/d3/d3-color.git" }, "scripts": { "pretest": "rollup -c", "test": "tape 'test/**/*-test.js' && eslint src test", "prepublishOnly": "rm -rf dist && yarn test", "postpublish": "git push && git push --tags && cd ../d3.github.com && git pull && cp ../${npm_package_name}/dist/${npm_package_name}.js ${npm_package_name}.v${npm_package_version%%.*}.js && cp ../${npm_package_name}/dist/${npm_package_name}.min.js ${npm_package_name}.v${npm_package_version%%.*}.min.js && git add ${npm_package_name}.v${npm_package_version%%.*}.js ${npm_package_name}.v${npm_package_version%%.*}.min.js && git commit -m \"${npm_package_name} ${npm_package_version}\" && git push && cd - && zip -j dist/${npm_package_name}.zip -- LICENSE README.md dist/${npm_package_name}.js dist/${npm_package_name}.min.js" }, "devDependencies": { "eslint": "5", "rollup": "0.64", "rollup-plugin-terser": "1", "tape": "4" } } d3-color-1.2.8/rollup.config.js000066400000000000000000000015451350531377300162770ustar00rootroot00000000000000import {terser} from "rollup-plugin-terser"; import * as meta from "./package.json"; const config = { input: "src/index.js", external: Object.keys(meta.dependencies || {}).filter(key => /^d3-/.test(key)), output: { file: `dist/${meta.name}.js`, name: "d3", format: "umd", indent: false, extend: true, banner: `// ${meta.homepage} v${meta.version} Copyright ${(new Date).getFullYear()} ${meta.author.name}`, globals: Object.assign({}, ...Object.keys(meta.dependencies || {}).filter(key => /^d3-/.test(key)).map(key => ({[key]: "d3"}))) }, plugins: [] }; export default [ config, { ...config, output: { ...config.output, file: `dist/${meta.name}.min.js` }, plugins: [ ...config.plugins, terser({ output: { preamble: config.output.banner } }) ] } ]; d3-color-1.2.8/src/000077500000000000000000000000001350531377300137425ustar00rootroot00000000000000d3-color-1.2.8/src/color.js000066400000000000000000000225371350531377300154270ustar00rootroot00000000000000import define, {extend} from "./define"; export function Color() {} export var darker = 0.7; export var brighter = 1 / darker; var reI = "\\s*([+-]?\\d+)\\s*", reN = "\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\s*", reP = "\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)%\\s*", reHex3 = /^#([0-9a-f]{3})$/, reHex6 = /^#([0-9a-f]{6})$/, reRgbInteger = new RegExp("^rgb\\(" + [reI, reI, reI] + "\\)$"), reRgbPercent = new RegExp("^rgb\\(" + [reP, reP, reP] + "\\)$"), reRgbaInteger = new RegExp("^rgba\\(" + [reI, reI, reI, reN] + "\\)$"), reRgbaPercent = new RegExp("^rgba\\(" + [reP, reP, reP, reN] + "\\)$"), reHslPercent = new RegExp("^hsl\\(" + [reN, reP, reP] + "\\)$"), reHslaPercent = new RegExp("^hsla\\(" + [reN, reP, reP, reN] + "\\)$"); var named = { aliceblue: 0xf0f8ff, antiquewhite: 0xfaebd7, aqua: 0x00ffff, aquamarine: 0x7fffd4, azure: 0xf0ffff, beige: 0xf5f5dc, bisque: 0xffe4c4, black: 0x000000, blanchedalmond: 0xffebcd, blue: 0x0000ff, blueviolet: 0x8a2be2, brown: 0xa52a2a, burlywood: 0xdeb887, cadetblue: 0x5f9ea0, chartreuse: 0x7fff00, chocolate: 0xd2691e, coral: 0xff7f50, cornflowerblue: 0x6495ed, cornsilk: 0xfff8dc, crimson: 0xdc143c, cyan: 0x00ffff, darkblue: 0x00008b, darkcyan: 0x008b8b, darkgoldenrod: 0xb8860b, darkgray: 0xa9a9a9, darkgreen: 0x006400, darkgrey: 0xa9a9a9, darkkhaki: 0xbdb76b, darkmagenta: 0x8b008b, darkolivegreen: 0x556b2f, darkorange: 0xff8c00, darkorchid: 0x9932cc, darkred: 0x8b0000, darksalmon: 0xe9967a, darkseagreen: 0x8fbc8f, darkslateblue: 0x483d8b, darkslategray: 0x2f4f4f, darkslategrey: 0x2f4f4f, darkturquoise: 0x00ced1, darkviolet: 0x9400d3, deeppink: 0xff1493, deepskyblue: 0x00bfff, dimgray: 0x696969, dimgrey: 0x696969, dodgerblue: 0x1e90ff, firebrick: 0xb22222, floralwhite: 0xfffaf0, forestgreen: 0x228b22, fuchsia: 0xff00ff, gainsboro: 0xdcdcdc, ghostwhite: 0xf8f8ff, gold: 0xffd700, goldenrod: 0xdaa520, gray: 0x808080, green: 0x008000, greenyellow: 0xadff2f, grey: 0x808080, honeydew: 0xf0fff0, hotpink: 0xff69b4, indianred: 0xcd5c5c, indigo: 0x4b0082, ivory: 0xfffff0, khaki: 0xf0e68c, lavender: 0xe6e6fa, lavenderblush: 0xfff0f5, lawngreen: 0x7cfc00, lemonchiffon: 0xfffacd, lightblue: 0xadd8e6, lightcoral: 0xf08080, lightcyan: 0xe0ffff, lightgoldenrodyellow: 0xfafad2, lightgray: 0xd3d3d3, lightgreen: 0x90ee90, lightgrey: 0xd3d3d3, lightpink: 0xffb6c1, lightsalmon: 0xffa07a, lightseagreen: 0x20b2aa, lightskyblue: 0x87cefa, lightslategray: 0x778899, lightslategrey: 0x778899, lightsteelblue: 0xb0c4de, lightyellow: 0xffffe0, lime: 0x00ff00, limegreen: 0x32cd32, linen: 0xfaf0e6, magenta: 0xff00ff, maroon: 0x800000, mediumaquamarine: 0x66cdaa, mediumblue: 0x0000cd, mediumorchid: 0xba55d3, mediumpurple: 0x9370db, mediumseagreen: 0x3cb371, mediumslateblue: 0x7b68ee, mediumspringgreen: 0x00fa9a, mediumturquoise: 0x48d1cc, mediumvioletred: 0xc71585, midnightblue: 0x191970, mintcream: 0xf5fffa, mistyrose: 0xffe4e1, moccasin: 0xffe4b5, navajowhite: 0xffdead, navy: 0x000080, oldlace: 0xfdf5e6, olive: 0x808000, olivedrab: 0x6b8e23, orange: 0xffa500, orangered: 0xff4500, orchid: 0xda70d6, palegoldenrod: 0xeee8aa, palegreen: 0x98fb98, paleturquoise: 0xafeeee, palevioletred: 0xdb7093, papayawhip: 0xffefd5, peachpuff: 0xffdab9, peru: 0xcd853f, pink: 0xffc0cb, plum: 0xdda0dd, powderblue: 0xb0e0e6, purple: 0x800080, rebeccapurple: 0x663399, red: 0xff0000, rosybrown: 0xbc8f8f, royalblue: 0x4169e1, saddlebrown: 0x8b4513, salmon: 0xfa8072, sandybrown: 0xf4a460, seagreen: 0x2e8b57, seashell: 0xfff5ee, sienna: 0xa0522d, silver: 0xc0c0c0, skyblue: 0x87ceeb, slateblue: 0x6a5acd, slategray: 0x708090, slategrey: 0x708090, snow: 0xfffafa, springgreen: 0x00ff7f, steelblue: 0x4682b4, tan: 0xd2b48c, teal: 0x008080, thistle: 0xd8bfd8, tomato: 0xff6347, turquoise: 0x40e0d0, violet: 0xee82ee, wheat: 0xf5deb3, white: 0xffffff, whitesmoke: 0xf5f5f5, yellow: 0xffff00, yellowgreen: 0x9acd32 }; define(Color, color, { displayable: function() { return this.rgb().displayable(); }, hex: function() { return this.rgb().hex(); }, toString: function() { return this.rgb() + ""; } }); export default function color(format) { var m; format = (format + "").trim().toLowerCase(); return (m = reHex3.exec(format)) ? (m = parseInt(m[1], 16), new Rgb((m >> 8 & 0xf) | (m >> 4 & 0x0f0), (m >> 4 & 0xf) | (m & 0xf0), ((m & 0xf) << 4) | (m & 0xf), 1)) // #f00 : (m = reHex6.exec(format)) ? rgbn(parseInt(m[1], 16)) // #ff0000 : (m = reRgbInteger.exec(format)) ? new Rgb(m[1], m[2], m[3], 1) // rgb(255, 0, 0) : (m = reRgbPercent.exec(format)) ? new Rgb(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, 1) // rgb(100%, 0%, 0%) : (m = reRgbaInteger.exec(format)) ? rgba(m[1], m[2], m[3], m[4]) // rgba(255, 0, 0, 1) : (m = reRgbaPercent.exec(format)) ? rgba(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, m[4]) // rgb(100%, 0%, 0%, 1) : (m = reHslPercent.exec(format)) ? hsla(m[1], m[2] / 100, m[3] / 100, 1) // hsl(120, 50%, 50%) : (m = reHslaPercent.exec(format)) ? hsla(m[1], m[2] / 100, m[3] / 100, m[4]) // hsla(120, 50%, 50%, 1) : named.hasOwnProperty(format) ? rgbn(named[format]) : format === "transparent" ? new Rgb(NaN, NaN, NaN, 0) : null; } function rgbn(n) { return new Rgb(n >> 16 & 0xff, n >> 8 & 0xff, n & 0xff, 1); } function rgba(r, g, b, a) { if (a <= 0) r = g = b = NaN; return new Rgb(r, g, b, a); } export function rgbConvert(o) { if (!(o instanceof Color)) o = color(o); if (!o) return new Rgb; o = o.rgb(); return new Rgb(o.r, o.g, o.b, o.opacity); } export function rgb(r, g, b, opacity) { return arguments.length === 1 ? rgbConvert(r) : new Rgb(r, g, b, opacity == null ? 1 : opacity); } export function Rgb(r, g, b, opacity) { this.r = +r; this.g = +g; this.b = +b; this.opacity = +opacity; } define(Rgb, rgb, extend(Color, { brighter: function(k) { k = k == null ? brighter : Math.pow(brighter, k); return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity); }, darker: function(k) { k = k == null ? darker : Math.pow(darker, k); return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity); }, rgb: function() { return this; }, displayable: function() { return (-0.5 <= this.r && this.r < 255.5) && (-0.5 <= this.g && this.g < 255.5) && (-0.5 <= this.b && this.b < 255.5) && (0 <= this.opacity && this.opacity <= 1); }, hex: function() { return "#" + hex(this.r) + hex(this.g) + hex(this.b); }, toString: function() { var a = this.opacity; a = isNaN(a) ? 1 : Math.max(0, Math.min(1, a)); return (a === 1 ? "rgb(" : "rgba(") + Math.max(0, Math.min(255, Math.round(this.r) || 0)) + ", " + Math.max(0, Math.min(255, Math.round(this.g) || 0)) + ", " + Math.max(0, Math.min(255, Math.round(this.b) || 0)) + (a === 1 ? ")" : ", " + a + ")"); } })); function hex(value) { value = Math.max(0, Math.min(255, Math.round(value) || 0)); return (value < 16 ? "0" : "") + value.toString(16); } function hsla(h, s, l, a) { if (a <= 0) h = s = l = NaN; else if (l <= 0 || l >= 1) h = s = NaN; else if (s <= 0) h = NaN; return new Hsl(h, s, l, a); } export function hslConvert(o) { if (o instanceof Hsl) return new Hsl(o.h, o.s, o.l, o.opacity); if (!(o instanceof Color)) o = color(o); if (!o) return new Hsl; if (o instanceof Hsl) return o; o = o.rgb(); var r = o.r / 255, g = o.g / 255, b = o.b / 255, min = Math.min(r, g, b), max = Math.max(r, g, b), h = NaN, s = max - min, l = (max + min) / 2; if (s) { if (r === max) h = (g - b) / s + (g < b) * 6; else if (g === max) h = (b - r) / s + 2; else h = (r - g) / s + 4; s /= l < 0.5 ? max + min : 2 - max - min; h *= 60; } else { s = l > 0 && l < 1 ? 0 : h; } return new Hsl(h, s, l, o.opacity); } export function hsl(h, s, l, opacity) { return arguments.length === 1 ? hslConvert(h) : new Hsl(h, s, l, opacity == null ? 1 : opacity); } function Hsl(h, s, l, opacity) { this.h = +h; this.s = +s; this.l = +l; this.opacity = +opacity; } define(Hsl, hsl, extend(Color, { brighter: function(k) { k = k == null ? brighter : Math.pow(brighter, k); return new Hsl(this.h, this.s, this.l * k, this.opacity); }, darker: function(k) { k = k == null ? darker : Math.pow(darker, k); return new Hsl(this.h, this.s, this.l * k, this.opacity); }, rgb: function() { var h = this.h % 360 + (this.h < 0) * 360, s = isNaN(h) || isNaN(this.s) ? 0 : this.s, l = this.l, m2 = l + (l < 0.5 ? l : 1 - l) * s, m1 = 2 * l - m2; return new Rgb( hsl2rgb(h >= 240 ? h - 240 : h + 120, m1, m2), hsl2rgb(h, m1, m2), hsl2rgb(h < 120 ? h + 240 : h - 120, m1, m2), this.opacity ); }, displayable: function() { return (0 <= this.s && this.s <= 1 || isNaN(this.s)) && (0 <= this.l && this.l <= 1) && (0 <= this.opacity && this.opacity <= 1); } })); /* From FvD 13.37, CSS Color Module Level 3 */ function hsl2rgb(h, m1, m2) { return (h < 60 ? m1 + (m2 - m1) * h / 60 : h < 180 ? m2 : h < 240 ? m1 + (m2 - m1) * (240 - h) / 60 : m1) * 255; } d3-color-1.2.8/src/cubehelix.js000066400000000000000000000034771350531377300162630ustar00rootroot00000000000000import define, {extend} from "./define"; import {Color, rgbConvert, Rgb, darker, brighter} from "./color"; import {deg2rad, rad2deg} from "./math"; var A = -0.14861, B = +1.78277, C = -0.29227, D = -0.90649, E = +1.97294, ED = E * D, EB = E * B, BC_DA = B * C - D * A; function cubehelixConvert(o) { if (o instanceof Cubehelix) return new Cubehelix(o.h, o.s, o.l, o.opacity); if (!(o instanceof Rgb)) o = rgbConvert(o); var r = o.r / 255, g = o.g / 255, b = o.b / 255, l = (BC_DA * b + ED * r - EB * g) / (BC_DA + ED - EB), bl = b - l, k = (E * (g - l) - C * bl) / D, s = Math.sqrt(k * k + bl * bl) / (E * l * (1 - l)), // NaN if l=0 or l=1 h = s ? Math.atan2(k, bl) * rad2deg - 120 : NaN; return new Cubehelix(h < 0 ? h + 360 : h, s, l, o.opacity); } export default function cubehelix(h, s, l, opacity) { return arguments.length === 1 ? cubehelixConvert(h) : new Cubehelix(h, s, l, opacity == null ? 1 : opacity); } export function Cubehelix(h, s, l, opacity) { this.h = +h; this.s = +s; this.l = +l; this.opacity = +opacity; } define(Cubehelix, cubehelix, extend(Color, { brighter: function(k) { k = k == null ? brighter : Math.pow(brighter, k); return new Cubehelix(this.h, this.s, this.l * k, this.opacity); }, darker: function(k) { k = k == null ? darker : Math.pow(darker, k); return new Cubehelix(this.h, this.s, this.l * k, this.opacity); }, rgb: function() { var h = isNaN(this.h) ? 0 : (this.h + 120) * deg2rad, l = +this.l, a = isNaN(this.s) ? 0 : this.s * l * (1 - l), cosh = Math.cos(h), sinh = Math.sin(h); return new Rgb( 255 * (l + a * (A * cosh + B * sinh)), 255 * (l + a * (C * cosh + D * sinh)), 255 * (l + a * (E * cosh)), this.opacity ); } })); d3-color-1.2.8/src/define.js000066400000000000000000000005241350531377300155330ustar00rootroot00000000000000export default function(constructor, factory, prototype) { constructor.prototype = factory.prototype = prototype; prototype.constructor = constructor; } export function extend(parent, definition) { var prototype = Object.create(parent.prototype); for (var key in definition) prototype[key] = definition[key]; return prototype; } d3-color-1.2.8/src/index.js000066400000000000000000000002341350531377300154060ustar00rootroot00000000000000export {default as color, rgb, hsl} from "./color"; export {default as lab, hcl, lch, gray} from "./lab"; export {default as cubehelix} from "./cubehelix"; d3-color-1.2.8/src/lab.js000066400000000000000000000071041350531377300150400ustar00rootroot00000000000000import define, {extend} from "./define"; import {Color, rgbConvert, Rgb} from "./color"; import {deg2rad, rad2deg} from "./math"; // https://observablehq.com/@mbostock/lab-and-rgb var K = 18, Xn = 0.96422, Yn = 1, Zn = 0.82521, t0 = 4 / 29, t1 = 6 / 29, t2 = 3 * t1 * t1, t3 = t1 * t1 * t1; function labConvert(o) { if (o instanceof Lab) return new Lab(o.l, o.a, o.b, o.opacity); if (o instanceof Hcl) return hcl2lab(o); if (!(o instanceof Rgb)) o = rgbConvert(o); var r = rgb2lrgb(o.r), g = rgb2lrgb(o.g), b = rgb2lrgb(o.b), y = xyz2lab((0.2225045 * r + 0.7168786 * g + 0.0606169 * b) / Yn), x, z; if (r === g && g === b) x = z = y; else { x = xyz2lab((0.4360747 * r + 0.3850649 * g + 0.1430804 * b) / Xn); z = xyz2lab((0.0139322 * r + 0.0971045 * g + 0.7141733 * b) / Zn); } return new Lab(116 * y - 16, 500 * (x - y), 200 * (y - z), o.opacity); } export function gray(l, opacity) { return new Lab(l, 0, 0, opacity == null ? 1 : opacity); } export default function lab(l, a, b, opacity) { return arguments.length === 1 ? labConvert(l) : new Lab(l, a, b, opacity == null ? 1 : opacity); } export function Lab(l, a, b, opacity) { this.l = +l; this.a = +a; this.b = +b; this.opacity = +opacity; } define(Lab, lab, extend(Color, { brighter: function(k) { return new Lab(this.l + K * (k == null ? 1 : k), this.a, this.b, this.opacity); }, darker: function(k) { return new Lab(this.l - K * (k == null ? 1 : k), this.a, this.b, this.opacity); }, rgb: function() { var y = (this.l + 16) / 116, x = isNaN(this.a) ? y : y + this.a / 500, z = isNaN(this.b) ? y : y - this.b / 200; x = Xn * lab2xyz(x); y = Yn * lab2xyz(y); z = Zn * lab2xyz(z); return new Rgb( lrgb2rgb( 3.1338561 * x - 1.6168667 * y - 0.4906146 * z), lrgb2rgb(-0.9787684 * x + 1.9161415 * y + 0.0334540 * z), lrgb2rgb( 0.0719453 * x - 0.2289914 * y + 1.4052427 * z), this.opacity ); } })); function xyz2lab(t) { return t > t3 ? Math.pow(t, 1 / 3) : t / t2 + t0; } function lab2xyz(t) { return t > t1 ? t * t * t : t2 * (t - t0); } function lrgb2rgb(x) { return 255 * (x <= 0.0031308 ? 12.92 * x : 1.055 * Math.pow(x, 1 / 2.4) - 0.055); } function rgb2lrgb(x) { return (x /= 255) <= 0.04045 ? x / 12.92 : Math.pow((x + 0.055) / 1.055, 2.4); } function hclConvert(o) { if (o instanceof Hcl) return new Hcl(o.h, o.c, o.l, o.opacity); if (!(o instanceof Lab)) o = labConvert(o); if (o.a === 0 && o.b === 0) return new Hcl(NaN, 0 < o.l && o.l < 100 ? 0 : NaN, o.l, o.opacity); var h = Math.atan2(o.b, o.a) * rad2deg; return new Hcl(h < 0 ? h + 360 : h, Math.sqrt(o.a * o.a + o.b * o.b), o.l, o.opacity); } export function lch(l, c, h, opacity) { return arguments.length === 1 ? hclConvert(l) : new Hcl(h, c, l, opacity == null ? 1 : opacity); } export function hcl(h, c, l, opacity) { return arguments.length === 1 ? hclConvert(h) : new Hcl(h, c, l, opacity == null ? 1 : opacity); } export function Hcl(h, c, l, opacity) { this.h = +h; this.c = +c; this.l = +l; this.opacity = +opacity; } function hcl2lab(o) { if (isNaN(o.h)) return new Lab(o.l, 0, 0, o.opacity); var h = o.h * deg2rad; return new Lab(o.l, Math.cos(h) * o.c, Math.sin(h) * o.c, o.opacity); } define(Hcl, hcl, extend(Color, { brighter: function(k) { return new Hcl(this.h, this.c, this.l + K * (k == null ? 1 : k), this.opacity); }, darker: function(k) { return new Hcl(this.h, this.c, this.l - K * (k == null ? 1 : k), this.opacity); }, rgb: function() { return hcl2lab(this).rgb(); } })); d3-color-1.2.8/src/math.js000066400000000000000000000001101350531377300152210ustar00rootroot00000000000000export var deg2rad = Math.PI / 180; export var rad2deg = 180 / Math.PI; d3-color-1.2.8/test/000077500000000000000000000000001350531377300141325ustar00rootroot00000000000000d3-color-1.2.8/test/color-test.js000066400000000000000000000157551350531377300166000ustar00rootroot00000000000000var tape = require("tape"), color = require("../"); require("./rgbEqual"); require("./hslEqual"); tape("color(format) parses CSS color names (e.g., \"rebeccapurple\")", function(test) { test.rgbEqual(color.color("moccasin"), 255, 228, 181, 1); test.rgbEqual(color.color("aliceblue"), 240, 248, 255, 1); test.rgbEqual(color.color("yellow"), 255, 255, 0, 1); test.rgbEqual(color.color("moccasin"), 255, 228, 181, 1); test.rgbEqual(color.color("aliceblue"), 240, 248, 255, 1); test.rgbEqual(color.color("yellow"), 255, 255, 0, 1); test.rgbEqual(color.color("rebeccapurple"), 102, 51, 153, 1); test.rgbEqual(color.color("transparent"), NaN, NaN, NaN, 0); test.end(); }); tape("color(format) parses 6-digit hexadecimal (e.g., \"#abcdef\")", function(test) { test.rgbEqual(color.color("#abcdef"), 171, 205, 239, 1); test.end(); }); tape("color(format) parses 3-digit hexadecimal (e.g., \"#abc\")", function(test) { test.rgbEqual(color.color("#abc"), 170, 187, 204, 1); test.end(); }); tape("color(format) parses RGB integer format (e.g., \"rgb(12,34,56)\")", function(test) { test.rgbEqual(color.color("rgb(12,34,56)"), 12, 34, 56, 1); test.end(); }); tape("color(format) parses RGBA integer format (e.g., \"rgba(12,34,56,0.4)\")", function(test) { test.rgbEqual(color.color("rgba(12,34,56,0.4)"), 12, 34, 56, 0.4); test.end(); }); tape("color(format) parses RGB percentage format (e.g., \"rgb(12%,34%,56%)\")", function(test) { test.rgbEqual(color.color("rgb(12%,34%,56%)"), 31, 87, 143, 1); test.rgbStrictEqual(color.color("rgb(100%,100%,100%)"), 255, 255, 255, 1); test.end(); }); tape("color(format) parses RGBA percentage format (e.g., \"rgba(12%,34%,56%,0.4)\")", function(test) { test.rgbEqual(color.color("rgba(12%,34%,56%,0.4)"), 31, 87, 143, 0.4); test.rgbStrictEqual(color.color("rgba(100%,100%,100%,0.4)"), 255, 255, 255, 0.4); test.end(); }); tape("color(format) parses HSL format (e.g., \"hsl(60,100%,20%)\")", function(test) { test.hslEqual(color.color("hsl(60,100%,20%)"), 60, 1, 0.2, 1); test.end(); }); tape("color(format) parses HSLA format (e.g., \"hsla(60,100%,20%,0.4)\")", function(test) { test.hslEqual(color.color("hsla(60,100%,20%,0.4)"), 60, 1, 0.2, 0.4); test.end(); }); tape("color(format) ignores leading and trailing whitespace", function(test) { test.rgbEqual(color.color(" aliceblue\t\n"), 240, 248, 255, 1); test.rgbEqual(color.color(" #abc\t\n"), 170, 187, 204, 1); test.rgbEqual(color.color(" #aabbcc\t\n"), 170, 187, 204, 1); test.rgbEqual(color.color(" rgb(120,30,50)\t\n"), 120, 30, 50, 1); test.hslEqual(color.color(" hsl(120,30%,50%)\t\n"), 120, 0.3, 0.5, 1); test.end(); }); tape("color(format) ignores whitespace between numbers", function(test) { test.rgbEqual(color.color(" rgb( 120 , 30 , 50 ) "), 120, 30, 50, 1); test.hslEqual(color.color(" hsl( 120 , 30% , 50% ) "), 120, 0.3, 0.5, 1); test.rgbEqual(color.color(" rgba( 12 , 34 , 56 , 0.4 ) "), 12, 34, 56, 0.4); test.rgbEqual(color.color(" rgba( 12% , 34% , 56% , 0.4 ) "), 31, 87, 143, 0.4); test.hslEqual(color.color(" hsla( 60 , 100% , 20% , 0.4 ) "), 60, 1, 0.2, 0.4); test.end(); }); tape("color(format) allows number signs", function(test) { test.rgbEqual(color.color("rgb(+120,+30,+50)"), 120, 30, 50, 1); test.hslEqual(color.color("hsl(+120,+30%,+50%)"), 120, 0.3, 0.5, 1); test.rgbEqual(color.color("rgb(-120,-30,-50)"), -120, -30, -50, 1); test.hslEqual(color.color("hsl(-120,-30%,-50%)"), NaN, NaN, -0.5, 1); test.rgbEqual(color.color("rgba(12,34,56,+0.4)"), 12, 34, 56, 0.4); test.rgbEqual(color.color("rgba(12,34,56,-0.4)"), NaN, NaN, NaN, -0.4); test.rgbEqual(color.color("rgba(12%,34%,56%,+0.4)"), 31, 87, 143, 0.4); test.rgbEqual(color.color("rgba(12%,34%,56%,-0.4)"), NaN, NaN, NaN, -0.4); test.hslEqual(color.color("hsla(60,100%,20%,+0.4)"), 60, 1, 0.2, 0.4); test.hslEqual(color.color("hsla(60,100%,20%,-0.4)"), NaN, NaN, NaN, -0.4); test.end(); }); tape("color(format) allows decimals for non-integer values", function(test) { test.rgbEqual(color.color("rgb(20.0%,30.4%,51.2%)"), 51, 78, 131, 1); test.hslEqual(color.color("hsl(20.0,30.4%,51.2%)"), 20, 0.304, 0.512, 1); test.end(); }); tape("color(format) allows leading decimal for hue, opacity and percentages", function(test) { test.hslEqual(color.color("hsl(.9,.3%,.5%)"), 0.9, 0.003, 0.005, 1); test.hslEqual(color.color("hsla(.9,.3%,.5%,.5)"), 0.9, 0.003, 0.005, 0.5); test.rgbEqual(color.color("rgb(.1%,.2%,.3%)"), 0, 1, 1, 1); test.rgbEqual(color.color("rgba(120,30,50,.5)"), 120, 30, 50, 0.5); test.end(); }); tape("color(format) allows exponential format for hue, opacity and percentages", function(test) { test.hslEqual(color.color("hsl(1e1,2e1%,3e1%)"), 10, 0.2, 0.3, 1); test.hslEqual(color.color("hsla(9e-1,3e-1%,5e-1%,5e-1)"), 0.9, 0.003, 0.005, 0.5); test.rgbEqual(color.color("rgb(1e-1%,2e-1%,3e-1%)"), 0, 1, 1, 1); test.rgbEqual(color.color("rgba(120,30,50,1e-1)"), 120, 30, 50, 0.1); test.end(); }); tape("color(format) does not allow decimals for integer values", function(test) { test.equal(color.color("rgb(120.5,30,50)"), null); test.end(); }); tape("color(format) does not allow empty decimals", function(test) { test.equal(color.color("rgb(120.,30,50)"), null); test.equal(color.color("rgb(120.%,30%,50%)"), null); test.equal(color.color("rgba(120,30,50,1.)"), null); test.equal(color.color("rgba(12%,30%,50%,1.)"), null); test.equal(color.color("hsla(60,100%,20%,1.)"), null); test.end(); }); tape("color(format) does not allow made-up names", function(test) { test.equal(color.color("bostock"), null); test.end(); }); tape("color(format) does not allow whitespace before open paren or percent sign", function(test) { test.equal(color.color("rgb (120,30,50)"), null); test.equal(color.color("rgb (12%,30%,50%)"), null); test.equal(color.color("hsl (120,30%,50%)"), null); test.equal(color.color("hsl(120,30 %,50%)"), null); test.equal(color.color("rgba (120,30,50,1)"), null); test.equal(color.color("rgba (12%,30%,50%,1)"), null); test.equal(color.color("hsla (120,30%,50%,1)"), null); test.end(); }); tape("color(format) is case-insensitive", function(test) { test.rgbEqual(color.color("aLiCeBlUE"), 240, 248, 255, 1); test.rgbEqual(color.color("transPARENT"), NaN, NaN, NaN, 0); test.rgbEqual(color.color(" #aBc\t\n"), 170, 187, 204, 1); test.rgbEqual(color.color(" #aaBBCC\t\n"), 170, 187, 204, 1); test.rgbEqual(color.color(" rGB(120,30,50)\t\n"), 120, 30, 50, 1); test.hslEqual(color.color(" HSl(120,30%,50%)\t\n"), 120, 0.3, 0.5, 1); test.end(); }); tape("color(format) returns undefined RGB channel values for unknown formats", function(test) { test.equal(color.color("invalid"), null); test.equal(color.color("hasOwnProperty"), null); test.equal(color.color("__proto__"), null); test.equal(color.color("#ab"), null); test.equal(color.color("#abcd"), null); test.end(); }); tape("color(format).hex() returns a hexadecimal string", function(test) { test.equal(color.color("rgba(12%,34%,56%,0.4)").hex(), "#1f578f"); test.end(); }); d3-color-1.2.8/test/cubehelix-test.js000066400000000000000000000004241350531377300174150ustar00rootroot00000000000000var tape = require("tape"), color = require("../"); tape("cubehelix(…) returns an instance of cubehelix and color", function(test) { var c = color.cubehelix("steelblue"); test.ok(c instanceof color.cubehelix); test.ok(c instanceof color.color); test.end(); }); d3-color-1.2.8/test/gray-test.js000066400000000000000000000006171350531377300164130ustar00rootroot00000000000000var tape = require("tape"), color = require("../"); require("./labEqual"); tape("gray(l[, opacity]) is an alias for lab(l, 0, 0[, opacity])", function(test) { test.labEqual(color.gray(120), 120, 0, 0, 1); test.labEqual(color.gray(120, 0.5), 120, 0, 0, 0.5); test.labEqual(color.gray(120, null), 120, 0, 0, 1); test.labEqual(color.gray(120, undefined), 120, 0, 0, 1); test.end(); }); d3-color-1.2.8/test/hcl-test.js000066400000000000000000000235441350531377300162230ustar00rootroot00000000000000var tape = require("tape"), color = require("../"); require("./hclEqual"); require("./rgbEqual"); tape("hcl(…) returns an instance of hcl and color", function(test) { var c = color.hcl(120, 40, 50); test.ok(c instanceof color.hcl); test.ok(c instanceof color.color); test.end(); }); tape("hcl(…) exposes h, c, and l channel values", function(test) { test.hclEqual(color.hcl("#abc"), 252.37145234745182, 11.223567114593477, 74.96879980931759, 1); test.end(); }); tape("hcl(…) returns defined hue and undefined chroma for black and white", function(test) { test.hclEqual(color.hcl("black"), NaN, NaN, 0, 1); test.hclEqual(color.hcl("#000"), NaN, NaN, 0, 1); test.hclEqual(color.hcl(color.lab("#000")), NaN, NaN, 0, 1); test.hclEqual(color.hcl("white"), NaN, NaN, 100, 1); test.hclEqual(color.hcl("#fff"), NaN, NaN, 100, 1); test.hclEqual(color.hcl(color.lab("#fff")), NaN, NaN, 100, 1); test.end(); }); tape("hcl(…) returns undefined hue and zero chroma for gray", function(test) { test.hclEqual(color.hcl("gray"), NaN, 0, 53.585013, 1); test.hclEqual(color.hcl(color.lab("gray")), NaN, 0, 53.585013, 1); test.end(); }); tape("hcl.toString() converts to RGB and formats as hexadecimal", function(test) { test.equal(color.hcl("#abcdef") + "", "rgb(171, 205, 239)"); test.equal(color.hcl("moccasin") + "", "rgb(255, 228, 181)"); test.equal(color.hcl("hsl(60, 100%, 20%)") + "", "rgb(102, 102, 0)"); test.equal(color.hcl("rgb(12, 34, 56)") + "", "rgb(12, 34, 56)"); test.equal(color.hcl(color.rgb(12, 34, 56)) + "", "rgb(12, 34, 56)"); test.equal(color.hcl(color.hsl(60, 1, 0.2)) + "", "rgb(102, 102, 0)"); test.end(); }); tape("hcl.toString() reflects h, c and l channel values", function(test) { var c = color.hcl("#abc"); c.h += 10, c.c += 1, c.l -= 1; test.equal(c + "", "rgb(170, 183, 204)"); test.end(); }); tape("hcl.toString() treats undefined opacity as 1", function(test) { var c = color.hcl("#abc"); c.opacity = NaN; test.equal(c + "", "rgb(170, 187, 204)"); test.end(); }); tape("hcl.toString() treats undefined channel values as 0", function(test) { test.equal(color.hcl("invalid") + "", "rgb(0, 0, 0)"); test.equal(color.hcl("#000") + "", "rgb(0, 0, 0)"); test.equal(color.hcl("#ccc") + "", "rgb(204, 204, 204)"); test.equal(color.hcl("#fff") + "", "rgb(255, 255, 255)"); test.equal(color.hcl(NaN, 20, 40) + "", "rgb(94, 94, 94)"); // equivalent to hcl(*, *, 40) test.equal(color.hcl(120, NaN, 40) + "", "rgb(94, 94, 94)"); test.equal(color.hcl(0, NaN, 40) + "", "rgb(94, 94, 94)"); test.equal(color.hcl(120, 50, NaN) + "", "rgb(0, 0, 0)"); // equivalent to hcl(*, *, 0) test.equal(color.hcl(0, 50, NaN) + "", "rgb(0, 0, 0)"); test.equal(color.hcl(120, 0, NaN) + "", "rgb(0, 0, 0)"); test.end(); }); tape("hcl(yellow) is displayable", function(test) { test.equal(color.hcl("yellow").displayable(), true); test.equal(color.hcl("yellow") + "", "rgb(255, 255, 0)"); test.end(); }); tape("hcl(h, c, l) does not wrap hue to [0,360)", function(test) { test.hclEqual(color.hcl(-10, 40, 50), -10, 40, 50, 1); test.hclEqual(color.hcl(0, 40, 50), 0, 40, 50, 1); test.hclEqual(color.hcl(360, 40, 50), 360, 40, 50, 1); test.hclEqual(color.hcl(370, 40, 50), 370, 40, 50, 1); test.end(); }); tape("hcl(h, c, l) does not clamp l channel value", function(test) { test.hclEqual(color.hcl(120, 20, -10), 120, 20, -10, 1); test.hclEqual(color.hcl(120, 20, 0), 120, 20, 0, 1); test.hclEqual(color.hcl(120, 20, 100), 120, 20, 100, 1); test.hclEqual(color.hcl(120, 20, 110), 120, 20, 110, 1); test.end(); }); tape("hcl(h, c, l, opacity) does not clamp opacity to [0,1]", function(test) { test.hclEqual(color.hcl(120, 20, 100, -0.2), 120, 20, 100, -0.2); test.hclEqual(color.hcl(120, 20, 110, 1.2), 120, 20, 110, 1.2); test.end(); }); tape("hcl(h, c, l) coerces channel values to numbers", function(test) { test.hclEqual(color.hcl("120", "40", "50"), 120, 40, 50, 1); test.end(); }); tape("hcl(h, c, l, opacity) coerces opacity to number", function(test) { test.hclEqual(color.hcl(120, 40, 50, "0.2"), 120, 40, 50, 0.2); test.end(); }); tape("hcl(h, c, l) allows undefined channel values", function(test) { test.hclEqual(color.hcl(undefined, NaN, "foo"), NaN, NaN, NaN, 1); test.hclEqual(color.hcl(undefined, 40, 50), NaN, 40, 50, 1); test.hclEqual(color.hcl(42, undefined, 50), 42, NaN, 50, 1); test.hclEqual(color.hcl(42, 40, undefined), 42, 40, NaN, 1); test.end(); }); tape("hcl(h, c, l, opacity) converts undefined opacity to 1", function(test) { test.hclEqual(color.hcl(10, 20, 30, null), 10, 20, 30, 1); test.hclEqual(color.hcl(10, 20, 30, undefined), 10, 20, 30, 1); test.end(); }); tape("hcl(format) parses the specified format and converts to HCL", function(test) { test.hclEqual(color.hcl("#abcdef"), 254.0079700170605, 21.62257586147983, 80.77135418262527, 1); test.hclEqual(color.hcl("#abc"), 252.37145234745182, 11.223567114593477, 74.96879980931759, 1); test.hclEqual(color.hcl("rgb(12, 34, 56)"), 262.8292023352897, 17.30347233219686, 12.404844123471648, 1); test.hclEqual(color.hcl("rgb(12%, 34%, 56%)"), 266.117653326772, 37.03612078188506, 35.48300043476593, 1); test.hclEqual(color.hcl("rgba(12%, 34%, 56%, 0.4)"), 266.117653326772, 37.03612078188506, 35.48300043476593, 0.4); test.hclEqual(color.hcl("hsl(60,100%,20%)"), 99.57458688693686, 48.327323183108916, 41.97125732118659, 1); test.hclEqual(color.hcl("hsla(60,100%,20%,0.4)"), 99.57458688693686, 48.327323183108916, 41.97125732118659, 0.4); test.hclEqual(color.hcl("aliceblue"), 247.7353849904697, 4.681732046417135, 97.12294991108756, 1); test.end(); }); tape("hcl(format) returns undefined channel values for unknown formats", function(test) { test.hclEqual(color.hcl("invalid"), NaN, NaN, NaN, NaN); test.end(); }); tape("hcl(hcl) copies an HCL color", function(test) { var c1 = color.hcl(120, 30, 50, 0.4), c2 = color.hcl(c1); test.hclEqual(c1, 120, 30, 50, 0.4); c1.h = c1.c = c1.l = c1.opacity = 0; test.hclEqual(c1, 0, 0, 0, 0); test.hclEqual(c2, 120, 30, 50, 0.4); test.end(); }); tape("hcl(lab) returns h = NaN if a and b are zero", function(test) { test.hclEqual(color.hcl(color.lab(0, 0, 0)), NaN, NaN, 0, 1); test.hclEqual(color.hcl(color.lab(50, 0, 0)), NaN, 0, 50, 1); test.hclEqual(color.hcl(color.lab(100, 0, 0)), NaN, NaN, 100, 1); test.hclEqual(color.hcl(color.lab(0, 10, 0)), 0, 10, 0, 1); test.hclEqual(color.hcl(color.lab(50, 10, 0)), 0, 10, 50, 1); test.hclEqual(color.hcl(color.lab(100, 10, 0)), 0, 10, 100, 1); test.hclEqual(color.hcl(color.lab(0, 0, 10)), 90, 10, 0, 1); test.hclEqual(color.hcl(color.lab(50, 0, 10)), 90, 10, 50, 1); test.hclEqual(color.hcl(color.lab(100, 0, 10)), 90, 10, 100, 1); test.end(); }); tape("hcl(rgb) converts from RGB", function(test) { test.hclEqual(color.hcl(color.rgb(255, 0, 0, 0.4)), 40.85261277607024, 106.83899941284552, 54.29173376861782, 0.4); test.end(); }); tape("hcl(color) converts from another colorspace via color.rgb()", function(test) { function TestColor() {} TestColor.prototype = Object.create(color.color.prototype); TestColor.prototype.rgb = function() { return color.rgb(12, 34, 56, 0.4); }; TestColor.prototype.toString = function() { throw new Error("should use rgb, not toString"); }; test.hclEqual(color.hcl(new TestColor), 262.8292023352897, 17.30347233219686, 12.404844123471648, 0.4); test.end(); }); tape("hcl.brighter(k) returns a brighter color if k > 0", function(test) { var c = color.hcl("rgba(165, 42, 42, 0.4)"); test.hclEqual(c.brighter(0.5), 32.28342524928155, 59.60231039142763, 47.149667346714935, 0.4); test.hclEqual(c.brighter(1), 32.28342524928155, 59.60231039142763, 56.149667346714935, 0.4); test.hclEqual(c.brighter(2), 32.28342524928155, 59.60231039142763, 74.14966734671493, 0.4); test.end(); }); tape("hcl.brighter(k) returns a copy", function(test) { var c1 = color.hcl("rgba(70, 130, 180, 0.4)"), c2 = c1.brighter(1); test.hclEqual(c1, 255.71009124439382, 33.88100417355615, 51.98624890550498, 0.4); test.hclEqual(c2, 255.71009124439382, 33.88100417355615, 69.98624890550498, 0.4); test.end(); }); tape("hcl.brighter() is equivalent to hcl.brighter(1)", function(test) { var c1 = color.hcl("rgba(70, 130, 180, 0.4)"), c2 = c1.brighter(), c3 = c1.brighter(1); test.hclEqual(c2, c3.h, c3.c, c3.l, 0.4); test.end(); }); tape("hcl.brighter(k) is equivalent to hcl.darker(-k)", function(test) { var c1 = color.hcl("rgba(70, 130, 180, 0.4)"), c2 = c1.brighter(1.5), c3 = c1.darker(-1.5); test.hclEqual(c2, c3.h, c3.c, c3.l, 0.4); test.end(); }); tape("hcl.darker(k) returns a darker color if k > 0", function(test) { var c = color.hcl("rgba(165, 42, 42, 0.4)"); test.hclEqual(c.darker(0.5), 32.28342524928155, 59.60231039142763, 29.149667346714935, 0.4); test.hclEqual(c.darker(1), 32.28342524928155, 59.60231039142763, 20.149667346714935, 0.4); test.hclEqual(c.darker(2), 32.28342524928155, 59.60231039142763, 2.149667346714935, 0.4); test.end(); }); tape("hcl.darker(k) returns a copy", function(test) { var c1 = color.hcl("rgba(70, 130, 180, 0.4)"), c2 = c1.darker(1); test.hclEqual(c1, 255.71009124439382, 33.88100417355615, 51.98624890550498, 0.4); test.hclEqual(c2, 255.71009124439382, 33.88100417355615, 33.98624890550498, 0.4); test.end(); }); tape("hcl.darker() is equivalent to hcl.darker(1)", function(test) { var c1 = color.hcl("rgba(70, 130, 180, 0.4)"), c2 = c1.darker(), c3 = c1.darker(1); test.hclEqual(c2, c3.h, c3.c, c3.l, 0.4); test.end(); }); tape("hcl.darker(k) is equivalent to hcl.brighter(-k)", function(test) { var c1 = color.hcl("rgba(70, 130, 180, 0.4)"), c2 = c1.darker(1.5), c3 = c1.brighter(-1.5); test.hclEqual(c2, c3.h, c3.c, c3.l, 0.4); test.end(); }); tape("hcl.rgb() converts to RGB", function(test) { var c = color.hcl(120, 30, 50, 0.4); test.rgbEqual(c.rgb(), 105, 126, 73, 0.4); test.end(); }); d3-color-1.2.8/test/hclEqual.js000066400000000000000000000014111350531377300162230ustar00rootroot00000000000000var tape = require("tape"), color = require("../"); tape.Test.prototype.hclEqual = function(actual, h, c, l, opacity) { this._assert(actual instanceof color.hcl && (isNaN(h) ? isNaN(actual.h) && actual.h !== actual.h : h - 1e-6 <= actual.h && actual.h <= h + 1e-6) && (isNaN(c) ? isNaN(actual.c) && actual.c !== actual.c : c - 1e-6 <= actual.c && actual.c <= c + 1e-6) && (isNaN(l) ? isNaN(actual.l) && actual.l !== actual.l : l - 1e-6 <= actual.l && actual.l <= l + 1e-6) && (isNaN(opacity) ? isNaN(actual.opacity) && actual.opacity !== actual.opacity : actual.opacity === opacity), { message: "should be equal", operator: "hclEqual", actual: [actual.h, actual.c, actual.l, actual.opacity], expected: [h, c, l, opacity] }); }; d3-color-1.2.8/test/hsl-test.js000066400000000000000000000263661350531377300162500ustar00rootroot00000000000000var tape = require("tape"), color = require("../"); require("./hslEqual"); require("./rgbEqual"); tape("hsl(…) returns an instance of hsl and color", function(test) { var c = color.hsl(120, 0.4, 0.5); test.ok(c instanceof color.hsl); test.ok(c instanceof color.color); test.end(); }); tape("hsl(…) exposes h, s, and l channel values and opacity", function(test) { test.hslEqual(color.hsl("#abc"), 210, 0.25, 0.7333333, 1); test.hslEqual(color.hsl("hsla(60, 100%, 20%, 0.4)"), 60, 1, 0.2, 0.4); test.end(); }); tape("hsl.toString() converts to RGB and formats as rgb(…) or rgba(…)", function(test) { test.equal(color.hsl("#abcdef") + "", "rgb(171, 205, 239)"); test.equal(color.hsl("moccasin") + "", "rgb(255, 228, 181)"); test.equal(color.hsl("hsl(60, 100%, 20%)") + "", "rgb(102, 102, 0)"); test.equal(color.hsl("hsla(60, 100%, 20%, 0.4)") + "", "rgba(102, 102, 0, 0.4)"); test.equal(color.hsl("rgb(12, 34, 56)") + "", "rgb(12, 34, 56)"); test.equal(color.hsl(color.rgb(12, 34, 56)) + "", "rgb(12, 34, 56)"); test.equal(color.hsl(color.hsl(60, 1, 0.2)) + "", "rgb(102, 102, 0)"); test.equal(color.hsl(color.hsl(60, 1, 0.2, 0.4)) + "", "rgba(102, 102, 0, 0.4)"); test.end(); }); tape("hsl.toString() reflects h, s and l channel values and opacity", function(test) { var c = color.hsl("#abc"); c.h += 10, c.s += 0.01, c.l -= 0.01, c.opacity = 0.4; test.equal(c + "", "rgba(166, 178, 203, 0.4)"); test.end(); }); tape("hsl.toString() treats undefined channel values as 0", function(test) { test.equal(color.hsl("invalid") + "", "rgb(0, 0, 0)"); test.equal(color.hsl("#000") + "", "rgb(0, 0, 0)"); test.equal(color.hsl("#ccc") + "", "rgb(204, 204, 204)"); test.equal(color.hsl("#fff") + "", "rgb(255, 255, 255)"); test.equal(color.hsl(NaN, 0.5, 0.4) + "", "rgb(102, 102, 102)"); // equivalent to hsl(*, 0, 0.4) test.equal(color.hsl(120, NaN, 0.4) + "", "rgb(102, 102, 102)"); test.equal(color.hsl(NaN, NaN, 0.4) + "", "rgb(102, 102, 102)"); test.equal(color.hsl(120, 0.5, NaN) + "", "rgb(0, 0, 0)"); // equivalent to hsl(120, 0.5, 0) test.end(); }); tape("hsl.toString() treats undefined opacity as 1", function(test) { var c = color.hsl("#abc"); c.opacity = NaN; test.equal(c + "", "rgb(170, 187, 204)"); test.end(); }); tape("hsl(h, s, l) does not wrap hue to [0,360)", function(test) { test.hslEqual(color.hsl(-10, 0.4, 0.5), -10, 0.4, 0.5, 1); test.hslEqual(color.hsl(0, 0.4, 0.5), 0, 0.4, 0.5, 1); test.hslEqual(color.hsl(360, 0.4, 0.5), 360, 0.4, 0.5, 1); test.hslEqual(color.hsl(370, 0.4, 0.5), 370, 0.4, 0.5, 1); test.end(); }); tape("hsl(h, s, l) does not clamp s and l channel values to [0,1]", function(test) { test.hslEqual(color.hsl(120, -0.1, 0.5), 120, -0.1, 0.5, 1); test.hslEqual(color.hsl(120, 1.1, 0.5), 120, 1.1, 0.5, 1); test.hslEqual(color.hsl(120, 0.2, -0.1), 120, 0.2, -0.1, 1); test.hslEqual(color.hsl(120, 0.2, 1.1), 120, 0.2, 1.1, 1); test.end(); }); tape("hsl(h, s, l, opacity) does not clamp opacity to [0,1]", function(test) { test.hslEqual(color.hsl(120, 0.1, 0.5, -0.2), 120, 0.1, 0.5, -0.2); test.hslEqual(color.hsl(120, 0.9, 0.5, 1.2), 120, 0.9, 0.5, 1.2); test.end(); }); tape("hsl(h, s, l) coerces channel values to numbers", function(test) { test.hslEqual(color.hsl("120", ".4", ".5"), 120, 0.4, 0.5, 1); test.end(); }); tape("hsl(h, s, l, opacity) coerces opacity to number", function(test) { test.hslEqual(color.hsl(120, 0.1, 0.5, "0.2"), 120, 0.1, 0.5, 0.2); test.hslEqual(color.hsl(120, 0.9, 0.5, "0.9"), 120, 0.9, 0.5, 0.9); test.end(); }); tape("hsl(h, s, l) allows undefined channel values", function(test) { test.hslEqual(color.hsl(undefined, NaN, "foo"), NaN, NaN, NaN, 1); test.hslEqual(color.hsl(undefined, 0.4, 0.5), NaN, 0.4, 0.5, 1); test.hslEqual(color.hsl(42, undefined, 0.5), 42, NaN, 0.5, 1); test.hslEqual(color.hsl(42, 0.4, undefined), 42, 0.4, NaN, 1); test.end(); }); tape("hsl(h, s, l, opacity) converts undefined opacity to 1", function(test) { test.hslEqual(color.hsl(10, 0.2, 0.3, null), 10, 0.2, 0.3, 1); test.hslEqual(color.hsl(10, 0.2, 0.3, undefined), 10, 0.2, 0.3, 1); test.end(); }); tape("hsl(h, s, l) preserves explicit hue, even for grays", function(test) { test.hslEqual(color.hsl(0, 0, 0), 0, 0, 0, 1); test.hslEqual(color.hsl(42, 0, 0.5), 42, 0, 0.5, 1); test.hslEqual(color.hsl(118, 0, 1), 118, 0, 1, 1); test.end(); }); tape("hsl(h, s, l) preserves explicit saturation, even for white or black", function(test) { test.hslEqual(color.hsl(0, 0, 0), 0, 0, 0, 1); test.hslEqual(color.hsl(0, 0.18, 0), 0, 0.18, 0, 1); test.hslEqual(color.hsl(0, 0.42, 1), 0, 0.42, 1, 1); test.hslEqual(color.hsl(0, 1, 1), 0, 1, 1, 1); test.end(); }); tape("hsl(format) parses the specified format and converts to HSL", function(test) { test.hslEqual(color.hsl("#abcdef"), 210, 0.68, 0.8039215, 1); test.hslEqual(color.hsl("#abc"), 210, 0.25, 0.733333333, 1); test.hslEqual(color.hsl("rgb(12, 34, 56)"), 210, 0.647058, 0.1333333, 1); test.hslEqual(color.hsl("rgb(12%, 34%, 56%)"), 210, 0.647058, 0.34, 1); test.hslEqual(color.hsl("hsl(60,100%,20%)"), 60, 1, 0.2, 1); test.hslEqual(color.hsl("hsla(60,100%,20%,0.4)"), 60, 1, 0.2, 0.4); test.hslEqual(color.hsl("aliceblue"), 208, 1, 0.9705882, 1); test.hslEqual(color.hsl("transparent"), NaN, NaN, NaN, 0); test.end(); }); tape("hsl(format) ignores the hue if the saturation is <= 0", function(test) { test.hslEqual(color.hsl("hsl(120,0%,20%)"), NaN, 0, 0.2, 1); test.hslEqual(color.hsl("hsl(120,-10%,20%)"), NaN, -0.1, 0.2, 1); test.end(); }); tape("hsl(format) ignores the hue and saturation if the lightness is <= 0 or >= 1", function(test) { test.hslEqual(color.hsl("hsl(120,20%,-10%)"), NaN, NaN, -0.1, 1); test.hslEqual(color.hsl("hsl(120,20%,0%)"), NaN, NaN, 0.0, 1); test.hslEqual(color.hsl("hsl(120,20%,100%)"), NaN, NaN, 1.0, 1); test.hslEqual(color.hsl("hsl(120,20%,120%)"), NaN, NaN, 1.2, 1); test.end(); }); tape("hsl(format) ignores all channels if the alpha is <= 0", function(test) { test.hslEqual(color.hsl("hsla(120,20%,10%,0)"), NaN, NaN, NaN, 0); test.hslEqual(color.hsl("hsla(120,20%,10%,-0.1)"), NaN, NaN, NaN, -0.1); test.end(); }); tape("hsl(format) does not lose precision when parsing HSL formats", function(test) { test.hslEqual(color.hsl("hsl(325,50%,40%)"), 325, 0.5, 0.4, 1); test.end(); }); tape("hsl(format) returns undefined channel values for unknown formats", function(test) { test.hslEqual(color.hsl("invalid"), NaN, NaN, NaN, NaN); test.end(); }); tape("hsl(hsl) copies an HSL color", function(test) { var c1 = color.hsl("hsla(120,30%,50%,0.4)"), c2 = color.hsl(c1); test.hslEqual(c1, 120, 0.3, 0.5, 0.4); c1.h = c1.s = c1.l = c1.opacity = 0; test.hslEqual(c1, 0, 0, 0, 0); test.hslEqual(c2, 120, 0.3, 0.5, 0.4); test.end(); }); tape("hsl(rgb) converts from RGB", function(test) { test.hslEqual(color.hsl(color.rgb(255, 0, 0, 0.4)), 0, 1, 0.5, 0.4); test.end(); }); tape("hsl(color) returns undefined hue and zero saturation for grays (but not white and black)", function(test) { test.hslEqual(color.hsl("gray"), NaN, 0, 0.5019608, 1); test.hslEqual(color.hsl("#ccc"), NaN, 0, 0.8, 1); test.hslEqual(color.hsl(color.rgb("gray")), NaN, 0, 0.5019608, 1); test.end(); }); tape("hsl(color) returns undefined hue and saturation for black and white", function(test) { test.hslEqual(color.hsl("black"), NaN, NaN, 0, 1); test.hslEqual(color.hsl("#000"), NaN, NaN, 0, 1); test.hslEqual(color.hsl("white"), NaN, NaN, 1, 1); test.hslEqual(color.hsl("#fff"), NaN, NaN, 1, 1); test.hslEqual(color.hsl(color.rgb("#fff")), NaN, NaN, 1, 1); test.end(); }); tape("hsl(color) converts from another colorspace via color.rgb()", function(test) { function TestColor() {} TestColor.prototype = Object.create(color.color.prototype); TestColor.prototype.rgb = function() { return color.rgb(12, 34, 56, 0.4); }; TestColor.prototype.toString = function() { throw new Error("should use rgb, not toString"); }; test.hslEqual(color.hsl(new TestColor), 210, 0.6470588, 0.1333334, 0.4); test.end(); }); tape("hsl.displayable() returns true if the color is within the RGB gamut and the opacity is in [0,1]", function(test) { test.equal(color.hsl("white").displayable(), true); test.equal(color.hsl("red").displayable(), true); test.equal(color.hsl("black").displayable(), true); test.equal(color.hsl("invalid").displayable(), false); test.equal(color.hsl(NaN, NaN, 1).displayable(), true); test.equal(color.hsl(NaN, NaN, 1.5).displayable(), false); test.equal(color.hsl(120, -0.5, 0).displayable(), false); test.equal(color.hsl(120, 1.5, 0).displayable(), false); test.equal(color.hsl(0, 1, 1, 0).displayable(), true); test.equal(color.hsl(0, 1, 1, 1).displayable(), true); test.equal(color.hsl(0, 1, 1, -0.2).displayable(), false); test.equal(color.hsl(0, 1, 1, 1.2).displayable(), false); test.end(); }); tape("hsl.brighter(k) returns a brighter color if k > 0", function(test) { var c = color.hsl("rgba(165, 42, 42, 0.4)"); test.hslEqual(c.brighter(0.5), 0, 0.5942028, 0.4851222, 0.4); test.hslEqual(c.brighter(1), 0, 0.5942028, 0.5798319, 0.4); test.hslEqual(c.brighter(2), 0, 0.5942028, 0.8283313, 0.4); test.end(); }); tape("hsl.brighter(k) returns a copy", function(test) { var c1 = color.hsl("rgba(70, 130, 180, 0.4)"), c2 = c1.brighter(1); test.hslEqual(c1, 207.272727, 0.44, 0.4901961, 0.4); test.hslEqual(c2, 207.272727, 0.44, 0.7002801, 0.4); test.end(); }); tape("hsl.brighter() is equivalent to hsl.brighter(1)", function(test) { var c1 = color.hsl("rgba(70, 130, 180, 0.4)"), c2 = c1.brighter(), c3 = c1.brighter(1); test.hslEqual(c2, c3.h, c3.s, c3.l, 0.4); test.end(); }); tape("hsl.brighter(k) is equivalent to hsl.darker(-k)", function(test) { var c1 = color.hsl("rgba(70, 130, 180, 0.4)"), c2 = c1.brighter(1.5), c3 = c1.darker(-1.5); test.hslEqual(c2, c3.h, c3.s, c3.l, 0.4); test.end(); }); tape("hsl(\"black\").brighter() still returns black", function(test) { var c1 = color.hsl("black"), c2 = c1.brighter(1); test.hslEqual(c1, NaN, NaN, 0, 1); test.hslEqual(c2, NaN, NaN, 0, 1); test.end(); }); tape("hsl.darker(k) returns a darker color if k > 0", function(test) { var c = color.hsl("rgba(165, 42, 42, 0.4)"); test.hslEqual(c.darker(0.5), 0, 0.5942029, 0.3395855, 0.4); test.hslEqual(c.darker(1), 0, 0.5942029, 0.2841176, 0.4); test.hslEqual(c.darker(2), 0, 0.5942029, 0.1988823, 0.4); test.end(); }); tape("hsl.darker(k) returns a copy", function(test) { var c1 = color.hsl("rgba(70, 130, 180, 0.4)"), c2 = c1.darker(1); test.hslEqual(c1, 207.272727, 0.44, 0.4901961, 0.4); test.hslEqual(c2, 207.272727, 0.44, 0.3431373, 0.4); test.end(); }); tape("hsl.darker() is equivalent to hsl.darker(1)", function(test) { var c1 = color.hsl("rgba(70, 130, 180, 0.4)"), c2 = c1.darker(), c3 = c1.darker(1); test.hslEqual(c2, c3.h, c3.s, c3.l, 0.4); test.end(); }); tape("hsl.darker(k) is equivalent to hsl.brighter(-k)", function(test) { var c1 = color.hsl("rgba(70, 130, 180, 0.4)"), c2 = c1.darker(1.5), c3 = c1.brighter(-1.5); test.hslEqual(c2, c3.h, c3.s, c3.l, 0.4); test.end(); }); tape("hsl.rgb() converts to RGB", function(test) { var c = color.hsl(120, 0.3, 0.5, 0.4); test.rgbEqual(c.rgb(), 89, 166, 89, 0.4); test.end(); }); d3-color-1.2.8/test/hslEqual.js000066400000000000000000000014111350531377300162430ustar00rootroot00000000000000var tape = require("tape"), color = require("../"); tape.Test.prototype.hslEqual = function(actual, h, s, l, opacity) { this._assert(actual instanceof color.hsl && (isNaN(h) ? isNaN(actual.h) && actual.h !== actual.h : h - 1e-6 <= actual.h && actual.h <= h + 1e-6) && (isNaN(s) ? isNaN(actual.s) && actual.s !== actual.s : s - 1e-6 <= actual.s && actual.s <= s + 1e-6) && (isNaN(l) ? isNaN(actual.l) && actual.l !== actual.l : l - 1e-6 <= actual.l && actual.l <= l + 1e-6) && (isNaN(opacity) ? isNaN(actual.opacity) && actual.opacity !== actual.opacity : actual.opacity === opacity), { message: "should be equal", operator: "hslEqual", actual: [actual.h, actual.s, actual.l, actual.opacity], expected: [h, s, l, opacity] }); }; d3-color-1.2.8/test/lab-test.js000066400000000000000000000201331350531377300162020ustar00rootroot00000000000000var tape = require("tape"), color = require("../"); require("./labEqual"); require("./rgbEqual"); tape("lab(…) returns an instance of lab and color", function(test) { var c = color.lab(120, 40, 50); test.ok(c instanceof color.lab); test.ok(c instanceof color.color); test.end(); }); tape("lab(…) exposes l, a and b channel values and opacity", function(test) { test.labEqual(color.lab("rgba(170, 187, 204, 0.4)"), 74.96879980931759, -3.398998724348956, -10.696507207853333, 0.4); test.end(); }); tape("lab.toString() converts to RGB and formats as rgb(…) or rgba(…)", function(test) { test.equal(color.lab("#abcdef") + "", "rgb(171, 205, 239)"); test.equal(color.lab("moccasin") + "", "rgb(255, 228, 181)"); test.equal(color.lab("hsl(60, 100%, 20%)") + "", "rgb(102, 102, 0)"); test.equal(color.lab("hsla(60, 100%, 20%, 0.4)") + "", "rgba(102, 102, 0, 0.4)"); test.equal(color.lab("rgb(12, 34, 56)") + "", "rgb(12, 34, 56)"); test.equal(color.lab(color.rgb(12, 34, 56)) + "", "rgb(12, 34, 56)"); test.equal(color.lab(color.hsl(60, 1, 0.2)) + "", "rgb(102, 102, 0)"); test.equal(color.lab(color.hsl(60, 1, 0.2, 0.4)) + "", "rgba(102, 102, 0, 0.4)"); test.end(); }); tape("lab.toString() reflects l, a and b channel values and opacity", function(test) { var c = color.lab("#abc"); c.l += 10, c.a -= 10, c.b += 10, c.opacity = 0.4; test.equal(c + "", "rgba(184, 220, 213, 0.4)"); test.end(); }); tape("lab.toString() treats undefined channel values as 0", function(test) { test.equal(color.lab("invalid") + "", "rgb(0, 0, 0)"); test.equal(color.lab(NaN, 0, 0) + "", "rgb(0, 0, 0)"); test.equal(color.lab(50, NaN, 0) + "", "rgb(119, 119, 119)"); test.equal(color.lab(50, 0, NaN) + "", "rgb(119, 119, 119)"); test.equal(color.lab(50, NaN, NaN) + "", "rgb(119, 119, 119)"); test.end(); }); tape("lab.toString() treats undefined opacity as 1", function(test) { var c = color.lab("#abc"); c.opacity = NaN; test.equal(c + "", "rgb(170, 187, 204)"); test.end(); }); tape("lab(l, a, b) does not clamp l channel value", function(test) { test.labEqual(color.lab(-10, 1, 2), -10, 1, 2, 1); test.labEqual(color.lab(0, 1, 2), 0, 1, 2, 1); test.labEqual(color.lab(100, 1, 2), 100, 1, 2, 1); test.labEqual(color.lab(110, 1, 2), 110, 1, 2, 1); test.end(); }); tape("lab(l, a, b, opacity) does not clamp opacity to [0,1]", function(test) { test.labEqual(color.lab(50, 10, 20, -0.2), 50, 10, 20, -0.2); test.labEqual(color.lab(50, 10, 20, 1.2), 50, 10, 20, 1.2); test.end(); }); tape("lab(l, a, b) coerces channel values to numbers", function(test) { test.labEqual(color.lab("50", "4", "-5"), 50, 4, -5, 1); test.end(); }); tape("lab(l, a, b, opacity) coerces opacity to number", function(test) { test.labEqual(color.lab(50, 4, -5, "0.2"), 50, 4, -5, 0.2); test.end(); }); tape("lab(l, a, b) allows undefined channel values", function(test) { test.labEqual(color.lab(undefined, NaN, "foo"), NaN, NaN, NaN, 1); test.labEqual(color.lab(undefined, 4, -5), NaN, 4, -5, 1); test.labEqual(color.lab(42, undefined, -5), 42, NaN, -5, 1); test.labEqual(color.lab(42, 4, undefined), 42, 4, NaN, 1); test.end(); }); tape("lab(l, a, b, opacity) converts undefined opacity to 1", function(test) { test.labEqual(color.lab(10, 20, 30, null), 10, 20, 30, 1); test.labEqual(color.lab(10, 20, 30, undefined), 10, 20, 30, 1); test.end(); }); tape("lab(format) parses the specified format and converts to Lab", function(test) { test.labEqual(color.lab("#abcdef"), 80.77135418262527, -5.957098328496224, -20.785782794739237, 1); test.labEqual(color.lab("#abc"), 74.96879980931759, -3.398998724348956, -10.696507207853333, 1); test.labEqual(color.lab("rgb(12, 34, 56)"), 12.404844123471648, -2.159950219712034, -17.168132391132946, 1); test.labEqual(color.lab("rgb(12%, 34%, 56%)"), 35.48300043476593, -2.507637675606522, -36.95112983195855, 1); test.labEqual(color.lab("rgba(12%, 34%, 56%, 0.4)"), 35.48300043476593, -2.507637675606522, -36.95112983195855, 0.4); test.labEqual(color.lab("hsl(60,100%,20%)"), 41.97125732118659, -8.03835128380484, 47.65411917854332, 1); test.labEqual(color.lab("hsla(60,100%,20%,0.4)"), 41.97125732118659, -8.03835128380484, 47.65411917854332, 0.4); test.labEqual(color.lab("aliceblue"), 97.12294991108756, -1.773836604137824, -4.332680308569969, 1); test.end(); }); tape("lab(format) returns undefined channel values for unknown formats", function(test) { test.labEqual(color.lab("invalid"), NaN, NaN, NaN, NaN); test.end(); }); tape("lab(lab) copies a Lab color", function(test) { var c1 = color.lab(50, 4, -5, 0.4), c2 = color.lab(c1); test.labEqual(c1, 50, 4, -5, 0.4); c1.l = c1.a = c1.b = c1.opacity = 0; test.labEqual(c1, 0, 0, 0, 0); test.labEqual(c2, 50, 4, -5, 0.4); test.end(); }); tape("lab(hcl(lab)) doesn’t lose a and b channels if luminance is zero", function(test) { test.labEqual(color.lab(color.hcl(color.lab(0, 10, 0))), 0, 10, 0, 1); test.end(); }); tape("lab(rgb) converts from RGB", function(test) { test.labEqual(color.lab(color.rgb(255, 0, 0, 0.4)), 54.29173376861782, 80.8124553179771, 69.88504032350531, 0.4); test.end(); }); tape("lab(color) converts from another colorspace via color.rgb()", function(test) { function TestColor() {} TestColor.prototype = Object.create(color.color.prototype); TestColor.prototype.rgb = function() { return color.rgb(12, 34, 56, 0.4); }; TestColor.prototype.toString = function() { throw new Error("should use rgb, not toString"); }; test.labEqual(color.lab(new TestColor), 12.404844123471648, -2.159950219712034, -17.168132391132946, 0.4); test.end(); }); tape("lab.brighter(k) returns a brighter color if k > 0", function(test) { var c = color.lab("rgba(165, 42, 42, 0.4)"); test.labEqual(c.brighter(0.5), 47.149667346714935, 50.388769337115, 31.834059255569358, 0.4); test.labEqual(c.brighter(1), 56.149667346714935, 50.388769337115, 31.834059255569358, 0.4); test.labEqual(c.brighter(2), 74.14966734671493, 50.388769337115, 31.834059255569358, 0.4); test.end(); }); tape("lab.brighter(k) returns a copy", function(test) { var c1 = color.lab("rgba(70, 130, 180, 0.4)"), c2 = c1.brighter(1); test.labEqual(c1, 51.98624890550498, -8.362792037014344, -32.832699449697685, 0.4); test.labEqual(c2, 69.98624890550498, -8.362792037014344, -32.832699449697685, 0.4); test.end(); }); tape("lab.brighter() is equivalent to lab.brighter(1)", function(test) { var c1 = color.lab("rgba(70, 130, 180, 0.4)"), c2 = c1.brighter(), c3 = c1.brighter(1); test.labEqual(c2, c3.l, c3.a, c3.b, 0.4); test.end(); }); tape("lab.brighter(k) is equivalent to lab.darker(-k)", function(test) { var c1 = color.lab("rgba(70, 130, 180, 0.4)"), c2 = c1.brighter(1.5), c3 = c1.darker(-1.5); test.labEqual(c2, c3.l, c3.a, c3.b, 0.4); test.end(); }); tape("lab.darker(k) returns a darker color if k > 0", function(test) { var c = color.lab("rgba(165, 42, 42, 0.4)"); test.labEqual(c.darker(0.5), 29.149667346714935, 50.388769337115, 31.834059255569358, 0.4); test.labEqual(c.darker(1), 20.149667346714935, 50.388769337115, 31.834059255569358, 0.4); test.labEqual(c.darker(2), 2.149667346714935, 50.388769337115, 31.834059255569358, 0.4); test.end(); }); tape("lab.darker(k) returns a copy", function(test) { var c1 = color.lab("rgba(70, 130, 180, 0.4)"), c2 = c1.darker(1); test.labEqual(c1, 51.98624890550498, -8.362792037014344, -32.832699449697685, 0.4); test.labEqual(c2, 33.98624890550498, -8.362792037014344, -32.832699449697685, 0.4); test.end(); }); tape("lab.darker() is equivalent to lab.darker(1)", function(test) { var c1 = color.lab("rgba(70, 130, 180, 0.4)"), c2 = c1.darker(), c3 = c1.darker(1); test.labEqual(c2, c3.l, c3.a, c3.b, 0.4); test.end(); }); tape("lab.darker(k) is equivalent to lab.brighter(-k)", function(test) { var c1 = color.lab("rgba(70, 130, 180, 0.4)"), c2 = c1.darker(1.5), c3 = c1.brighter(-1.5); test.labEqual(c2, c3.l, c3.a, c3.b, 0.4); test.end(); }); tape("lab.rgb() converts to RGB", function(test) { var c = color.lab(50, 4, -5, 0.4); test.rgbEqual(c.rgb(), 123, 117, 128, 0.4); test.end(); }); d3-color-1.2.8/test/labEqual.js000066400000000000000000000014111350531377300162130ustar00rootroot00000000000000var tape = require("tape"), color = require("../"); tape.Test.prototype.labEqual = function(actual, l, a, b, opacity) { this._assert(actual instanceof color.lab && (isNaN(l) ? isNaN(actual.l) && actual.l !== actual.l : l - 1e-6 <= actual.l && actual.l <= l + 1e-6) && (isNaN(a) ? isNaN(actual.a) && actual.a !== actual.a : a - 1e-6 <= actual.a && actual.a <= a + 1e-6) && (isNaN(b) ? isNaN(actual.b) && actual.b !== actual.b : b - 1e-6 <= actual.b && actual.b <= b + 1e-6) && (isNaN(opacity) ? isNaN(actual.opacity) && actual.opacity !== actual.opacity : actual.opacity === opacity), { message: "should be equal", operator: "labEqual", actual: [actual.l, actual.a, actual.b, actual.opacity], expected: [l, a, b, opacity] }); }; d3-color-1.2.8/test/lch-test.js000066400000000000000000000014241350531377300162140ustar00rootroot00000000000000var tape = require("tape"), color = require("../"); require("./hclEqual"); tape("lch(color) is equivalent to hcl(color)", function(test) { test.hclEqual(color.lch("#abc"), 252.37145234745182, 11.223567114593477, 74.96879980931759, 1); test.hclEqual(color.lch(color.rgb("#abc")), 252.37145234745182, 11.223567114593477, 74.96879980931759, 1); test.end(); }); tape("lch(l, c, h[, opacity]) is equivalent to hcl(h, c, l[, opacity])", function(test) { test.hclEqual(color.lch(74, 11, 252), 252, 11, 74, 1); test.hclEqual(color.lch(74, 11, 252), 252, 11, 74, 1); test.hclEqual(color.lch(74, 11, 252, null), 252, 11, 74, 1); test.hclEqual(color.lch(74, 11, 252, undefined), 252, 11, 74, 1); test.hclEqual(color.lch(74, 11, 252, 0.5), 252, 11, 74, 0.5); test.end(); }); d3-color-1.2.8/test/rgb-test.js000066400000000000000000000220771350531377300162270ustar00rootroot00000000000000var tape = require("tape"), color = require("../"); require("./rgbEqual"); tape("rgb(…) returns an instance of rgb and color", function(test) { var c = color.rgb(70, 130, 180); test.ok(c instanceof color.rgb); test.ok(c instanceof color.color); test.end(); }); tape("rgb(…) exposes r, g and b channel values and opacity", function(test) { test.rgbEqual(color.rgb("#abc"), 170, 187, 204, 1); test.rgbEqual(color.rgb("rgba(170, 187, 204, 0.4)"), 170, 187, 204, 0.4); test.end(); }); tape("rgb.toString() formats as rgb(…) or rgba(…)", function(test) { test.equal(color.rgb("#abcdef") + "", "rgb(171, 205, 239)"); test.equal(color.rgb("moccasin") + "", "rgb(255, 228, 181)"); test.equal(color.rgb("hsl(60, 100%, 20%)") + "", "rgb(102, 102, 0)"); test.equal(color.rgb("rgb(12, 34, 56)") + "", "rgb(12, 34, 56)"); test.equal(color.rgb(color.rgb(12, 34, 56)) + "", "rgb(12, 34, 56)"); test.equal(color.rgb(color.hsl(60, 1, 0.2)) + "", "rgb(102, 102, 0)"); test.equal(color.rgb("rgba(12, 34, 56, 0.4)") + "", "rgba(12, 34, 56, 0.4)"); test.equal(color.rgb("rgba(12%, 34%, 56%, 0.4)") + "", "rgba(31, 87, 143, 0.4)"); test.equal(color.rgb("hsla(60, 100%, 20%, 0.4)") + "", "rgba(102, 102, 0, 0.4)"); test.end(); }); tape("rgb.toString() reflects r, g and b channel values and opacity", function(test) { var c = color.rgb("#abc"); ++c.r, ++c.g, ++c.b, c.opacity = 0.5; test.equal(c + "", "rgba(171, 188, 205, 0.5)"); test.end(); }); tape("rgb.toString() treats undefined channel values as 0", function(test) { test.equal(color.rgb("invalid") + "", "rgb(0, 0, 0)"); test.equal(color.rgb(NaN, 12, 34) + "", "rgb(0, 12, 34)"); test.end(); }); tape("rgb.toString() treats undefined opacity as 1", function(test) { var c = color.rgb("#abc"); ++c.r, ++c.g, ++c.b, c.opacity = NaN; test.equal(c + "", "rgb(171, 188, 205)"); test.end(); }); tape("rgb.toString() clamps r, g, b and opacity channel values", function(test) { test.equal(color.rgb(-1, 2, 3) + "", "rgb(0, 2, 3)"); test.equal(color.rgb( 2, -1, 3) + "", "rgb(2, 0, 3)"); test.equal(color.rgb( 2, 3, -1) + "", "rgb(2, 3, 0)"); test.equal(color.rgb( 2, 3, -1, -0.2) + "", "rgba(2, 3, 0, 0)"); test.equal(color.rgb( 2, 3, -1, 1.2) + "", "rgb(2, 3, 0)"); test.end(); }); tape("rgb.toString() rounds r, g and b channel values", function(test) { test.equal(color.rgb(0.5, 2.0, 3.0) + "", "rgb(1, 2, 3)"); test.equal(color.rgb(2.0, 0.5, 3.0) + "", "rgb(2, 1, 3)"); test.equal(color.rgb(2.0, 3.0, 0.5) + "", "rgb(2, 3, 1)"); test.end(); }); tape("rgb(r, g, b) does not round channel values", function(test) { test.rgbStrictEqual(color.rgb(1.2, 2.6, 42.9), 1.2, 2.6, 42.9, 1); test.end(); }); tape("rgb(r, g, b) does not clamp channel values", function(test) { test.rgbEqual(color.rgb(-10, -20, -30), -10, -20, -30, 1); test.rgbEqual(color.rgb(300, 400, 500), 300, 400, 500, 1); test.end(); }); tape("rgb(r, g, b, opacity) does not clamp opacity", function(test) { test.rgbEqual(color.rgb(-10, -20, -30, -0.2), -10, -20, -30, -0.2); test.rgbEqual(color.rgb(300, 400, 500, 1.2), 300, 400, 500, 1.2); test.end(); }); tape("rgb(r, g, b) coerces channel values to numbers", function(test) { test.rgbEqual(color.rgb("12", "34", "56"), 12, 34, 56, 1); test.rgbEqual(color.rgb(null, null, null), 0, 0, 0, 1); test.end(); }); tape("rgb(r, g, b, opacity) coerces opacity to number", function(test) { test.rgbStrictEqual(color.rgb(-10, -20, -30, "-0.2"), -10, -20, -30, -0.2); test.rgbStrictEqual(color.rgb(300, 400, 500, "1.2"), 300, 400, 500, 1.2); test.end(); }); tape("rgb(r, g, b) allows undefined channel values", function(test) { test.rgbEqual(color.rgb(undefined, NaN, "foo"), NaN, NaN, NaN, 1); test.rgbEqual(color.rgb(undefined, 42, 56), NaN, 42, 56, 1); test.rgbEqual(color.rgb(42, undefined, 56), 42, NaN, 56, 1); test.rgbEqual(color.rgb(42, 56, undefined), 42, 56, NaN, 1); test.end(); }); tape("rgb(r, g, b, opacity) converts undefined opacity to 1", function(test) { test.rgbEqual(color.rgb(10, 20, 30, null), 10, 20, 30, 1); test.rgbEqual(color.rgb(10, 20, 30, undefined), 10, 20, 30, 1); test.end(); }); tape("rgb(format) parses the specified format and converts to RGB", function(test) { test.rgbEqual(color.rgb("#abcdef"), 171, 205, 239, 1); test.rgbEqual(color.rgb("#abc"), 170, 187, 204, 1); test.rgbEqual(color.rgb("rgb(12, 34, 56)"), 12, 34, 56, 1); test.rgbEqual(color.rgb("rgb(12%, 34%, 56%)"), 31, 87, 143, 1); test.rgbEqual(color.rgb("hsl(60,100%,20%)"), 102, 102, 0, 1); test.rgbEqual(color.rgb("aliceblue"), 240, 248, 255, 1); test.rgbEqual(color.rgb("hsla(60,100%,20%,0.4)"), 102, 102, 0, 0.4); test.end(); }); tape("rgb(format) ignores all channels if the alpha is <= 0", function(test) { test.rgbEqual(color.rgb("rgba(12,34,45,0)"), NaN, NaN, NaN, 0); test.rgbEqual(color.rgb("rgba(12,34,45,-0.1)"), NaN, NaN, NaN, -0.1); test.end(); }); tape("rgb(format) returns undefined channel values for unknown formats", function(test) { test.rgbEqual(color.rgb("invalid"), NaN, NaN, NaN, NaN); test.end(); }); tape("rgb(rgb) copies an RGB color", function(test) { var c1 = color.rgb("rgba(70, 130, 180, 0.4)"), c2 = color.rgb(c1); test.rgbEqual(c1, 70, 130, 180, 0.4); c1.r = c1.g = c1.b = c1.opacity = 0; test.rgbEqual(c1, 0, 0, 0, 0); test.rgbEqual(c2, 70, 130, 180, 0.4); test.end(); }); tape("rgb(hsl) converts from HSL", function(test) { test.rgbEqual(color.rgb(color.hsl(0, 1, 0.5)), 255, 0, 0, 1); test.rgbEqual(color.rgb(color.hsl(0, 1, 0.5, 0.4)), 255, 0, 0, 0.4); test.end(); }); tape("rgb(color) converts from another colorspace via color.rgb()", function(test) { function TestColor() {} TestColor.prototype = Object.create(color.color.prototype); TestColor.prototype.rgb = function() { return color.rgb(12, 34, 56, 0.4); }; TestColor.prototype.toString = function() { throw new Error("should use rgb, not toString"); }; test.rgbEqual(color.rgb(new TestColor), 12, 34, 56, 0.4); test.end(); }); tape("rgb.displayable() returns true if the color is within the RGB gamut and opacity is in [0,1]", function(test) { test.equal(color.rgb("white").displayable(), true); test.equal(color.rgb("red").displayable(), true); test.equal(color.rgb("black").displayable(), true); test.equal(color.rgb("invalid").displayable(), false); test.equal(color.rgb(-1, 0, 0).displayable(), false); test.equal(color.rgb(0, -1, 0).displayable(), false); test.equal(color.rgb(0, 0, -1).displayable(), false); test.equal(color.rgb(256, 0, 0).displayable(), false); test.equal(color.rgb(0, 256, 0).displayable(), false); test.equal(color.rgb(0, 0, 256).displayable(), false); test.equal(color.rgb(0, 0, 255, 0).displayable(), true); test.equal(color.rgb(0, 0, 255, 1.2).displayable(), false); test.equal(color.rgb(0, 0, 255, -0.2).displayable(), false); test.end(); }); tape("rgb.brighter(k) returns a brighter color if k > 0", function(test) { var c = color.rgb("rgba(165, 42, 42, 0.4)"); test.rgbEqual(c.brighter(0.5), 197, 50, 50, 0.4); test.rgbEqual(c.brighter(1), 236, 60, 60, 0.4); test.rgbEqual(c.brighter(2), 337, 86, 86, 0.4); test.end(); }); tape("rgb.brighter(k) returns a copy", function(test) { var c1 = color.rgb("rgba(70, 130, 180, 0.4)"), c2 = c1.brighter(1); test.rgbEqual(c1, 70, 130, 180, 0.4); test.rgbEqual(c2, 100, 186, 257, 0.4); test.end(); }); tape("rgb.brighter() is equivalent to rgb.brighter(1)", function(test) { var c1 = color.rgb("rgba(70, 130, 180, 0.4)"), c2 = c1.brighter(), c3 = c1.brighter(1); test.rgbEqual(c2, c3.r, c3.g, c3.b, 0.4); test.end(); }); tape("rgb.brighter(k) is equivalent to rgb.darker(-k)", function(test) { var c1 = color.rgb("rgba(70, 130, 180, 0.4)"), c2 = c1.brighter(1.5), c3 = c1.darker(-1.5); test.rgbEqual(c2, c3.r, c3.g, c3.b, 0.4); test.end(); }); tape("rgb(\"black\").brighter() still returns black", function(test) { var c1 = color.rgb("black"), c2 = c1.brighter(1); test.rgbEqual(c1, 0, 0, 0, 1); test.rgbEqual(c2, 0, 0, 0, 1); test.end(); }); tape("rgb.darker(k) returns a darker color if k > 0", function(test) { var c = color.rgb("rgba(165, 42, 42, 0.4)"); test.rgbEqual(c.darker(0.5), 138, 35, 35, 0.4); test.rgbEqual(c.darker(1), 115, 29, 29, 0.4); test.rgbEqual(c.darker(2), 81, 21, 21, 0.4); test.end(); }); tape("rgb.darker(k) returns a copy", function(test) { var c1 = color.rgb("rgba(70, 130, 180, 0.4)"), c2 = c1.darker(1); test.rgbEqual(c1, 70, 130, 180, 0.4); test.rgbEqual(c2, 49, 91, 126, 0.4); test.end(); }); tape("rgb.darker() is equivalent to rgb.darker(1)", function(test) { var c1 = color.rgb("rgba(70, 130, 180, 0.4)"), c2 = c1.darker(), c3 = c1.darker(1); test.rgbEqual(c2, c3.r, c3.g, c3.b, 0.4); test.end(); }); tape("rgb.darker(k) is equivalent to rgb.brighter(-k)", function(test) { var c1 = color.rgb("rgba(70, 130, 180, 0.4)"), c2 = c1.darker(1.5), c3 = c1.brighter(-1.5); test.rgbEqual(c2, c3.r, c3.g, c3.b, 0.4); test.end(); }); tape("rgb.rgb() returns this", function(test) { var c = color.rgb(70, 130, 180); test.equal(c.rgb(), c); test.end(); }); d3-color-1.2.8/test/rgbEqual.js000066400000000000000000000027021350531377300162330ustar00rootroot00000000000000var tape = require("tape"), color = require("../"); tape.Test.prototype.rgbStrictEqual = function(actual, r, g, b, opacity) { this._assert(actual instanceof color.rgb && (isNaN(r) ? isNaN(actual.r) && actual.r !== actual.r : actual.r === r) && (isNaN(g) ? isNaN(actual.g) && actual.g !== actual.g : actual.g === g) && (isNaN(b) ? isNaN(actual.b) && actual.b !== actual.b : actual.b === b) && (isNaN(opacity) ? isNaN(actual.opacity) && actual.opacity !== actual.opacity : actual.opacity === opacity), { message: "should be equal", operator: "rgbStrictEqual", actual: [actual.r, actual.g, actual.b, actual.opacity], expected: [r, g, b, opacity] }); }; tape.Test.prototype.rgbEqual = function(actual, r, g, b, opacity) { this._assert(actual instanceof color.rgb && (isNaN(r) ? isNaN(actual.r) && actual.r !== actual.r : Math.round(actual.r) === Math.round(r)) && (isNaN(g) ? isNaN(actual.g) && actual.g !== actual.g : Math.round(actual.g) === Math.round(g)) && (isNaN(b) ? isNaN(actual.b) && actual.b !== actual.b : Math.round(actual.b) === Math.round(b)) && (isNaN(opacity) ? isNaN(actual.opacity) && actual.opacity !== actual.opacity : actual.opacity === opacity), { message: "should be equal", operator: "rgbEqual", actual: [Math.round(actual.r), Math.round(actual.g), Math.round(actual.b), actual.opacity], expected: [Math.round(r), Math.round(g), Math.round(b), opacity] }); }; d3-color-1.2.8/yarn.lock000066400000000000000000000765141350531377300150130ustar00rootroot00000000000000# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. # yarn lockfile v1 "@babel/code-frame@^7.0.0-beta.47": version "7.0.0-rc.3" resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.0.0-rc.3.tgz#d77a587401f818a3168700f596e41cd6905947b2" dependencies: "@babel/highlight" "7.0.0-rc.3" "@babel/highlight@7.0.0-rc.3": version "7.0.0-rc.3" resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.0.0-rc.3.tgz#c2ee83f8e5c0c387279a8c48e06fef2e32027004" dependencies: chalk "^2.0.0" esutils "^2.0.2" js-tokens "^4.0.0" "@types/estree@0.0.39": version "0.0.39" resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.39.tgz#e177e699ee1b8c22d23174caaa7422644389509f" "@types/node@*": version "10.9.1" resolved "https://registry.yarnpkg.com/@types/node/-/node-10.9.1.tgz#06f002136fbcf51e730995149050bb3c45ee54e6" acorn-jsx@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-4.1.1.tgz#e8e41e48ea2fe0c896740610ab6a4ffd8add225e" dependencies: acorn "^5.0.3" acorn@^5.0.3, acorn@^5.6.0: version "5.7.2" resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.7.2.tgz#91fa871883485d06708800318404e72bfb26dcc5" ajv-keywords@^3.0.0: version "3.2.0" resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-3.2.0.tgz#e86b819c602cf8821ad637413698f1dec021847a" ajv@^6.0.1, ajv@^6.5.0: version "6.5.3" resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.5.3.tgz#71a569d189ecf4f4f321224fecb166f071dd90f9" dependencies: fast-deep-equal "^2.0.1" fast-json-stable-stringify "^2.0.0" json-schema-traverse "^0.4.1" uri-js "^4.2.2" ansi-escapes@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-3.1.0.tgz#f73207bb81207d75fd6c83f125af26eea378ca30" ansi-regex@^2.0.0: version "2.1.1" resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df" ansi-regex@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.0.tgz#ed0317c322064f79466c02966bddb605ab37d998" ansi-styles@^2.2.1: version "2.2.1" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe" ansi-styles@^3.2.1: version "3.2.1" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" dependencies: color-convert "^1.9.0" argparse@^1.0.7: version "1.0.10" resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" dependencies: sprintf-js "~1.0.2" array-union@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/array-union/-/array-union-1.0.2.tgz#9a34410e4f4e3da23dea375be5be70f24778ec39" dependencies: array-uniq "^1.0.1" array-uniq@^1.0.1: version "1.0.3" resolved "https://registry.yarnpkg.com/array-uniq/-/array-uniq-1.0.3.tgz#af6ac877a25cc7f74e058894753858dfdb24fdb6" arrify@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d" babel-code-frame@^6.26.0: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.26.0.tgz#63fd43f7dc1e3bb7ce35947db8fe369a3f58c74b" dependencies: chalk "^1.1.3" esutils "^2.0.2" js-tokens "^3.0.2" balanced-match@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" brace-expansion@^1.1.7: version "1.1.11" resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" dependencies: balanced-match "^1.0.0" concat-map "0.0.1" buffer-from@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" caller-path@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/caller-path/-/caller-path-0.1.0.tgz#94085ef63581ecd3daa92444a8fe94e82577751f" dependencies: callsites "^0.2.0" callsites@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/callsites/-/callsites-0.2.0.tgz#afab96262910a7f33c19a5775825c69f34e350ca" chalk@^1.1.3: version "1.1.3" resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98" dependencies: ansi-styles "^2.2.1" escape-string-regexp "^1.0.2" has-ansi "^2.0.0" strip-ansi "^3.0.0" supports-color "^2.0.0" chalk@^2.0.0, chalk@^2.1.0: version "2.4.1" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.1.tgz#18c49ab16a037b6eb0152cc83e3471338215b66e" dependencies: ansi-styles "^3.2.1" escape-string-regexp "^1.0.5" supports-color "^5.3.0" chardet@^0.4.0: version "0.4.2" resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.4.2.tgz#b5473b33dc97c424e5d98dc87d55d4d8a29c8bf2" circular-json@^0.3.1: version "0.3.3" resolved "https://registry.yarnpkg.com/circular-json/-/circular-json-0.3.3.tgz#815c99ea84f6809529d2f45791bdf82711352d66" cli-cursor@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-2.1.0.tgz#b35dac376479facc3e94747d41d0d0f5238ffcb5" dependencies: restore-cursor "^2.0.0" cli-width@^2.0.0: version "2.2.0" resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.2.0.tgz#ff19ede8a9a5e579324147b0c11f0fbcbabed639" color-convert@^1.9.0: version "1.9.2" resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.2.tgz#49881b8fba67df12a96bdf3f56c0aab9e7913147" dependencies: color-name "1.1.1" color-name@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.1.tgz#4b1415304cf50028ea81643643bd82ea05803689" commander@~2.16.0: version "2.16.0" resolved "https://registry.yarnpkg.com/commander/-/commander-2.16.0.tgz#f16390593996ceb4f3eeb020b31d78528f7f8a50" concat-map@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" cross-spawn@^6.0.5: version "6.0.5" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4" dependencies: nice-try "^1.0.4" path-key "^2.0.1" semver "^5.5.0" shebang-command "^1.2.0" which "^1.2.9" debug@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" dependencies: ms "2.0.0" deep-equal@~1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-1.0.1.tgz#f5d260292b660e084eff4cdbc9f08ad3247448b5" deep-is@~0.1.3: version "0.1.3" resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34" define-properties@^1.1.2: version "1.1.3" resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.3.tgz#cf88da6cbee26fe6db7094f61d870cbd84cee9f1" dependencies: object-keys "^1.0.12" defined@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/defined/-/defined-1.0.0.tgz#c98d9bcef75674188e110969151199e39b1fa693" del@^2.0.2: version "2.2.2" resolved "https://registry.yarnpkg.com/del/-/del-2.2.2.tgz#c12c981d067846c84bcaf862cff930d907ffd1a8" dependencies: globby "^5.0.0" is-path-cwd "^1.0.0" is-path-in-cwd "^1.0.0" object-assign "^4.0.1" pify "^2.0.0" pinkie-promise "^2.0.0" rimraf "^2.2.8" doctrine@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-2.1.0.tgz#5cd01fc101621b42c4cd7f5d1a66243716d3f39d" dependencies: esutils "^2.0.2" es-abstract@^1.5.0: version "1.12.0" resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.12.0.tgz#9dbbdd27c6856f0001421ca18782d786bf8a6165" dependencies: es-to-primitive "^1.1.1" function-bind "^1.1.1" has "^1.0.1" is-callable "^1.1.3" is-regex "^1.0.4" es-to-primitive@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.1.1.tgz#45355248a88979034b6792e19bb81f2b7975dd0d" dependencies: is-callable "^1.1.1" is-date-object "^1.0.1" is-symbol "^1.0.1" escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" eslint-scope@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-4.0.0.tgz#50bf3071e9338bcdc43331794a0cb533f0136172" dependencies: esrecurse "^4.1.0" estraverse "^4.1.1" eslint-utils@^1.3.1: version "1.3.1" resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-1.3.1.tgz#9a851ba89ee7c460346f97cf8939c7298827e512" eslint-visitor-keys@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#3f3180fb2e291017716acb4c9d6d5b5c34a6a81d" eslint@5: version "5.4.0" resolved "https://registry.yarnpkg.com/eslint/-/eslint-5.4.0.tgz#d068ec03006bb9e06b429dc85f7e46c1b69fac62" dependencies: ajv "^6.5.0" babel-code-frame "^6.26.0" chalk "^2.1.0" cross-spawn "^6.0.5" debug "^3.1.0" doctrine "^2.1.0" eslint-scope "^4.0.0" eslint-utils "^1.3.1" eslint-visitor-keys "^1.0.0" espree "^4.0.0" esquery "^1.0.1" esutils "^2.0.2" file-entry-cache "^2.0.0" functional-red-black-tree "^1.0.1" glob "^7.1.2" globals "^11.7.0" ignore "^4.0.2" imurmurhash "^0.1.4" inquirer "^5.2.0" is-resolvable "^1.1.0" js-yaml "^3.11.0" json-stable-stringify-without-jsonify "^1.0.1" levn "^0.3.0" lodash "^4.17.5" minimatch "^3.0.4" mkdirp "^0.5.1" natural-compare "^1.4.0" optionator "^0.8.2" path-is-inside "^1.0.2" pluralize "^7.0.0" progress "^2.0.0" regexpp "^2.0.0" require-uncached "^1.0.3" semver "^5.5.0" strip-ansi "^4.0.0" strip-json-comments "^2.0.1" table "^4.0.3" text-table "^0.2.0" espree@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/espree/-/espree-4.0.0.tgz#253998f20a0f82db5d866385799d912a83a36634" dependencies: acorn "^5.6.0" acorn-jsx "^4.1.1" esprima@^4.0.0: version "4.0.1" resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" esquery@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.0.1.tgz#406c51658b1f5991a5f9b62b1dc25b00e3e5c708" dependencies: estraverse "^4.0.0" esrecurse@^4.1.0: version "4.2.1" resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.2.1.tgz#007a3b9fdbc2b3bb87e4879ea19c92fdbd3942cf" dependencies: estraverse "^4.1.0" estraverse@^4.0.0, estraverse@^4.1.0, estraverse@^4.1.1: version "4.2.0" resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.2.0.tgz#0dee3fed31fcd469618ce7342099fc1afa0bdb13" esutils@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b" external-editor@^2.1.0: version "2.2.0" resolved "https://registry.yarnpkg.com/external-editor/-/external-editor-2.2.0.tgz#045511cfd8d133f3846673d1047c154e214ad3d5" dependencies: chardet "^0.4.0" iconv-lite "^0.4.17" tmp "^0.0.33" fast-deep-equal@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz#7b05218ddf9667bf7f370bf7fdb2cb15fdd0aa49" fast-json-stable-stringify@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz#d5142c0caee6b1189f87d3a76111064f86c8bbf2" fast-levenshtein@~2.0.4: version "2.0.6" resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" figures@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/figures/-/figures-2.0.0.tgz#3ab1a2d2a62c8bfb431a0c94cb797a2fce27c962" dependencies: escape-string-regexp "^1.0.5" file-entry-cache@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-2.0.0.tgz#c392990c3e684783d838b8c84a45d8a048458361" dependencies: flat-cache "^1.2.1" object-assign "^4.0.1" flat-cache@^1.2.1: version "1.3.0" resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-1.3.0.tgz#d3030b32b38154f4e3b7e9c709f490f7ef97c481" dependencies: circular-json "^0.3.1" del "^2.0.2" graceful-fs "^4.1.2" write "^0.2.1" for-each@~0.3.3: version "0.3.3" resolved "https://registry.yarnpkg.com/for-each/-/for-each-0.3.3.tgz#69b447e88a0a5d32c3e7084f3f1710034b21376e" dependencies: is-callable "^1.1.3" fs.realpath@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" function-bind@^1.0.2, function-bind@^1.1.1, function-bind@~1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" functional-red-black-tree@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz#1b0ab3bd553b2a0d6399d29c0e3ea0b252078327" glob@^7.0.3, glob@^7.0.5, glob@^7.1.2, glob@~7.1.2: version "7.1.2" resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15" dependencies: fs.realpath "^1.0.0" inflight "^1.0.4" inherits "2" minimatch "^3.0.4" once "^1.3.0" path-is-absolute "^1.0.0" globals@^11.7.0: version "11.7.0" resolved "https://registry.yarnpkg.com/globals/-/globals-11.7.0.tgz#a583faa43055b1aca771914bf68258e2fc125673" globby@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/globby/-/globby-5.0.0.tgz#ebd84667ca0dbb330b99bcfc68eac2bc54370e0d" dependencies: array-union "^1.0.1" arrify "^1.0.0" glob "^7.0.3" object-assign "^4.0.1" pify "^2.0.0" pinkie-promise "^2.0.0" graceful-fs@^4.1.2: version "4.1.11" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" has-ansi@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91" dependencies: ansi-regex "^2.0.0" has-flag@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" has@^1.0.1, has@~1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796" dependencies: function-bind "^1.1.1" iconv-lite@^0.4.17: version "0.4.24" resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" dependencies: safer-buffer ">= 2.1.2 < 3" ignore@^4.0.2: version "4.0.6" resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc" imurmurhash@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" inflight@^1.0.4: version "1.0.6" resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" dependencies: once "^1.3.0" wrappy "1" inherits@2, inherits@~2.0.3: version "2.0.3" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" inquirer@^5.2.0: version "5.2.0" resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-5.2.0.tgz#db350c2b73daca77ff1243962e9f22f099685726" dependencies: ansi-escapes "^3.0.0" chalk "^2.0.0" cli-cursor "^2.1.0" cli-width "^2.0.0" external-editor "^2.1.0" figures "^2.0.0" lodash "^4.3.0" mute-stream "0.0.7" run-async "^2.2.0" rxjs "^5.5.2" string-width "^2.1.0" strip-ansi "^4.0.0" through "^2.3.6" is-callable@^1.1.1, is-callable@^1.1.3: version "1.1.4" resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.4.tgz#1e1adf219e1eeb684d691f9d6a05ff0d30a24d75" is-date-object@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.1.tgz#9aa20eb6aeebbff77fbd33e74ca01b33581d3a16" is-fullwidth-code-point@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f" is-path-cwd@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-path-cwd/-/is-path-cwd-1.0.0.tgz#d225ec23132e89edd38fda767472e62e65f1106d" is-path-in-cwd@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/is-path-in-cwd/-/is-path-in-cwd-1.0.1.tgz#5ac48b345ef675339bd6c7a48a912110b241cf52" dependencies: is-path-inside "^1.0.0" is-path-inside@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-1.0.1.tgz#8ef5b7de50437a3fdca6b4e865ef7aa55cb48036" dependencies: path-is-inside "^1.0.1" is-promise@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/is-promise/-/is-promise-2.1.0.tgz#79a2a9ece7f096e80f36d2b2f3bc16c1ff4bf3fa" is-regex@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.0.4.tgz#5517489b547091b0930e095654ced25ee97e9491" dependencies: has "^1.0.1" is-resolvable@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/is-resolvable/-/is-resolvable-1.1.0.tgz#fb18f87ce1feb925169c9a407c19318a3206ed88" is-symbol@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.1.tgz#3cc59f00025194b6ab2e38dbae6689256b660572" isexe@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" js-tokens@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b" js-tokens@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" js-yaml@^3.11.0: version "3.12.0" resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.12.0.tgz#eaed656ec8344f10f527c6bfa1b6e2244de167d1" dependencies: argparse "^1.0.7" esprima "^4.0.0" json-schema-traverse@^0.4.1: version "0.4.1" resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" json-stable-stringify-without-jsonify@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651" levn@^0.3.0, levn@~0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/levn/-/levn-0.3.0.tgz#3b09924edf9f083c0490fdd4c0bc4421e04764ee" dependencies: prelude-ls "~1.1.2" type-check "~0.3.2" lodash@^4.17.4, lodash@^4.17.5, lodash@^4.3.0: version "4.17.10" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.10.tgz#1b7793cf7259ea38fb3661d4d38b3260af8ae4e7" mimic-fn@^1.0.0: version "1.2.0" resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.2.0.tgz#820c86a39334640e99516928bd03fca88057d022" minimatch@^3.0.4: version "3.0.4" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" dependencies: brace-expansion "^1.1.7" minimist@0.0.8: version "0.0.8" resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" minimist@~1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" mkdirp@^0.5.1: version "0.5.1" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" dependencies: minimist "0.0.8" ms@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" mute-stream@0.0.7: version "0.0.7" resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.7.tgz#3075ce93bc21b8fab43e1bc4da7e8115ed1e7bab" natural-compare@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" nice-try@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.4.tgz#d93962f6c52f2c1558c0fbda6d512819f1efe1c4" object-assign@^4.0.1: version "4.1.1" resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" object-inspect@~1.6.0: version "1.6.0" resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.6.0.tgz#c70b6cbf72f274aab4c34c0c82f5167bf82cf15b" object-keys@^1.0.12: version "1.0.12" resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.0.12.tgz#09c53855377575310cca62f55bb334abff7b3ed2" once@^1.3.0: version "1.4.0" resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" dependencies: wrappy "1" onetime@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/onetime/-/onetime-2.0.1.tgz#067428230fd67443b2794b22bba528b6867962d4" dependencies: mimic-fn "^1.0.0" optionator@^0.8.2: version "0.8.2" resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.2.tgz#364c5e409d3f4d6301d6c0b4c05bba50180aeb64" dependencies: deep-is "~0.1.3" fast-levenshtein "~2.0.4" levn "~0.3.0" prelude-ls "~1.1.2" type-check "~0.3.2" wordwrap "~1.0.0" os-tmpdir@~1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" path-is-absolute@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" path-is-inside@^1.0.1, path-is-inside@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/path-is-inside/-/path-is-inside-1.0.2.tgz#365417dede44430d1c11af61027facf074bdfc53" path-key@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40" path-parse@^1.0.5: version "1.0.6" resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c" pify@^2.0.0: version "2.3.0" resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c" pinkie-promise@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/pinkie-promise/-/pinkie-promise-2.0.1.tgz#2135d6dfa7a358c069ac9b178776288228450ffa" dependencies: pinkie "^2.0.0" pinkie@^2.0.0: version "2.0.4" resolved "https://registry.yarnpkg.com/pinkie/-/pinkie-2.0.4.tgz#72556b80cfa0d48a974e80e77248e80ed4f7f870" pluralize@^7.0.0: version "7.0.0" resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-7.0.0.tgz#298b89df8b93b0221dbf421ad2b1b1ea23fc6777" prelude-ls@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" progress@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.0.tgz#8a1be366bf8fc23db2bd23f10c6fe920b4389d1f" punycode@^2.1.0: version "2.1.1" resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" regexpp@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-2.0.0.tgz#b2a7534a85ca1b033bcf5ce9ff8e56d4e0755365" require-uncached@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/require-uncached/-/require-uncached-1.0.3.tgz#4e0d56d6c9662fd31e43011c4b95aa49955421d3" dependencies: caller-path "^0.1.0" resolve-from "^1.0.0" resolve-from@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-1.0.1.tgz#26cbfe935d1aeeeabb29bc3fe5aeb01e93d44226" resolve@~1.7.1: version "1.7.1" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.7.1.tgz#aadd656374fd298aee895bc026b8297418677fd3" dependencies: path-parse "^1.0.5" restore-cursor@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-2.0.0.tgz#9f7ee287f82fd326d4fd162923d62129eee0dfaf" dependencies: onetime "^2.0.0" signal-exit "^3.0.2" resumer@~0.0.0: version "0.0.0" resolved "https://registry.yarnpkg.com/resumer/-/resumer-0.0.0.tgz#f1e8f461e4064ba39e82af3cdc2a8c893d076759" dependencies: through "~2.3.4" rimraf@^2.2.8: version "2.6.2" resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.2.tgz#2ed8150d24a16ea8651e6d6ef0f47c4158ce7a36" dependencies: glob "^7.0.5" rollup-plugin-terser@1: version "1.0.1" resolved "https://registry.yarnpkg.com/rollup-plugin-terser/-/rollup-plugin-terser-1.0.1.tgz#ba5f497cbc9aa38ba19d3ee2167c04ea3ed279af" dependencies: "@babel/code-frame" "^7.0.0-beta.47" terser "^3.7.5" rollup@0.64: version "0.64.1" resolved "https://registry.yarnpkg.com/rollup/-/rollup-0.64.1.tgz#9188ee368e5fcd43ffbc00ec414e72eeb5de87ba" dependencies: "@types/estree" "0.0.39" "@types/node" "*" run-async@^2.2.0: version "2.3.0" resolved "https://registry.yarnpkg.com/run-async/-/run-async-2.3.0.tgz#0371ab4ae0bdd720d4166d7dfda64ff7a445a6c0" dependencies: is-promise "^2.1.0" rxjs@^5.5.2: version "5.5.11" resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-5.5.11.tgz#f733027ca43e3bec6b994473be4ab98ad43ced87" dependencies: symbol-observable "1.0.1" "safer-buffer@>= 2.1.2 < 3": version "2.1.2" resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" semver@^5.5.0: version "5.5.1" resolved "https://registry.yarnpkg.com/semver/-/semver-5.5.1.tgz#7dfdd8814bdb7cabc7be0fb1d734cfb66c940477" shebang-command@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea" dependencies: shebang-regex "^1.0.0" shebang-regex@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3" signal-exit@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d" slice-ansi@1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-1.0.0.tgz#044f1a49d8842ff307aad6b505ed178bd950134d" dependencies: is-fullwidth-code-point "^2.0.0" source-map-support@~0.5.6: version "0.5.9" resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.9.tgz#41bc953b2534267ea2d605bccfa7bfa3111ced5f" dependencies: buffer-from "^1.0.0" source-map "^0.6.0" source-map@^0.6.0, source-map@~0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" sprintf-js@~1.0.2: version "1.0.3" resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" string-width@^2.1.0, string-width@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e" dependencies: is-fullwidth-code-point "^2.0.0" strip-ansi "^4.0.0" string.prototype.trim@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/string.prototype.trim/-/string.prototype.trim-1.1.2.tgz#d04de2c89e137f4d7d206f086b5ed2fae6be8cea" dependencies: define-properties "^1.1.2" es-abstract "^1.5.0" function-bind "^1.0.2" strip-ansi@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-3.0.1.tgz#6a385fb8853d952d5ff05d0e8aaf94278dc63dcf" dependencies: ansi-regex "^2.0.0" strip-ansi@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-4.0.0.tgz#a8479022eb1ac368a871389b635262c505ee368f" dependencies: ansi-regex "^3.0.0" strip-json-comments@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" supports-color@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" supports-color@^5.3.0: version "5.5.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" dependencies: has-flag "^3.0.0" symbol-observable@1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.0.1.tgz#8340fc4702c3122df5d22288f88283f513d3fdd4" table@^4.0.3: version "4.0.3" resolved "https://registry.yarnpkg.com/table/-/table-4.0.3.tgz#00b5e2b602f1794b9acaf9ca908a76386a7813bc" dependencies: ajv "^6.0.1" ajv-keywords "^3.0.0" chalk "^2.1.0" lodash "^4.17.4" slice-ansi "1.0.0" string-width "^2.1.1" tape@4: version "4.9.1" resolved "https://registry.yarnpkg.com/tape/-/tape-4.9.1.tgz#1173d7337e040c76fbf42ec86fcabedc9b3805c9" dependencies: deep-equal "~1.0.1" defined "~1.0.0" for-each "~0.3.3" function-bind "~1.1.1" glob "~7.1.2" has "~1.0.3" inherits "~2.0.3" minimist "~1.2.0" object-inspect "~1.6.0" resolve "~1.7.1" resumer "~0.0.0" string.prototype.trim "~1.1.2" through "~2.3.8" terser@^3.7.5: version "3.8.1" resolved "https://registry.yarnpkg.com/terser/-/terser-3.8.1.tgz#cb70070ac9e0a71add169dfb63c0a64fca2738ac" dependencies: commander "~2.16.0" source-map "~0.6.1" source-map-support "~0.5.6" text-table@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" through@^2.3.6, through@~2.3.4, through@~2.3.8: version "2.3.8" resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" tmp@^0.0.33: version "0.0.33" resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9" dependencies: os-tmpdir "~1.0.2" type-check@~0.3.2: version "0.3.2" resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.3.2.tgz#5884cab512cf1d355e3fb784f30804b2b520db72" dependencies: prelude-ls "~1.1.2" uri-js@^4.2.2: version "4.2.2" resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.2.2.tgz#94c540e1ff772956e2299507c010aea6c8838eb0" dependencies: punycode "^2.1.0" which@^1.2.9: version "1.3.1" resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" dependencies: isexe "^2.0.0" wordwrap@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb" wrappy@1: version "1.0.2" resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" write@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/write/-/write-0.2.1.tgz#5fc03828e264cea3fe91455476f7a3c566cb0757" dependencies: mkdirp "^0.5.1"