Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

d3-interpolate

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

d3-interpolate - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

640

build/interpolate.js

@@ -7,3 +7,3 @@ (function (global, factory) {

var interpolateNumber = function(a, b) {
function interpolateNumber(a, b) {
return a = +a, b -= a, function(t) {

@@ -14,3 +14,3 @@ return a + b * t;

var interpolate = function(a, b) {
function interpolate(a, b) {
var i = interpolators.length, f;

@@ -21,3 +21,3 @@ while (--i >= 0 && !(f = interpolators[i](a, b)));

var interpolateObject = function(a, b) {
function interpolateObject(a, b) {
var i = {},

@@ -45,5 +45,6 @@ c = {},

};
}// TODO sparse arrays?
}
var interpolateArray = function(a, b) {
// TODO sparse arrays?
function interpolateArray(a, b) {
var x = [],

@@ -66,21 +67,11 @@ c = [],

function format(r, g, b) {
if (isNaN(r)) r = 0;
if (isNaN(g)) g = 0;
if (isNaN(b)) b = 0;
return "#"
+ (r < 16 ? "0" + r.toString(16) : r.toString(16))
+ (g < 16 ? "0" + g.toString(16) : g.toString(16))
+ (b < 16 ? "0" + b.toString(16) : b.toString(16));
}
function Rgb(r, g, b) {
this.r = Math.max(0, Math.min(255, Math.round(r)));
this.g = Math.max(0, Math.min(255, Math.round(g)));
this.b = Math.max(0, Math.min(255, Math.round(b)));
}
function Color() {}
Color.prototype = {
function Color() {}var reHex3 = /^#([0-9a-f]{3})$/;
var reHex6 = /^#([0-9a-f]{6})$/;
var reRgbInteger = /^rgb\(\s*([-+]?\d+)\s*,\s*([-+]?\d+)\s*,\s*([-+]?\d+)\s*\)$/;
var reRgbPercent = /^rgb\(\s*([-+]?\d+(?:\.\d+)?)%\s*,\s*([-+]?\d+(?:\.\d+)?)%\s*,\s*([-+]?\d+(?:\.\d+)?)%\s*\)$/;
var reHslPercent = /^hsl\(\s*([-+]?\d+(?:\.\d+)?)\s*,\s*([-+]?\d+(?:\.\d+)?)%\s*,\s*([-+]?\d+(?:\.\d+)?)%\s*\)$/;
color.prototype = Color.prototype = {
displayable: function() {
return this.rgb().displayable();
},
toString: function() {

@@ -91,14 +82,190 @@ return this.rgb() + "";

var _prototype = Rgb.prototype = new Color;
function color(format) {
var m;
format = (format + "").trim().toLowerCase();
return (m = reHex3.exec(format)) ? (m = parseInt(m[1], 16), rgb((m >> 8 & 0xf) | (m >> 4 & 0x0f0), (m >> 4 & 0xf) | (m & 0xf0), ((m & 0xf) << 4) | (m & 0xf))) // #f00
: (m = reHex6.exec(format)) ? rgbn(parseInt(m[1], 16)) // #ff0000
: (m = reRgbInteger.exec(format)) ? rgb(m[1], m[2], m[3]) // rgb(255,0,0)
: (m = reRgbPercent.exec(format)) ? rgb(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100) // rgb(100%,0%,0%)
: (m = reHslPercent.exec(format)) ? hsl(m[1], m[2] / 100, m[3] / 100) // hsl(120,50%,50%)
: named.hasOwnProperty(format) ? rgbn(named[format])
: null;
}function rgbn(n) {
return rgb(n >> 16 & 0xff, n >> 8 & 0xff, n & 0xff);
}
var darker = .7;
_prototype.darker = function(k) {
k = k == null ? darker : Math.pow(darker, k);
return new Rgb(this.r * k, this.g * k, this.b * k);
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
};
var darker = .7;
var brighter = 1 / darker;
_prototype.brighter = function(k) {
function rgb(r, g, b) {
if (arguments.length === 1) {
if (!(r instanceof Color)) r = color(r);
if (r) {
r = r.rgb();
b = r.b;
g = r.g;
r = r.r;
} else {
r = g = b = NaN;
}
}
return new Rgb(r, g, b);
}function Rgb(r, g, b) {
this.r = +r;
this.g = +g;
this.b = +b;
}var ____prototype = rgb.prototype = Rgb.prototype = new Color;
____prototype.brighter = function(k) {
k = k == null ? brighter : Math.pow(brighter, k);

@@ -108,203 +275,29 @@ return new Rgb(this.r * k, this.g * k, this.b * k);

_prototype.rgb = function() {
____prototype.darker = function(k) {
k = k == null ? darker : Math.pow(darker, k);
return new Rgb(this.r * k, this.g * k, this.b * k);
};
____prototype.rgb = function() {
return this;
};
_prototype.toString = function() {
return format(this.r, this.g, this.b);
____prototype.displayable = function() {
return (0 <= this.r && this.r <= 255)
&& (0 <= this.g && this.g <= 255)
&& (0 <= this.b && this.b <= 255);
};
var named = (new Map)
.set("aliceblue", 0xf0f8ff)
.set("antiquewhite", 0xfaebd7)
.set("aqua", 0x00ffff)
.set("aquamarine", 0x7fffd4)
.set("azure", 0xf0ffff)
.set("beige", 0xf5f5dc)
.set("bisque", 0xffe4c4)
.set("black", 0x000000)
.set("blanchedalmond", 0xffebcd)
.set("blue", 0x0000ff)
.set("blueviolet", 0x8a2be2)
.set("brown", 0xa52a2a)
.set("burlywood", 0xdeb887)
.set("cadetblue", 0x5f9ea0)
.set("chartreuse", 0x7fff00)
.set("chocolate", 0xd2691e)
.set("coral", 0xff7f50)
.set("cornflowerblue", 0x6495ed)
.set("cornsilk", 0xfff8dc)
.set("crimson", 0xdc143c)
.set("cyan", 0x00ffff)
.set("darkblue", 0x00008b)
.set("darkcyan", 0x008b8b)
.set("darkgoldenrod", 0xb8860b)
.set("darkgray", 0xa9a9a9)
.set("darkgreen", 0x006400)
.set("darkgrey", 0xa9a9a9)
.set("darkkhaki", 0xbdb76b)
.set("darkmagenta", 0x8b008b)
.set("darkolivegreen", 0x556b2f)
.set("darkorange", 0xff8c00)
.set("darkorchid", 0x9932cc)
.set("darkred", 0x8b0000)
.set("darksalmon", 0xe9967a)
.set("darkseagreen", 0x8fbc8f)
.set("darkslateblue", 0x483d8b)
.set("darkslategray", 0x2f4f4f)
.set("darkslategrey", 0x2f4f4f)
.set("darkturquoise", 0x00ced1)
.set("darkviolet", 0x9400d3)
.set("deeppink", 0xff1493)
.set("deepskyblue", 0x00bfff)
.set("dimgray", 0x696969)
.set("dimgrey", 0x696969)
.set("dodgerblue", 0x1e90ff)
.set("firebrick", 0xb22222)
.set("floralwhite", 0xfffaf0)
.set("forestgreen", 0x228b22)
.set("fuchsia", 0xff00ff)
.set("gainsboro", 0xdcdcdc)
.set("ghostwhite", 0xf8f8ff)
.set("gold", 0xffd700)
.set("goldenrod", 0xdaa520)
.set("gray", 0x808080)
.set("green", 0x008000)
.set("greenyellow", 0xadff2f)
.set("grey", 0x808080)
.set("honeydew", 0xf0fff0)
.set("hotpink", 0xff69b4)
.set("indianred", 0xcd5c5c)
.set("indigo", 0x4b0082)
.set("ivory", 0xfffff0)
.set("khaki", 0xf0e68c)
.set("lavender", 0xe6e6fa)
.set("lavenderblush", 0xfff0f5)
.set("lawngreen", 0x7cfc00)
.set("lemonchiffon", 0xfffacd)
.set("lightblue", 0xadd8e6)
.set("lightcoral", 0xf08080)
.set("lightcyan", 0xe0ffff)
.set("lightgoldenrodyellow", 0xfafad2)
.set("lightgray", 0xd3d3d3)
.set("lightgreen", 0x90ee90)
.set("lightgrey", 0xd3d3d3)
.set("lightpink", 0xffb6c1)
.set("lightsalmon", 0xffa07a)
.set("lightseagreen", 0x20b2aa)
.set("lightskyblue", 0x87cefa)
.set("lightslategray", 0x778899)
.set("lightslategrey", 0x778899)
.set("lightsteelblue", 0xb0c4de)
.set("lightyellow", 0xffffe0)
.set("lime", 0x00ff00)
.set("limegreen", 0x32cd32)
.set("linen", 0xfaf0e6)
.set("magenta", 0xff00ff)
.set("maroon", 0x800000)
.set("mediumaquamarine", 0x66cdaa)
.set("mediumblue", 0x0000cd)
.set("mediumorchid", 0xba55d3)
.set("mediumpurple", 0x9370db)
.set("mediumseagreen", 0x3cb371)
.set("mediumslateblue", 0x7b68ee)
.set("mediumspringgreen", 0x00fa9a)
.set("mediumturquoise", 0x48d1cc)
.set("mediumvioletred", 0xc71585)
.set("midnightblue", 0x191970)
.set("mintcream", 0xf5fffa)
.set("mistyrose", 0xffe4e1)
.set("moccasin", 0xffe4b5)
.set("navajowhite", 0xffdead)
.set("navy", 0x000080)
.set("oldlace", 0xfdf5e6)
.set("olive", 0x808000)
.set("olivedrab", 0x6b8e23)
.set("orange", 0xffa500)
.set("orangered", 0xff4500)
.set("orchid", 0xda70d6)
.set("palegoldenrod", 0xeee8aa)
.set("palegreen", 0x98fb98)
.set("paleturquoise", 0xafeeee)
.set("palevioletred", 0xdb7093)
.set("papayawhip", 0xffefd5)
.set("peachpuff", 0xffdab9)
.set("peru", 0xcd853f)
.set("pink", 0xffc0cb)
.set("plum", 0xdda0dd)
.set("powderblue", 0xb0e0e6)
.set("purple", 0x800080)
.set("rebeccapurple", 0x663399)
.set("red", 0xff0000)
.set("rosybrown", 0xbc8f8f)
.set("royalblue", 0x4169e1)
.set("saddlebrown", 0x8b4513)
.set("salmon", 0xfa8072)
.set("sandybrown", 0xf4a460)
.set("seagreen", 0x2e8b57)
.set("seashell", 0xfff5ee)
.set("sienna", 0xa0522d)
.set("silver", 0xc0c0c0)
.set("skyblue", 0x87ceeb)
.set("slateblue", 0x6a5acd)
.set("slategray", 0x708090)
.set("slategrey", 0x708090)
.set("snow", 0xfffafa)
.set("springgreen", 0x00ff7f)
.set("steelblue", 0x4682b4)
.set("tan", 0xd2b48c)
.set("teal", 0x008080)
.set("thistle", 0xd8bfd8)
.set("tomato", 0xff6347)
.set("turquoise", 0x40e0d0)
.set("violet", 0xee82ee)
.set("wheat", 0xf5deb3)
.set("white", 0xffffff)
.set("whitesmoke", 0xf5f5f5)
.set("yellow", 0xffff00)
.set("yellowgreen", 0x9acd32);
function rgbn(n) {
return rgb(n >> 16 & 0xff, n >> 8 & 0xff, n & 0xff);
}
function Hsl(h, s, l) {
this.h = +h;
this.s = Math.max(0, Math.min(1, +s));
this.l = Math.max(0, Math.min(1, +l));
}
var prototype = Hsl.prototype = new Color;
prototype.brighter = function(k) {
k = k == null ? brighter : Math.pow(brighter, k);
return new Hsl(this.h, this.s, this.l * k);
____prototype.toString = function() {
return _format(this.r, this.g, this.b);
};
prototype.darker = function(k) {
k = k == null ? darker : Math.pow(darker, k);
return new Hsl(this.h, this.s, this.l * k);
};/* 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;
function _format(r, g, b) {
return "#"
+ (isNaN(r) ? "00" : (r = Math.round(r)) < 16 ? "0" + Math.max(0, r).toString(16) : Math.min(255, r).toString(16))
+ (isNaN(g) ? "00" : (g = Math.round(g)) < 16 ? "0" + Math.max(0, g).toString(16) : Math.min(255, g).toString(16))
+ (isNaN(b) ? "00" : (b = Math.round(b)) < 16 ? "0" + Math.max(0, b).toString(16) : Math.min(255, b).toString(16));
}
prototype.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 <= .5 ? l * (1 + s) : l + s - 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)
);
};
var hsl = function(h, s, l) {
function hsl(h, s, l) {
if (arguments.length === 1) {

@@ -343,38 +336,102 @@ if (h instanceof Hsl) {

return new Hsl(h, s, l);
}
}function Hsl(h, s, l) {
this.h = +h;
this.s = +s;
this.l = +l;
}var ___prototype = hsl.prototype = Hsl.prototype = new Color;
var reHex3 = /^#([0-9a-f]{3})$/,
reHex6 = /^#([0-9a-f]{6})$/,
reRgbInteger = /^rgb\(\s*([-+]?\d+)\s*,\s*([-+]?\d+)\s*,\s*([-+]?\d+)\s*\)$/,
reRgbPercent = /^rgb\(\s*([-+]?\d+(?:\.\d+)?)%\s*,\s*([-+]?\d+(?:\.\d+)?)%\s*,\s*([-+]?\d+(?:\.\d+)?)%\s*\)$/,
reHslPercent = /^hsl\(\s*([-+]?\d+(?:\.\d+)?)\s*,\s*([-+]?\d+(?:\.\d+)?)%\s*,\s*([-+]?\d+(?:\.\d+)?)%\s*\)$/;
___prototype.brighter = function(k) {
k = k == null ? brighter : Math.pow(brighter, k);
return new Hsl(this.h, this.s, this.l * k);
};
var color = function(format) {
var m;
format = (format + "").trim().toLowerCase();
return (m = reHex3.exec(format)) ? (m = parseInt(m[1], 16), rgb((m >> 8 & 0xf) | (m >> 4 & 0x0f0), (m >> 4 & 0xf) | (m & 0xf0), ((m & 0xf) << 4) | (m & 0xf))) // #f00
: (m = reHex6.exec(format)) ? rgbn(parseInt(m[1], 16)) // #ff0000
: (m = reRgbInteger.exec(format)) ? rgb(m[1], m[2], m[3]) // rgb(255,0,0)
: (m = reRgbPercent.exec(format)) ? rgb(m[1] * 2.55, m[2] * 2.55, m[3] * 2.55) // rgb(100%,0%,0%)
: (m = reHslPercent.exec(format)) ? hsl(m[1], m[2] * .01, m[3] * .01) // hsl(120,50%,50%)
: named.has(format) ? rgbn(named.get(format))
: null;
___prototype.darker = function(k) {
k = k == null ? darker : Math.pow(darker, k);
return new Hsl(this.h, this.s, this.l * k);
};
___prototype.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 < .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)
);
};
___prototype.displayable = function() {
return (0 <= this.s && this.s <= 1 || isNaN(this.s))
&& (0 <= this.l && this.l <= 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;
}
var rgb = function(r, g, b) {
var deg2rad = Math.PI / 180;
var _rad2deg = 180 / Math.PI;
var A = -0.14861;
var B = +1.78277;
var C = -0.29227;
var D = -0.90649;
var E = +1.97294;
var ED = E * D;
var EB = E * B;
var BC_DA = B * C - D * A;
function cubehelix(h, s, l) {
if (arguments.length === 1) {
if (!(r instanceof Color)) r = color(r);
if (r) {
r = r.rgb();
b = r.b;
g = r.g;
r = r.r;
if (h instanceof Cubehelix) {
l = h.l;
s = h.s;
h = h.h;
} else {
r = g = b = NaN;
if (!(h instanceof Rgb)) h = rgb(h);
var r = h.r / 255, g = h.g / 255, b = h.b / 255;
l = (BC_DA * b + ED * r - EB * g) / (BC_DA + ED - EB);
var 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;
if (h < 0) h += 360;
}
}
return new Rgb(r, g, b);
}
return new Cubehelix(h, s, l);
}function Cubehelix(h, s, l) {
this.h = +h;
this.s = +s;
this.l = +l;
}var prototype = cubehelix.prototype = Cubehelix.prototype = new Color;
var interpolateRgb = function(a, b) {
prototype.brighter = function(k) {
k = k == null ? brighter : Math.pow(brighter, k);
return new Cubehelix(this.h, this.s, this.l * k);
};
prototype.darker = function(k) {
k = k == null ? darker : Math.pow(darker, k);
return new Cubehelix(this.h, this.s, this.l * k);
};
prototype.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))
);
};
function interpolateRgb(a, b) {
a = rgb(a);

@@ -389,6 +446,8 @@ b = rgb(b);

return function(t) {
return format(Math.round(ar + br * t), Math.round(ag + bg * t), Math.round(ab + bb * t));
return _format(Math.round(ar + br * t), Math.round(ag + bg * t), Math.round(ab + bb * t));
};
}
var reA = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g;
var reB = new RegExp(reA.source, "g");
function interpolate0(b) {

@@ -406,6 +465,3 @@ return function() {

var reA = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,
reB = new RegExp(reA.source, "g");
var interpolateString = function(a, b) {
function interpolateString(a, b) {
var bi = reA.lastIndex = reB.lastIndex = 0, // scan index for next number in b

@@ -468,6 +524,6 @@ am, // current match in a

];
var rho = Math.SQRT2,
rho2 = 2,
rho4 = 4;
var rho = Math.SQRT2;
var rho2 = 2;
var rho4 = 4;
function cosh(x) {

@@ -483,6 +539,7 @@ return ((x = Math.exp(x)) + 1 / x) / 2;

return ((x = Math.exp(2 * x)) - 1) / (x + 1);
}// p0 = [ux0, uy0, w0]
}
// p0 = [ux0, uy0, w0]
// p1 = [ux1, uy1, w1]
var interpolateZoom = function(p0, p1) {
function interpolateZoom(p0, p1) {
var ux0 = p0[0], uy0 = p0[1], w0 = p0[2],

@@ -528,27 +585,16 @@ ux1 = p1[0], uy1 = p1[1], w1 = p1[2],

var rad2deg = 180 / Math.PI,
identity = {a: 1, b: 0, c: 0, d: 1, e: 0, f: 0},
g;
function combine(a, b, k) {
a[0] += k * b[0];
a[1] += k * b[1];
return a;
}
function dot(a, b) {
return a[0] * b[0] + a[1] * b[1];
}
function normalize(a) {
var k = Math.sqrt(dot(a, a));
if (k) a[0] /= k, a[1] /= k;
return k;
}// Compute x-scale and normalize the first row.
var rad2deg = 180 / Math.PI;
var identity = {a: 1, b: 0, c: 0, d: 1, e: 0, f: 0};
var _g;
// Compute x-scale and normalize the first row.
// Compute shear and make second row orthogonal to first.
// Compute y-scale and normalize the second row.
// Finally, compute the rotation.
function Transform(string) {
if (!_g) _g = document.createElementNS("http://www.w3.org/2000/svg", "g");
if (string) _g.setAttribute("transform", string), t = _g.transform.baseVal.consolidate();
function Transform(m) {
var r0 = [m.a, m.b],
var t,
m = t ? t.matrix : identity,
r0 = [m.a, m.b],
r1 = [m.c, m.d],

@@ -572,17 +618,24 @@ kx = normalize(r0),

function transform(string) {
if (!g) g = document.createElementNS("http://www.w3.org/2000/svg", "g");
if (string != null) {
g.setAttribute("transform", string);
var t = g.transform.baseVal.consolidate();
}
return new Transform(t ? t.matrix : identity);
function dot(a, b) {
return a[0] * b[0] + a[1] * b[1];
}
var interpolateTransform = function(a, b) {
function normalize(a) {
var k = Math.sqrt(dot(a, a));
if (k) a[0] /= k, a[1] /= k;
return k;
}
function combine(a, b, k) {
a[0] += k * b[0];
a[1] += k * b[1];
return a;
}
function interpolateTransform(a, b) {
var s = [], // string constants and placeholders
q = [], // number interpolators
n,
A = transform(a),
B = transform(b),
A = new Transform(a),
B = new Transform(b),
ta = A.translate,

@@ -633,3 +686,4 @@ tb = B.translate,

}
var interpolateRound = function(a, b) {
function interpolateRound(a, b) {
return a = +a, b -= a, function(t) {

@@ -636,0 +690,0 @@ return Math.round(a + b * t);

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.interpolate={})}(this,function(e){"use strict";function t(e,t,n){return isNaN(e)&&(e=0),isNaN(t)&&(t=0),isNaN(n)&&(n=0),"#"+(16>e?"0"+e.toString(16):e.toString(16))+(16>t?"0"+t.toString(16):t.toString(16))+(16>n?"0"+n.toString(16):n.toString(16))}function n(e,t,n){this.r=Math.max(0,Math.min(255,Math.round(e))),this.g=Math.max(0,Math.min(255,Math.round(t))),this.b=Math.max(0,Math.min(255,Math.round(n)))}function r(){}function s(e){return X(e>>16&255,e>>8&255,255&e)}function a(e,t,n){this.h=+e,this.s=Math.max(0,Math.min(1,+t)),this.l=Math.max(0,Math.min(1,+n))}function i(e,t,n){return 255*(60>e?t+(n-t)*e/60:180>e?n:240>e?t+(n-t)*(240-e)/60:t)}function o(e){return function(){return e}}function u(e){return function(t){return e(t)+""}}function l(e){return((e=Math.exp(e))+1/e)/2}function h(e){return((e=Math.exp(e))-1/e)/2}function d(e){return((e=Math.exp(2*e))-1)/(e+1)}function g(e,t,n){return e[0]+=n*t[0],e[1]+=n*t[1],e}function c(e,t){return e[0]*t[0]+e[1]*t[1]}function f(e){var t=Math.sqrt(c(e,e));return t&&(e[0]/=t,e[1]/=t),t}function p(e){var t=[e.a,e.b],n=[e.c,e.d],r=f(t),s=c(t,n),a=f(g(n,t,-s))||0;t[0]*n[1]<n[0]*t[1]&&(t[0]*=-1,t[1]*=-1,r*=-1,s*=-1),this.rotate=(r?Math.atan2(t[1],t[0]):Math.atan2(-n[0],n[1]))*D,this.translate=[e.e,e.f],this.scale=[r,a],this.skew=a?Math.atan2(s,a)*D:0}function m(e){if(S||(S=document.createElementNS("http://www.w3.org/2000/svg","g")),null!=e){S.setAttribute("transform",e);var t=S.transform.baseVal.consolidate()}return new p(t?t.matrix:F)}var b=function(e,t){return e=+e,t-=e,function(n){return e+t*n}},w=function(e,t){for(var n,r=P.length;--r>=0&&!(n=P[r](e,t)););return n},y=function(e,t){var n,r={},s={};for(n in e)n in t?r[n]=w(e[n],t[n]):s[n]=e[n];for(n in t)n in e||(s[n]=t[n]);return function(e){for(n in r)s[n]=r[n](e);return s}},k=function(e,t){var n,r=[],s=[],a=e.length,i=t.length,o=Math.min(e.length,t.length);for(n=0;o>n;++n)r.push(w(e[n],t[n]));for(;a>n;++n)s[n]=e[n];for(;i>n;++n)s[n]=t[n];return function(e){for(n=0;o>n;++n)s[n]=r[n](e);return s}};r.prototype={toString:function(){return this.rgb()+""}};var M=n.prototype=new r,v=.7;M.darker=function(e){return e=null==e?v:Math.pow(v,e),new n(this.r*e,this.g*e,this.b*e)};var x=1/v;M.brighter=function(e){return e=null==e?x:Math.pow(x,e),new n(this.r*e,this.g*e,this.b*e)},M.rgb=function(){return this},M.toString=function(){return t(this.r,this.g,this.b)};var N=(new Map).set("aliceblue",15792383).set("antiquewhite",16444375).set("aqua",65535).set("aquamarine",8388564).set("azure",15794175).set("beige",16119260).set("bisque",16770244).set("black",0).set("blanchedalmond",16772045).set("blue",255).set("blueviolet",9055202).set("brown",10824234).set("burlywood",14596231).set("cadetblue",6266528).set("chartreuse",8388352).set("chocolate",13789470).set("coral",16744272).set("cornflowerblue",6591981).set("cornsilk",16775388).set("crimson",14423100).set("cyan",65535).set("darkblue",139).set("darkcyan",35723).set("darkgoldenrod",12092939).set("darkgray",11119017).set("darkgreen",25600).set("darkgrey",11119017).set("darkkhaki",12433259).set("darkmagenta",9109643).set("darkolivegreen",5597999).set("darkorange",16747520).set("darkorchid",10040012).set("darkred",9109504).set("darksalmon",15308410).set("darkseagreen",9419919).set("darkslateblue",4734347).set("darkslategray",3100495).set("darkslategrey",3100495).set("darkturquoise",52945).set("darkviolet",9699539).set("deeppink",16716947).set("deepskyblue",49151).set("dimgray",6908265).set("dimgrey",6908265).set("dodgerblue",2003199).set("firebrick",11674146).set("floralwhite",16775920).set("forestgreen",2263842).set("fuchsia",16711935).set("gainsboro",14474460).set("ghostwhite",16316671).set("gold",16766720).set("goldenrod",14329120).set("gray",8421504).set("green",32768).set("greenyellow",11403055).set("grey",8421504).set("honeydew",15794160).set("hotpink",16738740).set("indianred",13458524).set("indigo",4915330).set("ivory",16777200).set("khaki",15787660).set("lavender",15132410).set("lavenderblush",16773365).set("lawngreen",8190976).set("lemonchiffon",16775885).set("lightblue",11393254).set("lightcoral",15761536).set("lightcyan",14745599).set("lightgoldenrodyellow",16448210).set("lightgray",13882323).set("lightgreen",9498256).set("lightgrey",13882323).set("lightpink",16758465).set("lightsalmon",16752762).set("lightseagreen",2142890).set("lightskyblue",8900346).set("lightslategray",7833753).set("lightslategrey",7833753).set("lightsteelblue",11584734).set("lightyellow",16777184).set("lime",65280).set("limegreen",3329330).set("linen",16445670).set("magenta",16711935).set("maroon",8388608).set("mediumaquamarine",6737322).set("mediumblue",205).set("mediumorchid",12211667).set("mediumpurple",9662683).set("mediumseagreen",3978097).set("mediumslateblue",8087790).set("mediumspringgreen",64154).set("mediumturquoise",4772300).set("mediumvioletred",13047173).set("midnightblue",1644912).set("mintcream",16121850).set("mistyrose",16770273).set("moccasin",16770229).set("navajowhite",16768685).set("navy",128).set("oldlace",16643558).set("olive",8421376).set("olivedrab",7048739).set("orange",16753920).set("orangered",16729344).set("orchid",14315734).set("palegoldenrod",15657130).set("palegreen",10025880).set("paleturquoise",11529966).set("palevioletred",14381203).set("papayawhip",16773077).set("peachpuff",16767673).set("peru",13468991).set("pink",16761035).set("plum",14524637).set("powderblue",11591910).set("purple",8388736).set("rebeccapurple",6697881).set("red",16711680).set("rosybrown",12357519).set("royalblue",4286945).set("saddlebrown",9127187).set("salmon",16416882).set("sandybrown",16032864).set("seagreen",3050327).set("seashell",16774638).set("sienna",10506797).set("silver",12632256).set("skyblue",8900331).set("slateblue",6970061).set("slategray",7372944).set("slategrey",7372944).set("snow",16775930).set("springgreen",65407).set("steelblue",4620980).set("tan",13808780).set("teal",32896).set("thistle",14204888).set("tomato",16737095).set("turquoise",4251856).set("violet",15631086).set("wheat",16113331).set("white",16777215).set("whitesmoke",16119285).set("yellow",16776960).set("yellowgreen",10145074),q=a.prototype=new r;q.brighter=function(e){return e=null==e?x:Math.pow(x,e),new a(this.h,this.s,this.l*e)},q.darker=function(e){return e=null==e?v:Math.pow(v,e),new a(this.h,this.s,this.l*e)},q.rgb=function(){var e=this.h%360+360*(this.h<0),t=isNaN(e)||isNaN(this.s)?0:this.s,r=this.l,s=.5>=r?r*(1+t):r+t-r*t,a=2*r-s;return new n(i(e>=240?e-240:e+120,a,s),i(e,a,s),i(120>e?e+240:e-120,a,s))};var S,j=function(e,t,n){if(1===arguments.length)if(e instanceof a)n=e.l,t=e.s,e=e.h;else if(e instanceof r||(e=T(e)),e){if(e instanceof a)return e;e=e.rgb();var s=e.r/255,i=e.g/255,o=e.b/255,u=Math.min(s,i,o),l=Math.max(s,i,o),h=l-u;n=(l+u)/2,h?(t=.5>n?h/(l+u):h/(2-l-u),e=s===l?(i-o)/h+6*(o>i):i===l?(o-s)/h+2:(s-i)/h+4,e*=60):(e=0/0,t=n>0&&1>n?0:e)}else e=t=n=0/0;return new a(e,t,n)},I=/^#([0-9a-f]{3})$/,$=/^#([0-9a-f]{6})$/,A=/^rgb\(\s*([-+]?\d+)\s*,\s*([-+]?\d+)\s*,\s*([-+]?\d+)\s*\)$/,E=/^rgb\(\s*([-+]?\d+(?:\.\d+)?)%\s*,\s*([-+]?\d+(?:\.\d+)?)%\s*,\s*([-+]?\d+(?:\.\d+)?)%\s*\)$/,R=/^hsl\(\s*([-+]?\d+(?:\.\d+)?)\s*,\s*([-+]?\d+(?:\.\d+)?)%\s*,\s*([-+]?\d+(?:\.\d+)?)%\s*\)$/,T=function(e){var t;return e=(e+"").trim().toLowerCase(),(t=I.exec(e))?(t=parseInt(t[1],16),X(t>>8&15|t>>4&240,t>>4&15|240&t,(15&t)<<4|15&t)):(t=$.exec(e))?s(parseInt(t[1],16)):(t=A.exec(e))?X(t[1],t[2],t[3]):(t=E.exec(e))?X(2.55*t[1],2.55*t[2],2.55*t[3]):(t=R.exec(e))?j(t[1],.01*t[2],.01*t[3]):N.has(e)?s(N.get(e)):null},X=function(e,t,s){return 1===arguments.length&&(e instanceof r||(e=T(e)),e?(e=e.rgb(),s=e.b,t=e.g,e=e.r):e=t=s=0/0),new n(e,t,s)},z=function(e,n){e=X(e),n=X(n);var r=e.r,s=e.g,a=e.b,i=n.r-r,o=n.g-s,u=n.b-a;return function(e){return t(Math.round(r+i*e),Math.round(s+o*e),Math.round(a+u*e))}},C=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,L=new RegExp(C.source,"g"),O=function(e,t){var n,r,s,a=C.lastIndex=L.lastIndex=0,i=-1,l=[],h=[];for(e+="",t+="";(n=C.exec(e))&&(r=L.exec(t));)(s=r.index)>a&&(s=t.slice(a,s),l[i]?l[i]+=s:l[++i]=s),(n=n[0])===(r=r[0])?l[i]?l[i]+=r:l[++i]=r:(l[++i]=null,h.push({i:i,x:b(n,r)})),a=L.lastIndex;return a<t.length&&(s=t.slice(a),l[i]?l[i]+=s:l[++i]=s),l.length<2?h[0]?u(h[0].x):o(t):(t=h.length,function(e){for(var n,r=0;t>r;++r)l[(n=h[r]).i]=n.x(e);return l.join("")})},P=[function(e,t){var n,r=typeof t;return("string"===r?(n=T(t))?(t=n,z):O:t instanceof T?z:Array.isArray(t)?k:"object"===r&&isNaN(t)?y:b)(e,t)}],Q=Math.SQRT2,V=2,Z=4,B=function(e,t){function n(e){var t=e*v,n=l(y),r=i/(V*m)*(n*d(Q*t+y)-h(y));return[s+r*c,a+r*f,i*n/l(Q*t+y)]}function r(e){return[s+e*c,a+e*f,i*Math.exp(Q*e*v)]}var s=e[0],a=e[1],i=e[2],o=t[0],u=t[1],g=t[2],c=o-s,f=u-a,p=c*c+f*f,m=Math.sqrt(p),b=(g*g-i*i+Z*p)/(2*i*V*m),w=(g*g-i*i-Z*p)/(2*g*V*m),y=Math.log(Math.sqrt(b*b+1)-b),k=Math.log(Math.sqrt(w*w+1)-w),M=k-y,v=(M||Math.log(g/i))/Q,x=M?n:r;return x.duration=1e3*v,x},D=180/Math.PI,F={a:1,b:0,c:0,d:1,e:0,f:0},G=function(e,t){var n,r=[],s=[],a=m(e),i=m(t),o=a.translate,u=i.translate,l=a.rotate,h=i.rotate,d=a.skew,g=i.skew,c=a.scale,f=i.scale;return o[0]!=u[0]||o[1]!=u[1]?(r.push("translate(",null,",",null,")"),s.push({i:1,x:b(o[0],u[0])},{i:3,x:b(o[1],u[1])})):r.push(u[0]||u[1]?"translate("+u+")":""),l!=h?(l-h>180?h+=360:h-l>180&&(l+=360),s.push({i:r.push(r.pop()+"rotate(",null,")")-2,x:b(l,h)})):h&&r.push(r.pop()+"rotate("+h+")"),d!=g?s.push({i:r.push(r.pop()+"skewX(",null,")")-2,x:b(d,g)}):g&&r.push(r.pop()+"skewX("+g+")"),c[0]!=f[0]||c[1]!=f[1]?(n=r.push(r.pop()+"scale(",null,",",null,")"),s.push({i:n-4,x:b(c[0],f[0])},{i:n-2,x:b(c[1],f[1])})):(1!=f[0]||1!=f[1])&&r.push(r.pop()+"scale("+f+")"),n=s.length,function(e){for(var t,a=-1;++a<n;)r[(t=s[a]).i]=t.x(e);return r.join("")}},H=function(e,t){return e=+e,t-=e,function(n){return Math.round(e+t*n)}};e.interpolate=w,e.interpolateArray=k,e.interpolateNumber=b,e.interpolateObject=y,e.interpolateRound=H,e.interpolateString=O,e.interpolateTransform=G,e.interpolateZoom=B,e.interpolators=P});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.interpolate={})}(this,function(t){"use strict";function e(t,e){return t=+t,e-=t,function(n){return t+e*n}}function n(t,e){for(var n,r=tt.length;--r>=0&&!(n=tt[r](t,e)););return n}function r(t,e){var r,i={},a={};for(r in t)r in e?i[r]=n(t[r],e[r]):a[r]=t[r];for(r in e)r in t||(a[r]=e[r]);return function(t){for(r in i)a[r]=i[r](t);return a}}function i(t,e){var r,i=[],a=[],o=t.length,s=e.length,u=Math.min(t.length,e.length);for(r=0;u>r;++r)i.push(n(t[r],e[r]));for(;o>r;++r)a[r]=t[r];for(;s>r;++r)a[r]=e[r];return function(t){for(r=0;u>r;++r)a[r]=i[r](t);return a}}function a(){}function o(t){var e;return t=(t+"").trim().toLowerCase(),(e=A.exec(t))?(e=parseInt(e[1],16),u(e>>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e)):(e=P.exec(t))?s(parseInt(e[1],16)):(e=E.exec(t))?u(e[1],e[2],e[3]):(e=R.exec(t))?u(255*e[1]/100,255*e[2]/100,255*e[3]/100):(e=O.exec(t))?g(e[1],e[2]/100,e[3]/100):T.hasOwnProperty(t)?s(T[t]):null}function s(t){return u(t>>16&255,t>>8&255,255&t)}function u(t,e,n){return 1===arguments.length&&(t instanceof a||(t=o(t)),t?(t=t.rgb(),n=t.b,e=t.g,t=t.r):t=e=n=NaN),new l(t,e,n)}function l(t,e,n){this.r=+t,this.g=+e,this.b=+n}function h(t,e,n){return"#"+(isNaN(t)?"00":(t=Math.round(t))<16?"0"+Math.max(0,t).toString(16):Math.min(255,t).toString(16))+(isNaN(e)?"00":(e=Math.round(e))<16?"0"+Math.max(0,e).toString(16):Math.min(255,e).toString(16))+(isNaN(n)?"00":(n=Math.round(n))<16?"0"+Math.max(0,n).toString(16):Math.min(255,n).toString(16))}function g(t,e,n){if(1===arguments.length)if(t instanceof c)n=t.l,e=t.s,t=t.h;else if(t instanceof a||(t=o(t)),t){if(t instanceof c)return t;t=t.rgb();var r=t.r/255,i=t.g/255,s=t.b/255,u=Math.min(r,i,s),l=Math.max(r,i,s),h=l-u;n=(l+u)/2,h?(e=.5>n?h/(l+u):h/(2-l-u),t=r===l?(i-s)/h+6*(s>i):i===l?(s-r)/h+2:(r-i)/h+4,t*=60):(t=NaN,e=n>0&&1>n?0:t)}else t=e=n=NaN;return new c(t,e,n)}function c(t,e,n){this.h=+t,this.s=+e,this.l=+n}function d(t,e,n){return 255*(60>t?e+(n-e)*t/60:180>t?n:240>t?e+(n-e)*(240-t)/60:e)}function f(t,e,n){if(1===arguments.length)if(t instanceof p)n=t.l,e=t.s,t=t.h;else{t instanceof l||(t=u(t));var r=t.r/255,i=t.g/255,a=t.b/255;n=(K*a+H*r-J*i)/(K+H-J);var o=a-n,s=(G*(i-n)-D*o)/F;e=Math.sqrt(s*s+o*o)/(G*n*(1-n)),t=e?Math.atan2(s,o)*V-120:NaN,0>t&&(t+=360)}return new p(t,e,n)}function p(t,e,n){this.h=+t,this.s=+e,this.l=+n}function b(t,e){t=u(t),e=u(e);var n=t.r,r=t.g,i=t.b,a=e.r-n,o=e.g-r,s=e.b-i;return function(t){return h(Math.round(n+a*t),Math.round(r+o*t),Math.round(i+s*t))}}function m(t){return function(){return t}}function w(t){return function(e){return t(e)+""}}function y(t,n){var r,i,a,o=Y.lastIndex=_.lastIndex=0,s=-1,u=[],l=[];for(t+="",n+="";(r=Y.exec(t))&&(i=_.exec(n));)(a=i.index)>o&&(a=n.slice(o,a),u[s]?u[s]+=a:u[++s]=a),(r=r[0])===(i=i[0])?u[s]?u[s]+=i:u[++s]=i:(u[++s]=null,l.push({i:s,x:e(r,i)})),o=_.lastIndex;return o<n.length&&(a=n.slice(o),u[s]?u[s]+=a:u[++s]=a),u.length<2?l[0]?w(l[0].x):m(n):(n=l.length,function(t){for(var e,r=0;n>r;++r)u[(e=l[r]).i]=e.x(t);return u.join("")})}function M(t){return((t=Math.exp(t))+1/t)/2}function k(t){return((t=Math.exp(t))-1/t)/2}function v(t){return((t=Math.exp(2*t))-1)/(t+1)}function x(t,e){function n(t){var e=t*y,n=M(b),r=o/(nt*d)*(n*v(et*e+b)-k(b));return[i+r*h,a+r*g,o*n/M(et*e+b)]}function r(t){return[i+t*h,a+t*g,o*Math.exp(et*t*y)]}var i=t[0],a=t[1],o=t[2],s=e[0],u=e[1],l=e[2],h=s-i,g=u-a,c=h*h+g*g,d=Math.sqrt(c),f=(l*l-o*o+rt*c)/(2*o*nt*d),p=(l*l-o*o-rt*c)/(2*l*nt*d),b=Math.log(Math.sqrt(f*f+1)-f),m=Math.log(Math.sqrt(p*p+1)-p),w=m-b,y=(w||Math.log(l/o))/et,x=w?n:r;return x.duration=1e3*y,x}function N(t){W||(W=document.createElementNS("http://www.w3.org/2000/svg","g")),t&&(W.setAttribute("transform",t),e=W.transform.baseVal.consolidate());var e,n=e?e.matrix:at,r=[n.a,n.b],i=[n.c,n.d],a=S(r),o=q(r,i),s=S(I(i,r,-o))||0;r[0]*i[1]<i[0]*r[1]&&(r[0]*=-1,r[1]*=-1,a*=-1,o*=-1),this.rotate=(a?Math.atan2(r[1],r[0]):Math.atan2(-i[0],i[1]))*it,this.translate=[n.e,n.f],this.scale=[a,s],this.skew=s?Math.atan2(o,s)*it:0}function q(t,e){return t[0]*e[0]+t[1]*e[1]}function S(t){var e=Math.sqrt(q(t,t));return e&&(t[0]/=e,t[1]/=e),e}function I(t,e,n){return t[0]+=n*e[0],t[1]+=n*e[1],t}function j(t,n){var r,i=[],a=[],o=new N(t),s=new N(n),u=o.translate,l=s.translate,h=o.rotate,g=s.rotate,c=o.skew,d=s.skew,f=o.scale,p=s.scale;return u[0]!=l[0]||u[1]!=l[1]?(i.push("translate(",null,",",null,")"),a.push({i:1,x:e(u[0],l[0])},{i:3,x:e(u[1],l[1])})):l[0]||l[1]?i.push("translate("+l+")"):i.push(""),h!=g?(h-g>180?g+=360:g-h>180&&(h+=360),a.push({i:i.push(i.pop()+"rotate(",null,")")-2,x:e(h,g)})):g&&i.push(i.pop()+"rotate("+g+")"),c!=d?a.push({i:i.push(i.pop()+"skewX(",null,")")-2,x:e(c,d)}):d&&i.push(i.pop()+"skewX("+d+")"),f[0]!=p[0]||f[1]!=p[1]?(r=i.push(i.pop()+"scale(",null,",",null,")"),a.push({i:r-4,x:e(f[0],p[0])},{i:r-2,x:e(f[1],p[1])})):(1!=p[0]||1!=p[1])&&i.push(i.pop()+"scale("+p+")"),r=a.length,function(t){for(var e,n=-1;++n<r;)i[(e=a[n]).i]=e.x(t);return i.join("")}}function $(t,e){return t=+t,e-=t,function(n){return Math.round(t+e*n)}}var A=/^#([0-9a-f]{3})$/,P=/^#([0-9a-f]{6})$/,E=/^rgb\(\s*([-+]?\d+)\s*,\s*([-+]?\d+)\s*,\s*([-+]?\d+)\s*\)$/,R=/^rgb\(\s*([-+]?\d+(?:\.\d+)?)%\s*,\s*([-+]?\d+(?:\.\d+)?)%\s*,\s*([-+]?\d+(?:\.\d+)?)%\s*\)$/,O=/^hsl\(\s*([-+]?\d+(?:\.\d+)?)\s*,\s*([-+]?\d+(?:\.\d+)?)%\s*,\s*([-+]?\d+(?:\.\d+)?)%\s*\)$/;o.prototype=a.prototype={displayable:function(){return this.rgb().displayable()},toString:function(){return this.rgb()+""}};var T={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},X=.7,z=1/X,C=u.prototype=l.prototype=new a;C.brighter=function(t){return t=null==t?z:Math.pow(z,t),new l(this.r*t,this.g*t,this.b*t)},C.darker=function(t){return t=null==t?X:Math.pow(X,t),new l(this.r*t,this.g*t,this.b*t)},C.rgb=function(){return this},C.displayable=function(){return 0<=this.r&&this.r<=255&&0<=this.g&&this.g<=255&&0<=this.b&&this.b<=255},C.toString=function(){return h(this.r,this.g,this.b)};var L=g.prototype=c.prototype=new a;L.brighter=function(t){return t=null==t?z:Math.pow(z,t),new c(this.h,this.s,this.l*t)},L.darker=function(t){return t=null==t?X:Math.pow(X,t),new c(this.h,this.s,this.l*t)},L.rgb=function(){var t=this.h%360+360*(this.h<0),e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,r=n+(.5>n?n:1-n)*e,i=2*n-r;return new l(d(t>=240?t-240:t+120,i,r),d(t,i,r),d(120>t?t+240:t-120,i,r))},L.displayable=function(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1};var Q=Math.PI/180,V=180/Math.PI,Z=-.14861,B=1.78277,D=-.29227,F=-.90649,G=1.97294,H=G*F,J=G*B,K=B*D-F*Z,U=f.prototype=p.prototype=new a;U.brighter=function(t){return t=null==t?z:Math.pow(z,t),new p(this.h,this.s,this.l*t)},U.darker=function(t){return t=null==t?X:Math.pow(X,t),new p(this.h,this.s,this.l*t)},U.rgb=function(){var t=isNaN(this.h)?0:(this.h+120)*Q,e=+this.l,n=isNaN(this.s)?0:this.s*e*(1-e),r=Math.cos(t),i=Math.sin(t);return new l(255*(e+n*(Z*r+B*i)),255*(e+n*(D*r+F*i)),255*(e+n*G*r))};var W,Y=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,_=new RegExp(Y.source,"g"),tt=[function(t,n){var a,s=typeof n;return("string"===s?(a=o(n))?(n=a,b):y:n instanceof o?b:Array.isArray(n)?i:"object"===s&&isNaN(n)?r:e)(t,n)}],et=Math.SQRT2,nt=2,rt=4,it=180/Math.PI,at={a:1,b:0,c:0,d:1,e:0,f:0};t.interpolate=n,t.interpolateArray=i,t.interpolateNumber=e,t.interpolateObject=r,t.interpolateRound=$,t.interpolateString=y,t.interpolateTransform=j,t.interpolateZoom=x,t.interpolators=tt});
{
"name": "d3-interpolate",
"version": "0.1.1",
"version": "0.1.2",
"description": "Interpolate numbers, colors, strings, arrays, objects, whatever!",

@@ -28,8 +28,8 @@ "keywords": [

"devDependencies": {
"d3-bundler": "~0.2.6",
"d3-color": "~0.2.0",
"d3-bundler": "~0.2.9",
"d3-color": "~0.2.6",
"faucet": "0.0",
"tape": "4",
"uglifyjs": "2"
"uglify-js": "2"
}
}
# d3-interpolate
A variety of interpolation methods for blending between values. Values may be numbers, colors, strings, arrays, even deeply-nested objects.
The d3-interpolate module provides a variety of interpolation methods for blending between two values. These values may be numbers, colors, strings, arrays, even deeply-nested objects. For example:
Given a starting value *a* and an ending value *b*, an *interpolator* is a function that takes a parameter *t* in the domain [0,1] and returns an interpolated value between *a* and *b*. For example:
```js

@@ -15,4 +13,6 @@ var i = interpolateNumber(10, 20);

A more elaborate example, demonstrating type inference used by [interpolate](#interpolate) for colors on nested objects:
The returned function `i` is called an *interpolator*. Given the starting value *a* and the ending value *b*, it takes a parameter *t* in the domain [0,1] and returns an interpolated value between *a* and *b*. An interpolator typically returns a value equivalent to *a* at *t* = 0, and a value equivalent to *b* at *t* = 1.
Here’s a more elaborate example demonstrating type inference used by [interpolate](#interpolate):
```js

@@ -25,4 +25,10 @@ var i = interpolate({colors: ["red", "blue"]}, {colors: ["white", "black"]});

An interpolator (such as `i` above) typically returns a value equivalent to *a* at *t* = 0, and a value equivalent to *b* at *t* = 1.
Note that the generic interpolate method detects not only nested objects and arrays, but also color strings and numbers embedded in strings!
## Installing
If you use NPM, `npm install d3-interpolate`. Otherwise, download the [latest release](https://github.com/d3/d3-interpolate/releases/latest).
## API Reference
<a name="interpolate" href="#interpolate">#</a> <b>interpolate</b>(<i>a</i>, <i>b</i>)

@@ -70,3 +76,3 @@

Note: no defensive copy of the template array is created; modifications of the returned array may adversely affect subsequent evaluation of the interpolator. No copy is made because interpolators should be fast, as they are part of the inner loop of animation.
Note: **no defensive copy** of the template array is created; modifications of the returned array may adversely affect subsequent evaluation of the interpolator. No copy is made because interpolators should be fast, as they are part of the inner loop of animation.

@@ -81,3 +87,3 @@ <a name="interpolateObject" href="#interpolateObject">#</a> <b>interpolateObject</b>(<i>a</i>, <i>b</i>)

Note: no defensive copy of the template object is created; modifications of the returned object may adversely affect subsequent evaluation of the interpolator. No copy is made because interpolators should be fast, as they are part of the inner loop of animation.
Note: **no defensive copy** of the template object is created; modifications of the returned object may adversely affect subsequent evaluation of the interpolator. No copy is made because interpolators should be fast, as they are part of the inner loop of animation.

@@ -84,0 +90,0 @@ <a name="interpolateTransform" href="#interpolateTransform">#</a> <b>interpolateTransform</b>(<i>a</i>, <i>b</i>)

@@ -7,11 +7,2 @@ import interpolateNumber from "./interpolateNumber";

function transform(string) {
if (!g) g = document.createElementNS("http://www.w3.org/2000/svg", "g");
if (string != null) {
g.setAttribute("transform", string);
var t = g.transform.baseVal.consolidate();
}
return new Transform(t ? t.matrix : identity);
}
// Compute x-scale and normalize the first row.

@@ -21,4 +12,9 @@ // Compute shear and make second row orthogonal to first.

// Finally, compute the rotation.
function Transform(m) {
var r0 = [m.a, m.b],
function Transform(string) {
if (!g) g = document.createElementNS("http://www.w3.org/2000/svg", "g");
if (string) g.setAttribute("transform", string), t = g.transform.baseVal.consolidate();
var t,
m = t ? t.matrix : identity,
r0 = [m.a, m.b],
r1 = [m.c, m.d],

@@ -40,3 +36,3 @@ kx = normalize(r0),

this.skew = ky ? Math.atan2(kz, ky) * rad2deg : 0;
};
}

@@ -63,4 +59,4 @@ function dot(a, b) {

n,
A = transform(a),
B = transform(b),
A = new Transform(a),
B = new Transform(b),
ta = A.translate,

@@ -67,0 +63,0 @@ tb = B.translate,

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc