Socket
Socket
Sign inDemoInstall

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.5.1 to 0.5.2

src/color.js

2

build/bundle.js

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

var version = "0.5.1"; export * from "../index"; export {version};
var version = "0.5.2"; export * from "../index"; export {version};

@@ -7,56 +7,57 @@ (function (global, factory) {

function rgb$1(a, b) {
a = d3Color.rgb(a);
b = d3Color.rgb(b);
var ar = a.r,
ag = a.g,
ab = a.b,
br = b.r || 0,
bg = b.g || 0,
bb = b.b || 0;
if (isNaN(ar)) ar = br;
if (isNaN(ag)) ag = bg;
if (isNaN(ab)) ab = bb;
br -= ar;
bg -= ag;
bb -= ab;
function constant(x) {
return function() {
return x;
};
}
function linear(a, d) {
return function(t) {
a.r = ar + br * t;
a.g = ag + bg * t;
a.b = ab + bb * t;
return a + "";
return a + t * d;
};
}
rgb$1.gamma = function gamma(y) {
y = +y;
function exponential(a, b, y) {
return a = Math.pow(a, y), b = Math.pow(b, y) - a, y = 1 / y, function(t) {
return Math.pow(a + t * b, y);
};
}
function rgb(a, b) {
a = d3Color.rgb(a);
b = d3Color.rgb(b);
var ar = Math.pow(a.r, y),
ag = Math.pow(a.g, y),
ab = Math.pow(a.b, y),
br = Math.pow(b.r || 0, y),
bg = Math.pow(b.g || 0, y),
bb = Math.pow(b.b || 0, y);
if (isNaN(ar)) ar = br;
if (isNaN(ag)) ag = bg;
if (isNaN(ab)) ab = bb;
br -= ar;
bg -= ag;
bb -= ab;
y = 1 / y;
function hue(a, b) {
var d = b - a;
return d ? linear(a, d > 180 || d < -180 ? d - 360 * Math.round(d / 360) : d) : constant(isNaN(a) ? b : a);
}
function gamma(y) {
return (y = +y) === 1 ? nogamma : function(a, b) {
return b - a ? exponential(a, b, y) : constant(isNaN(a) ? b : a);
};
}
function nogamma(a, b) {
var d = b - a;
return d ? linear(a, d) : constant(isNaN(a) ? b : a);
}
var rgb$1 = (function gamma$$(y) {
var interpolateColor = gamma(y);
function interpolateRgb(start, end) {
var r = interpolateColor((start = d3Color.rgb(start)).r, (end = d3Color.rgb(end)).r),
g = interpolateColor(start.g, end.g),
b = interpolateColor(start.b, end.b),
opacity = interpolateColor(start.opacity, end.opacity);
return function(t) {
a.r = Math.pow(ar + br * t, y);
a.g = Math.pow(ag + bg * t, y);
a.b = Math.pow(ab + bb * t, y);
return a + "";
start.r = r(t);
start.g = g(t);
start.b = b(t);
start.opacity = opacity(t);
return start + "";
};
}
rgb.gamma = gamma;
interpolateRgb.gamma = gamma$$;
return rgb;
};
return interpolateRgb;
})(1);

@@ -368,121 +369,69 @@ // TODO sparse arrays?

function deltaHue(h1, h0) {
var delta = h1 - h0;
return delta > 180 || delta < -180
? delta - 360 * Math.round(delta / 360)
: delta;
}
function hsl$1(a, b) {
a = d3Color.hsl(a);
b = d3Color.hsl(b);
var ah = a.h,
as = a.s,
al = a.l,
bh = b.h,
bs = b.s,
bl = b.l || 0;
if (isNaN(ah)) ah = bh;
if (isNaN(as)) as = bs;
if (isNaN(al)) al = bl;
bh = deltaHue(bh, ah) || 0;
bs = (bs - as) || 0;
bl -= al;
function interpolateHsl(start, end) {
var h = hue((start = d3Color.hsl(start)).h, (end = d3Color.hsl(end)).h),
s = nogamma(start.s, end.s),
l = nogamma(start.l, end.l),
opacity = nogamma(start.opacity, end.opacity);
return function(t) {
a.h = ah + bh * t;
a.s = as + bs * t;
a.l = al + bl * t;
return a + "";
start.h = h(t);
start.s = s(t);
start.l = l(t);
start.opacity = opacity(t);
return start + "";
};
}
function hslLong(a, b) {
a = d3Color.hsl(a);
b = d3Color.hsl(b);
var ah = a.h,
as = a.s,
al = a.l,
bh = b.h,
bs = b.s,
bl = b.l || 0;
if (isNaN(ah)) ah = bh;
if (isNaN(as)) as = bs;
if (isNaN(al)) al = bl;
bh = (bh - ah) || 0;
bs = (bs - as) || 0;
bl -= al;
function interpolateHslLong(start, end) {
var h = nogamma((start = d3Color.hsl(start)).h, (end = d3Color.hsl(end)).h),
s = nogamma(start.s, end.s),
l = nogamma(start.l, end.l),
opacity = nogamma(start.opacity, end.opacity);
return function(t) {
a.h = ah + bh * t;
a.s = as + bs * t;
a.l = al + bl * t;
return a + "";
start.h = h(t);
start.s = s(t);
start.l = l(t);
start.opacity = opacity(t);
return start + "";
};
}
function lab$1(a, b) {
a = d3Color.lab(a);
b = d3Color.lab(b);
var al = a.l,
aa = a.a,
ab = a.b,
bl = b.l || 0,
ba = b.a || 0,
bb = b.b || 0;
if (isNaN(al)) al = bl;
if (isNaN(aa)) aa = ba;
if (isNaN(ab)) ab = bb;
bl -= al;
ba -= aa;
bb -= ab;
function interpolateLab(start, end) {
var l = nogamma((start = d3Color.lab(start)).l, (end = d3Color.lab(end)).l),
a = nogamma(start.a, end.a),
b = nogamma(start.b, end.b),
opacity = nogamma(start.opacity, end.opacity);
return function(t) {
a.l = al + bl * t;
a.a = aa + ba * t;
a.b = ab + bb * t;
return a + "";
start.l = l(t);
start.a = a(t);
start.b = b(t);
start.opacity = opacity(t);
return start + "";
};
}
function hcl$1(a, b) {
a = d3Color.hcl(a);
b = d3Color.hcl(b);
var ah = a.h,
ac = a.c,
al = a.l,
bh = b.h,
bc = b.c,
bl = b.l || 0;
if (isNaN(ah)) ah = bh;
if (isNaN(ac)) ac = bc;
if (isNaN(al)) al = bl;
bh = deltaHue(bh, ah) || 0;
bc = (bc - ac) || 0;
bl -= al;
function interpolateHcl(start, end) {
var h = hue((start = d3Color.hcl(start)).h, (end = d3Color.hcl(end)).h),
c = nogamma(start.c, end.c),
l = nogamma(start.l, end.l),
opacity = nogamma(start.opacity, end.opacity);
return function(t) {
a.h = ah + bh * t;
a.c = ac + bc * t;
a.l = al + bl * t;
return a + "";
start.h = h(t);
start.c = c(t);
start.l = l(t);
start.opacity = opacity(t);
return start + "";
};
}
function hclLong(a, b) {
a = d3Color.hcl(a);
b = d3Color.hcl(b);
var ah = a.h,
ac = a.c,
al = a.l,
bh = b.h,
bc = b.c,
bl = b.l || 0;
if (isNaN(ah)) ah = bh;
if (isNaN(ac)) ac = bc;
if (isNaN(al)) al = bl;
bh = (bh - ah) || 0;
bc = (bc - ac) || 0;
bl -= al;
function interpolateHclLong(start, end) {
var h = nogamma((start = d3Color.hcl(start)).h, (end = d3Color.hcl(end)).h),
c = nogamma(start.c, end.c),
l = nogamma(start.l, end.l),
opacity = nogamma(start.opacity, end.opacity);
return function(t) {
a.h = ah + bh * t;
a.c = ac + bc * t;
a.l = al + bl * t;
return a + "";
start.h = h(t);
start.c = c(t);
start.l = l(t);
start.opacity = opacity(t);
return start + "";
};

@@ -494,28 +443,19 @@ }

function cubehelix(a, b) {
a = d3Color.cubehelix(a);
b = d3Color.cubehelix(b);
var ah = a.h,
as = a.s,
al = a.l,
bh = b.h,
bs = b.s,
bl = b.l || 0;
if (isNaN(ah)) ah = bh;
if (isNaN(as)) as = bs;
if (isNaN(al)) al = bl;
bh = deltaHue(bh, ah) || 0;
bs = (bs - as) || 0;
bl -= al;
function interpolateCubehelix(start, end) {
var h = hue((start = d3Color.cubehelix(start)).h, (end = d3Color.cubehelix(end)).h),
s = nogamma(start.s, end.s),
l = nogamma(start.l, end.l),
opacity = nogamma(start.opacity, end.opacity);
return function(t) {
a.h = ah + bh * t;
a.s = as + bs * t;
a.l = al + bl * Math.pow(t, y);
return a + "";
start.h = h(t);
start.s = s(t);
start.l = l(Math.pow(t, y));
start.opacity = opacity(t);
return start + "";
};
}
cubehelix.gamma = gamma;
interpolateCubehelix.gamma = gamma;
return cubehelix;
return interpolateCubehelix;
})(1);

@@ -526,31 +466,22 @@

function cubehelix(a, b) {
a = d3Color.cubehelix(a);
b = d3Color.cubehelix(b);
var ah = a.h,
as = a.s,
al = a.l,
bh = b.h,
bs = b.s,
bl = b.l || 0;
if (isNaN(ah)) ah = bh;
if (isNaN(as)) as = bs;
if (isNaN(al)) al = bl;
bh = (bh - ah) || 0;
bs = (bs - as) || 0;
bl -= al;
function interpolateCubehelixLong(start, end) {
var h = nogamma((start = d3Color.cubehelix(start)).h, (end = d3Color.cubehelix(end)).h),
s = nogamma(start.s, end.s),
l = nogamma(start.l, end.l),
opacity = nogamma(start.opacity, end.opacity);
return function(t) {
a.h = ah + bh * t;
a.s = as + bs * t;
a.l = al + bl * Math.pow(t, y);
return a + "";
start.h = h(t);
start.s = s(t);
start.l = l(Math.pow(t, y));
start.opacity = opacity(t);
return start + "";
};
}
cubehelix.gamma = gamma;
interpolateCubehelixLong.gamma = gamma;
return cubehelix;
return interpolateCubehelixLong;
})(1);
var version = "0.5.1";
var version = "0.5.2";

@@ -568,7 +499,7 @@ exports.version = version;

exports.interpolateRgb = rgb$1;
exports.interpolateHsl = hsl$1;
exports.interpolateHslLong = hslLong;
exports.interpolateLab = lab$1;
exports.interpolateHcl = hcl$1;
exports.interpolateHclLong = hclLong;
exports.interpolateHsl = interpolateHsl;
exports.interpolateHslLong = interpolateHslLong;
exports.interpolateLab = interpolateLab;
exports.interpolateHcl = interpolateHcl;
exports.interpolateHclLong = interpolateHclLong;
exports.interpolateCubehelix = cubehelix$1;

@@ -575,0 +506,0 @@ exports.interpolateCubehelixLong = cubehelixLong;

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

!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("d3-color")):"function"==typeof define&&define.amd?define(["exports","d3-color"],n):n(t.d3_interpolate={},t.d3_color)}(this,function(t,n){"use strict";function r(t,r){t=n.rgb(t),r=n.rgb(r);var e=t.r,a=t.g,i=t.b,o=r.r||0,u=r.g||0,l=r.b||0;return isNaN(e)&&(e=o),isNaN(a)&&(a=u),isNaN(i)&&(i=l),o-=e,u-=a,l-=i,function(n){return t.r=e+o*n,t.g=a+u*n,t.b=i+l*n,t+""}}function e(t,n){var r,e=[],a=[],i=t?t.length:0,o=n?n.length:0,u=Math.min(i,o);for(r=0;u>r;++r)e.push(s(t[r],n[r]));for(;i>r;++r)a[r]=t[r];for(;o>r;++r)a[r]=n[r];return function(t){for(r=0;u>r;++r)a[r]=e[r](t);return a}}function a(t,n){return t=+t,n-=t,function(r){return t+n*r}}function i(t,n){var r,e={},a={};(null===t||"object"!=typeof t)&&(t={}),(null===n||"object"!=typeof n)&&(n={});for(r in t)r in n?e[r]=s(t[r],n[r]):a[r]=t[r];for(r in n)r in t||(a[r]=n[r]);return function(t){for(r in e)a[r]=e[r](t);return a}}function o(t){return function(){return t}}function u(t){return function(n){return t(n)+""}}function l(t,n){var r,e,i,l=E.lastIndex=S.lastIndex=0,s=-1,c=[],h=[];for(t+="",n+="";(r=E.exec(t))&&(e=S.exec(n));)(i=e.index)>l&&(i=n.slice(l,i),c[s]?c[s]+=i:c[++s]=i),(r=r[0])===(e=e[0])?c[s]?c[s]+=e:c[++s]=e:(c[++s]=null,h.push({i:s,x:a(r,e)})),l=S.lastIndex;return l<n.length&&(i=n.slice(l),c[s]?c[s]+=i:c[++s]=i),c.length<2?h[0]?u(h[0].x):o(n):(n=h.length,function(t){for(var r,e=0;n>e;++e)c[(r=h[e]).i]=r.x(t);return c.join("")})}function s(t,n){for(var r,e=C.length;--e>=0&&!(r=C[e](t,n)););return r}function c(t,n){return t=+t,n-=t,function(r){return Math.round(t+n*r)}}function h(t){R||(R=document.createElementNS("http://www.w3.org/2000/svg","g")),t&&(R.setAttribute("transform",t),n=R.transform.baseVal.consolidate());var n,r=n?n.matrix:X,e=[r.a,r.b],a=[r.c,r.d],i=p(e),o=f(e,a),u=p(N(a,e,-o))||0;e[0]*a[1]<a[0]*e[1]&&(e[0]*=-1,e[1]*=-1,i*=-1,o*=-1),this.rotate=(i?Math.atan2(e[1],e[0]):Math.atan2(-a[0],a[1]))*T,this.translate=[r.e,r.f],this.scale=[i,u],this.skew=u?Math.atan2(o,u)*T:0}function f(t,n){return t[0]*n[0]+t[1]*n[1]}function p(t){var n=Math.sqrt(f(t,t));return n&&(t[0]/=n,t[1]/=n),n}function N(t,n,r){return t[0]+=r*n[0],t[1]+=r*n[1],t}function g(t){return t.length?t.pop()+",":""}function b(t,n,r,e){if(t[0]!==n[0]||t[1]!==n[1]){var i=r.push("translate(",null,",",null,")");e.push({i:i-4,x:a(t[0],n[0])},{i:i-2,x:a(t[1],n[1])})}else(n[0]||n[1])&&r.push("translate("+n+")")}function x(t,n,r,e){t!==n?(t-n>180?n+=360:n-t>180&&(t+=360),e.push({i:r.push(g(r)+"rotate(",null,")")-2,x:a(t,n)})):n&&r.push(g(r)+"rotate("+n+")")}function M(t,n,r,e){t!==n?e.push({i:r.push(g(r)+"skewX(",null,")")-2,x:a(t,n)}):n&&r.push(g(r)+"skewX("+n+")")}function v(t,n,r,e){if(t[0]!==n[0]||t[1]!==n[1]){var i=r.push(g(r)+"scale(",null,",",null,")");e.push({i:i-4,x:a(t[0],n[0])},{i:i-2,x:a(t[1],n[1])})}else(1!==n[0]||1!==n[1])&&r.push(g(r)+"scale("+n+")")}function d(t,n){var r=[],e=[];return t=new h(t),n=new h(n),b(t.translate,n.translate,r,e),x(t.rotate,n.rotate,r,e),M(t.skew,n.skew,r,e),v(t.scale,n.scale,r,e),t=n=null,function(t){for(var n,a=-1,i=e.length;++a<i;)r[(n=e[a]).i]=n.x(t);return r.join("")}}function w(t){return((t=Math.exp(t))+1/t)/2}function m(t){return((t=Math.exp(t))-1/t)/2}function y(t){return((t=Math.exp(2*t))-1)/(t+1)}function j(t,n){var r,e,a=t[0],i=t[1],o=t[2],u=n[0],l=n[1],s=n[2],c=u-a,h=l-i,f=c*c+h*h;if(Q>f)e=Math.log(s/o)/_,r=function(t){return[a+t*c,i+t*h,o*Math.exp(_*t*e)]};else{var p=Math.sqrt(f),N=(s*s-o*o+P*f)/(2*o*O*p),g=(s*s-o*o-P*f)/(2*s*O*p),b=Math.log(Math.sqrt(N*N+1)-N),x=Math.log(Math.sqrt(g*g+1)-g);e=(x-b)/_,r=function(t){var n=t*e,r=w(b),u=o/(O*p)*(r*y(_*n+b)-m(b));return[a+u*c,i+u*h,o*r/w(_*n+b)]}}return r.duration=1e3*e,r}function k(t,n){var r=t-n;return r>180||-180>r?r-360*Math.round(r/360):r}function q(t,r){t=n.hsl(t),r=n.hsl(r);var e=t.h,a=t.s,i=t.l,o=r.h,u=r.s,l=r.l||0;return isNaN(e)&&(e=o),isNaN(a)&&(a=u),isNaN(i)&&(i=l),o=k(o,e)||0,u=u-a||0,l-=i,function(n){return t.h=e+o*n,t.s=a+u*n,t.l=i+l*n,t+""}}function A(t,r){t=n.hsl(t),r=n.hsl(r);var e=t.h,a=t.s,i=t.l,o=r.h,u=r.s,l=r.l||0;return isNaN(e)&&(e=o),isNaN(a)&&(a=u),isNaN(i)&&(i=l),o=o-e||0,u=u-a||0,l-=i,function(n){return t.h=e+o*n,t.s=a+u*n,t.l=i+l*n,t+""}}function H(t,r){t=n.lab(t),r=n.lab(r);var e=t.l,a=t.a,i=t.b,o=r.l||0,u=r.a||0,l=r.b||0;return isNaN(e)&&(e=o),isNaN(a)&&(a=u),isNaN(i)&&(i=l),o-=e,u-=a,l-=i,function(n){return t.l=e+o*n,t.a=a+u*n,t.b=i+l*n,t+""}}function I(t,r){t=n.hcl(t),r=n.hcl(r);var e=t.h,a=t.c,i=t.l,o=r.h,u=r.c,l=r.l||0;return isNaN(e)&&(e=o),isNaN(a)&&(a=u),isNaN(i)&&(i=l),o=k(o,e)||0,u=u-a||0,l-=i,function(n){return t.h=e+o*n,t.c=a+u*n,t.l=i+l*n,t+""}}function L(t,r){t=n.hcl(t),r=n.hcl(r);var e=t.h,a=t.c,i=t.l,o=r.h,u=r.c,l=r.l||0;return isNaN(e)&&(e=o),isNaN(a)&&(a=u),isNaN(i)&&(i=l),o=o-e||0,u=u-a||0,l-=i,function(n){return t.h=e+o*n,t.c=a+u*n,t.l=i+l*n,t+""}}r.gamma=function B(t){function r(r,e){r=n.rgb(r),e=n.rgb(e);var a=Math.pow(r.r,t),i=Math.pow(r.g,t),o=Math.pow(r.b,t),u=Math.pow(e.r||0,t),l=Math.pow(e.g||0,t),s=Math.pow(e.b||0,t);return isNaN(a)&&(a=u),isNaN(i)&&(i=l),isNaN(o)&&(o=s),u-=a,l-=i,s-=o,t=1/t,function(n){return r.r=Math.pow(a+u*n,t),r.g=Math.pow(i+l*n,t),r.b=Math.pow(o+s*n,t),r+""}}return t=+t,r.gamma=B,r};var R,E=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,S=new RegExp(E.source,"g"),C=[function(t,o){var u,s=typeof o;return("string"===s?(u=n.color(o))?(o=u,r):l:o instanceof n.color?r:Array.isArray(o)?e:"object"===s&&isNaN(o)?i:a)(t,o)}],T=180/Math.PI,X={a:1,b:0,c:0,d:1,e:0,f:0},_=Math.SQRT2,O=2,P=4,Q=1e-12,V=function D(t){function r(r,e){r=n.cubehelix(r),e=n.cubehelix(e);var a=r.h,i=r.s,o=r.l,u=e.h,l=e.s,s=e.l||0;return isNaN(a)&&(a=u),isNaN(i)&&(i=l),isNaN(o)&&(o=s),u=k(u,a)||0,l=l-i||0,s-=o,function(n){return r.h=a+u*n,r.s=i+l*n,r.l=o+s*Math.pow(n,t),r+""}}return t=+t,r.gamma=D,r}(1),Z=function F(t){function r(r,e){r=n.cubehelix(r),e=n.cubehelix(e);var a=r.h,i=r.s,o=r.l,u=e.h,l=e.s,s=e.l||0;return isNaN(a)&&(a=u),isNaN(i)&&(i=l),isNaN(o)&&(o=s),u=u-a||0,l=l-i||0,s-=o,function(n){return r.h=a+u*n,r.s=i+l*n,r.l=o+s*Math.pow(n,t),r+""}}return t=+t,r.gamma=F,r}(1),z="0.5.1";t.version=z,t.interpolate=s,t.interpolators=C,t.interpolateArray=e,t.interpolateNumber=a,t.interpolateObject=i,t.interpolateRound=c,t.interpolateString=l,t.interpolateTransform=d,t.interpolateZoom=j,t.interpolateRgb=r,t.interpolateHsl=q,t.interpolateHslLong=A,t.interpolateLab=H,t.interpolateHcl=I,t.interpolateHclLong=L,t.interpolateCubehelix=V,t.interpolateCubehelixLong=Z});
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("d3-color")):"function"==typeof define&&define.amd?define(["exports","d3-color"],n):n(t.d3_interpolate={},t.d3_color)}(this,function(t,n){"use strict";function r(t){return function(){return t}}function e(t,n){return function(r){return t+r*n}}function o(t,n,r){return t=Math.pow(t,r),n=Math.pow(n,r)-t,r=1/r,function(e){return Math.pow(t+e*n,r)}}function u(t,n){var o=n-t;return o?e(t,o>180||-180>o?o-360*Math.round(o/360):o):r(isNaN(t)?n:t)}function i(t){return 1===(t=+t)?a:function(n,e){return e-n?o(n,e,t):r(isNaN(n)?e:n)}}function a(t,n){var o=n-t;return o?e(t,o):r(isNaN(t)?n:t)}function c(t,n){var r,e=[],o=[],u=t?t.length:0,i=n?n.length:0,a=Math.min(u,i);for(r=0;a>r;++r)e.push(y(t[r],n[r]));for(;u>r;++r)o[r]=t[r];for(;i>r;++r)o[r]=n[r];return function(t){for(r=0;a>r;++r)o[r]=e[r](t);return o}}function l(t,n){return t=+t,n-=t,function(r){return t+n*r}}function f(t,n){var r,e={},o={};(null===t||"object"!=typeof t)&&(t={}),(null===n||"object"!=typeof n)&&(n={});for(r in t)r in n?e[r]=y(t[r],n[r]):o[r]=t[r];for(r in n)r in t||(o[r]=n[r]);return function(t){for(r in e)o[r]=e[r](t);return o}}function s(t){return function(){return t}}function h(t){return function(n){return t(n)+""}}function p(t,n){var r,e,o,u=_.lastIndex=O.lastIndex=0,i=-1,a=[],c=[];for(t+="",n+="";(r=_.exec(t))&&(e=O.exec(n));)(o=e.index)>u&&(o=n.slice(u,o),a[i]?a[i]+=o:a[++i]=o),(r=r[0])===(e=e[0])?a[i]?a[i]+=e:a[++i]=e:(a[++i]=null,c.push({i:i,x:l(r,e)})),u=O.lastIndex;return u<n.length&&(o=n.slice(u),a[i]?a[i]+=o:a[++i]=o),a.length<2?c[0]?h(c[0].x):s(n):(n=c.length,function(t){for(var r,e=0;n>e;++e)a[(r=c[e]).i]=r.x(t);return a.join("")})}function y(t,n){for(var r,e=P.length;--e>=0&&!(r=P[e](t,n)););return r}function g(t,n){return t=+t,n-=t,function(r){return Math.round(t+n*r)}}function x(t){T||(T=document.createElementNS("http://www.w3.org/2000/svg","g")),t&&(T.setAttribute("transform",t),n=T.transform.baseVal.consolidate());var n,r=n?n.matrix:V,e=[r.a,r.b],o=[r.c,r.d],u=b(e),i=v(e,o),a=b(d(o,e,-i))||0;e[0]*o[1]<o[0]*e[1]&&(e[0]*=-1,e[1]*=-1,u*=-1,i*=-1),this.rotate=(u?Math.atan2(e[1],e[0]):Math.atan2(-o[0],o[1]))*Q,this.translate=[r.e,r.f],this.scale=[u,a],this.skew=a?Math.atan2(i,a)*Q:0}function v(t,n){return t[0]*n[0]+t[1]*n[1]}function b(t){var n=Math.sqrt(v(t,t));return n&&(t[0]/=n,t[1]/=n),n}function d(t,n,r){return t[0]+=r*n[0],t[1]+=r*n[1],t}function M(t){return t.length?t.pop()+",":""}function m(t,n,r,e){if(t[0]!==n[0]||t[1]!==n[1]){var o=r.push("translate(",null,",",null,")");e.push({i:o-4,x:l(t[0],n[0])},{i:o-2,x:l(t[1],n[1])})}else(n[0]||n[1])&&r.push("translate("+n+")")}function w(t,n,r,e){t!==n?(t-n>180?n+=360:n-t>180&&(t+=360),e.push({i:r.push(M(r)+"rotate(",null,")")-2,x:l(t,n)})):n&&r.push(M(r)+"rotate("+n+")")}function N(t,n,r,e){t!==n?e.push({i:r.push(M(r)+"skewX(",null,")")-2,x:l(t,n)}):n&&r.push(M(r)+"skewX("+n+")")}function j(t,n,r,e){if(t[0]!==n[0]||t[1]!==n[1]){var o=r.push(M(r)+"scale(",null,",",null,")");e.push({i:o-4,x:l(t[0],n[0])},{i:o-2,x:l(t[1],n[1])})}else(1!==n[0]||1!==n[1])&&r.push(M(r)+"scale("+n+")")}function k(t,n){var r=[],e=[];return t=new x(t),n=new x(n),m(t.translate,n.translate,r,e),w(t.rotate,n.rotate,r,e),N(t.skew,n.skew,r,e),j(t.scale,n.scale,r,e),t=n=null,function(t){for(var n,o=-1,u=e.length;++o<u;)r[(n=e[o]).i]=n.x(t);return r.join("")}}function q(t){return((t=Math.exp(t))+1/t)/2}function A(t){return((t=Math.exp(t))-1/t)/2}function H(t){return((t=Math.exp(2*t))-1)/(t+1)}function I(t,n){var r,e,o=t[0],u=t[1],i=t[2],a=n[0],c=n[1],l=n[2],f=a-o,s=c-u,h=f*f+s*s;if(D>h)e=Math.log(l/i)/Z,r=function(t){return[o+t*f,u+t*s,i*Math.exp(Z*t*e)]};else{var p=Math.sqrt(h),y=(l*l-i*i+B*h)/(2*i*z*p),g=(l*l-i*i-B*h)/(2*l*z*p),x=Math.log(Math.sqrt(y*y+1)-y),v=Math.log(Math.sqrt(g*g+1)-g);e=(v-x)/Z,r=function(t){var n=t*e,r=q(x),a=i/(z*p)*(r*H(Z*n+x)-A(x));return[o+a*f,u+a*s,i*r/q(Z*n+x)]}}return r.duration=1e3*e,r}function L(t,r){var e=u((t=n.hsl(t)).h,(r=n.hsl(r)).h),o=a(t.s,r.s),i=a(t.l,r.l),c=a(t.opacity,r.opacity);return function(n){return t.h=e(n),t.s=o(n),t.l=i(n),t.opacity=c(n),t+""}}function R(t,r){var e=a((t=n.hsl(t)).h,(r=n.hsl(r)).h),o=a(t.s,r.s),u=a(t.l,r.l),i=a(t.opacity,r.opacity);return function(n){return t.h=e(n),t.s=o(n),t.l=u(n),t.opacity=i(n),t+""}}function E(t,r){var e=a((t=n.lab(t)).l,(r=n.lab(r)).l),o=a(t.a,r.a),u=a(t.b,r.b),i=a(t.opacity,r.opacity);return function(n){return t.l=e(n),t.a=o(n),t.b=u(n),t.opacity=i(n),t+""}}function S(t,r){var e=u((t=n.hcl(t)).h,(r=n.hcl(r)).h),o=a(t.c,r.c),i=a(t.l,r.l),c=a(t.opacity,r.opacity);return function(n){return t.h=e(n),t.c=o(n),t.l=i(n),t.opacity=c(n),t+""}}function C(t,r){var e=a((t=n.hcl(t)).h,(r=n.hcl(r)).h),o=a(t.c,r.c),u=a(t.l,r.l),i=a(t.opacity,r.opacity);return function(n){return t.h=e(n),t.c=o(n),t.l=u(n),t.opacity=i(n),t+""}}var T,X=function K(t){function r(t,r){var o=e((t=n.rgb(t)).r,(r=n.rgb(r)).r),u=e(t.g,r.g),i=e(t.b,r.b),a=e(t.opacity,r.opacity);return function(n){return t.r=o(n),t.g=u(n),t.b=i(n),t.opacity=a(n),t+""}}var e=i(t);return r.gamma=K,r}(1),_=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,O=new RegExp(_.source,"g"),P=[function(t,r){var e,o=typeof r;return("string"===o?(e=n.color(r))?(r=e,X):p:r instanceof n.color?X:Array.isArray(r)?c:"object"===o&&isNaN(r)?f:l)(t,r)}],Q=180/Math.PI,V={a:1,b:0,c:0,d:1,e:0,f:0},Z=Math.SQRT2,z=2,B=4,D=1e-12,F=function U(t){function r(r,e){var o=u((r=n.cubehelix(r)).h,(e=n.cubehelix(e)).h),i=a(r.s,e.s),c=a(r.l,e.l),l=a(r.opacity,e.opacity);return function(n){return r.h=o(n),r.s=i(n),r.l=c(Math.pow(n,t)),r.opacity=l(n),r+""}}return t=+t,r.gamma=U,r}(1),G=function W(t){function r(r,e){var o=a((r=n.cubehelix(r)).h,(e=n.cubehelix(e)).h),u=a(r.s,e.s),i=a(r.l,e.l),c=a(r.opacity,e.opacity);return function(n){return r.h=o(n),r.s=u(n),r.l=i(Math.pow(n,t)),r.opacity=c(n),r+""}}return t=+t,r.gamma=W,r}(1),J="0.5.2";t.version=J,t.interpolate=y,t.interpolators=P,t.interpolateArray=c,t.interpolateNumber=l,t.interpolateObject=f,t.interpolateRound=g,t.interpolateString=p,t.interpolateTransform=k,t.interpolateZoom=I,t.interpolateRgb=X,t.interpolateHsl=L,t.interpolateHslLong=R,t.interpolateLab=E,t.interpolateHcl=S,t.interpolateHclLong=C,t.interpolateCubehelix=F,t.interpolateCubehelixLong=G});
{
"name": "d3-interpolate",
"version": "0.5.1",
"version": "0.5.2",
"description": "Interpolate numbers, colors, strings, arrays, objects, whatever!",

@@ -25,3 +25,3 @@ "keywords": [

"pretest": "mkdir -p build && node -e 'process.stdout.write(\"var version = \\\"\" + require(\"./package.json\").version + \"\\\"; export * from \\\"../index\\\"; export {version};\");' > build/bundle.js && rollup -f umd -g d3-color:d3_color -n d3_interpolate -o build/d3-interpolate.js -- build/bundle.js",
"test": "faucet `find test -name '*-test.js'` && eslint index.js src",
"test": "faucet `find test -name '*-test.js'` && eslint index.js src test",
"prepublish": "npm run test && uglifyjs build/d3-interpolate.js -c -m -o build/d3-interpolate.min.js && rm -f build/d3-interpolate.zip && zip -j build/d3-interpolate.zip -- LICENSE README.md build/d3-interpolate.js build/d3-interpolate.min.js",

@@ -31,3 +31,3 @@ "postpublish": "VERSION=`node -e 'console.log(require(\"./package.json\").version)'`; git push && git tag -am \"Release $VERSION.\" v${VERSION} && git push --tags && cp build/d3-interpolate.js ../d3.github.com/d3-interpolate.v0.5.js && cp build/d3-interpolate.min.js ../d3.github.com/d3-interpolate.v0.5.min.js && cd ../d3.github.com && git add d3-interpolate.v0.5.js d3-interpolate.v0.5.min.js && git commit -m \"d3-interpolate ${VERSION}\" && git push"

"dependencies": {
"d3-color": "~0.3.4"
"d3-color": "~0.4.0"
},

@@ -34,0 +34,0 @@ "devDependencies": {

@@ -18,3 +18,3 @@ # d3-interpolate

```js
d3.interpolateLab("steelblue", "brown")(0.5); // "#8e5c6d"
d3.interpolateLab("steelblue", "brown")(0.5); // "rgb(142, 92, 109)"
```

@@ -26,5 +26,5 @@

var i = d3.interpolate({colors: ["red", "blue"]}, {colors: ["white", "black"]});
i(0.0); // {colors: ["#ff0000", "#0000ff"]}
i(0.5); // {colors: ["#ff8080", "#000080"]}
i(1.0); // {colors: ["#ffffff", "#000000"]}
i(0.0); // {colors: ["rgb(255, 0, 0)", "rgb(0, 0, 255)"]}
i(0.5); // {colors: ["rgb(255, 128, 128)", "rgb(0, 0, 128)"]}
i(1.0); // {colors: ["rgb(255, 255, 255)", "rgb(0, 0, 0)"]}
```

@@ -39,3 +39,3 @@

```html
<script src="https://d3js.org/d3-color.v0.3.min.js"></script>
<script src="https://d3js.org/d3-color.v0.4.min.js"></script>
<script src="https://d3js.org/d3-interpolate.v0.5.min.js"></script>

@@ -103,3 +103,3 @@ ```

For example, if *a* is `"300 12px sans-serif"`, and *b* is `"500 36px Comic-Sans"`, two embedded numbers are found. The remaining static parts of the string are a space between the two numbers (`" "`), and the suffix (`"px Comic-Sans"`). The result of the interpolator at *t* = .5 is `"400 24px Comic-Sans"`.
For example, if *a* is `"300 12px sans-serif"`, and *b* is `"500 36px Comic-Sans"`, two embedded numbers are found. The remaining static parts of the string are a space between the two numbers (`" "`), and the suffix (`"px Comic-Sans"`). The result of the interpolator at *t* = 0.5 is `"400 24px Comic-Sans"`.

@@ -110,3 +110,3 @@ <a name="interpolateArray" href="#interpolateArray">#</a> d3.<b>interpolateArray</b>(<i>a</i>, <i>b</i>)

For example, if *a* is the array `[0, 1]` and *b* is the array `[1, 10, 100]`, then the result of the interpolator for *t* = .5 is the array `[.5, 5.5, 100]`.
For example, if *a* is the array `[0, 1]` and *b* is the array `[1, 10, 100]`, then the result of the interpolator for *t* = 0.5 is the array `[0.5, 5.5, 100]`.

@@ -119,3 +119,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 for performance reasons; interpolators are often part of the inner loop of [animated transitions](https://github.com/d3/d3-transition).

For example, if *a* is the object `{x: 0, y: 1}` and *b* is the object `{x: 1, y: 10, z: 100}`, the result of the interpolator for *t* = .5 is the object `{x: .5, y: 5.5, z: 100}`.
For example, if *a* is the object `{x: 0, y: 1}` and *b* is the object `{x: 1, y: 10, z: 100}`, the result of the interpolator for *t* = 0.5 is the object `{x: 0.5, y: 5.5, z: 100}`.

@@ -140,18 +140,8 @@ Object interpolation is particularly useful for *dataspace interpolation*, where data is interpolated rather than attribute values. For example, you can interpolate an object which describes an arc in a pie chart, and then use d3.svg.arc to compute the new SVG path data.

Or, with a corrected [gamma](#rgb_gamma) of 2.2:
Or, with a corrected [gamma](#interpolate_gamma) of 2.2:
<img src="https://raw.githubusercontent.com/d3/d3-interpolate/master/img/rgbGamma.png" width="100%" height="40" alt="rgbGamma">
Returns an RGB color space interpolator between the two colors *a* and *b* with a configurable [gamma](#rgb_gamma). If the gamma is not specified, it defaults to 1.0. The colors *a* and *b* need not be in RGB; they will be converted to RGB using [color.rgb](https://github.com/d3/d3-color#rgb). The return value of the interpolator is a hexadecimal RGB string.
Returns an RGB color space interpolator between the two colors *a* and *b* with a configurable [gamma](#interpolate_gamma). If the gamma is not specified, it defaults to 1.0. The colors *a* and *b* need not be in RGB; they will be converted to RGB using [color.rgb](https://github.com/d3/d3-color#rgb). The return value of the interpolator is an RGB string.
<a name="rgb_gamma" href="#rgb_gamma">#</a> <i>rgb</i>.<b>gamma</b>(<i>gamma</i>)
Returns a new RGB interpolator factory using the specified *gamma*. For example, to interpolate from purple to orange with a gamma of 2.2:
```js
var interpolate = d3.interpolateRgb.gamma(2.2)("purple", "orange");
```
See Eric Brasseur’s article, [Gamma error in picture scaling](https://web.archive.org/web/20160112115812/http://www.4p8.com/eric.brasseur/gamma.html), for more on gamma correction.
<a name="interpolateHsl" href="#interpolateHsl">#</a> d3.<b>interpolateHsl</b>(<i>a</i>, <i>b</i>)

@@ -161,3 +151,3 @@

Returns an HSL color space interpolator between the two colors *a* and *b*. The colors *a* and *b* need not be in HSL; they will be converted to HSL using [color.hsl](https://github.com/d3/d3-color#hsl). If either color’s hue or saturation is NaN, the opposing color’s channel value is used. The shortest path between hues is used. The return value of the interpolator is a hexadecimal RGB string.
Returns an HSL color space interpolator between the two colors *a* and *b*. The colors *a* and *b* need not be in HSL; they will be converted to HSL using [color.hsl](https://github.com/d3/d3-color#hsl). If either color’s hue or saturation is NaN, the opposing color’s channel value is used. The shortest path between hues is used. The return value of the interpolator is an RGB string.

@@ -174,3 +164,3 @@ <a name="interpolateHslLong" href="#interpolateHslLong">#</a> d3.<b>interpolateHslLong</b>(<i>a</i>, <i>b</i>)

Returns a Lab color space interpolator between the two colors *a* and *b*. The colors *a* and *b* need not be in Lab; they will be converted to Lab using [color.lab](https://github.com/d3/d3-color#lab). The return value of the interpolator is a hexadecimal RGB string.
Returns a Lab color space interpolator between the two colors *a* and *b*. The colors *a* and *b* need not be in Lab; they will be converted to Lab using [color.lab](https://github.com/d3/d3-color#lab). The return value of the interpolator is an RGB string.

@@ -181,3 +171,3 @@ <a name="interpolateHcl" href="#interpolateHcl">#</a> d3.<b>interpolateHcl</b>(<i>a</i>, <i>b</i>)

Returns an HCL color space interpolator between the two colors *a* and *b*. The colors *a* and *b* need not be in HCL; they will be converted to HCL using [color.hcl](https://github.com/d3/d3-color#hcl). If either color’s hue or chroma is NaN, the opposing color’s channel value is used. The shortest path between hues is used. The return value of the interpolator is a hexadecimal RGB string.
Returns an HCL color space interpolator between the two colors *a* and *b*. The colors *a* and *b* need not be in HCL; they will be converted to HCL using [color.hcl](https://github.com/d3/d3-color#hcl). If either color’s hue or chroma is NaN, the opposing color’s channel value is used. The shortest path between hues is used. The return value of the interpolator is an RGB string.

@@ -194,7 +184,7 @@ <a name="interpolateHclLong" href="#interpolateHclLong">#</a> d3.<b>interpolateHclLong</b>(<i>a</i>, <i>b</i>)

Or, with a [gamma](#cubehelix_gamma) of 3.0 to emphasize high-intensity values:
Or, with a [gamma](#interpolate_gamma) of 3.0 to emphasize high-intensity values:
<img src="https://raw.githubusercontent.com/d3/d3-interpolate/master/img/cubehelixGamma.png" width="100%" height="40" alt="cubehelixGamma">
Returns a Cubehelix color space interpolator between the two colors *a* and *b* using a configurable [gamma](#cubehelix_gamma). If the gamma is not specified, it defaults to 1.0. The colors *a* and *b* need not be in Cubehelix; they will be converted to Cubehelix using [color.cubehelix](https://github.com/d3/d3-color#cubehelix). If either color’s hue or saturation is NaN, the opposing color’s channel value is used. The shortest path between hues is used. The return value of the interpolator is a hexadecimal RGB string.
Returns a Cubehelix color space interpolator between the two colors *a* and *b* using a configurable [gamma](#interpolate_gamma). If the gamma is not specified, it defaults to 1.0. The colors *a* and *b* need not be in Cubehelix; they will be converted to Cubehelix using [color.cubehelix](https://github.com/d3/d3-color#cubehelix). If either color’s hue or saturation is NaN, the opposing color’s channel value is used. The shortest path between hues is used. The return value of the interpolator is an RGB string.

@@ -205,3 +195,3 @@ <a name="interpolateCubehelixLong" href="#interpolateCubehelixLong">#</a> d3.<b>interpolateCubehelixLong</b>(<i>a</i>, <i>b</i>)

Or, with a [gamma](#cubehelix_gamma) of 3.0 to emphasize high-intensity values:
Or, with a [gamma](#interpolate_gamma) of 3.0 to emphasize high-intensity values:

@@ -212,8 +202,12 @@ <img src="https://raw.githubusercontent.com/d3/d3-interpolate/master/img/cubehelixGammaLong.png" width="100%" height="40" alt="cubehelixGammaLong">

<a name="cubehelix_gamma" href="#cubehelix_gamma">#</a> <i>cubehelix</i>.<b>gamma</b>(<i>gamma</i>)
### Gamma Correction
Returns a new Cubehelix interpolator factory using the specified *gamma*. For example, to interpolate from red to blue with a gamma of 3.0:
<a name="interpolate_gamma" href="#interpolate_gamma">#</a> <i>interpolate</i>.<b>gamma</b>(<i>gamma</i>)
Given that *interpolate* is one of [interpolateRgb](#interpolateRgb), [interpolateCubehelix](#interpolateCubehelix) or [interpolateCubehelixLong](#interpolateCubehelixLong), returns a new interpolator factory of the same type using the specified *gamma*. For example, to interpolate from purple to orange with a gamma of 2.2 in RGB space:
```js
var interpolate = d3.interpolateCubehelix.gamma(3.0)("red", "blue");
var interpolate = d3.interpolateRgb.gamma(2.2)("purple", "orange");
```
See Eric Brasseur’s article, [Gamma error in picture scaling](https://web.archive.org/web/20160112115812/http://www.4p8.com/eric.brasseur/gamma.html), for more on gamma correction.

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

import {cubehelix as color} from "d3-color";
import deltaHue from "./deltaHue";
import {cubehelix} from "d3-color";
import interpolateColor, {hue as interpolateHue} from "./color";

@@ -7,28 +7,19 @@ export default (function gamma(y) {

function cubehelix(a, b) {
a = color(a);
b = color(b);
var ah = a.h,
as = a.s,
al = a.l,
bh = b.h,
bs = b.s,
bl = b.l || 0;
if (isNaN(ah)) ah = bh;
if (isNaN(as)) as = bs;
if (isNaN(al)) al = bl;
bh = deltaHue(bh, ah) || 0;
bs = (bs - as) || 0;
bl -= al;
function interpolateCubehelix(start, end) {
var h = interpolateHue((start = cubehelix(start)).h, (end = cubehelix(end)).h),
s = interpolateColor(start.s, end.s),
l = interpolateColor(start.l, end.l),
opacity = interpolateColor(start.opacity, end.opacity);
return function(t) {
a.h = ah + bh * t;
a.s = as + bs * t;
a.l = al + bl * Math.pow(t, y);
return a + "";
start.h = h(t);
start.s = s(t);
start.l = l(Math.pow(t, y));
start.opacity = opacity(t);
return start + "";
};
}
cubehelix.gamma = gamma;
interpolateCubehelix.gamma = gamma;
return cubehelix;
return interpolateCubehelix;
})(1);

@@ -1,2 +0,3 @@

import {cubehelix as color} from "d3-color";
import {cubehelix} from "d3-color";
import interpolateColor from "./color";

@@ -6,28 +7,19 @@ export default (function gamma(y) {

function cubehelix(a, b) {
a = color(a);
b = color(b);
var ah = a.h,
as = a.s,
al = a.l,
bh = b.h,
bs = b.s,
bl = b.l || 0;
if (isNaN(ah)) ah = bh;
if (isNaN(as)) as = bs;
if (isNaN(al)) al = bl;
bh = (bh - ah) || 0;
bs = (bs - as) || 0;
bl -= al;
function interpolateCubehelixLong(start, end) {
var h = interpolateColor((start = cubehelix(start)).h, (end = cubehelix(end)).h),
s = interpolateColor(start.s, end.s),
l = interpolateColor(start.l, end.l),
opacity = interpolateColor(start.opacity, end.opacity);
return function(t) {
a.h = ah + bh * t;
a.s = as + bs * t;
a.l = al + bl * Math.pow(t, y);
return a + "";
start.h = h(t);
start.s = s(t);
start.l = l(Math.pow(t, y));
start.opacity = opacity(t);
return start + "";
};
}
cubehelix.gamma = gamma;
interpolateCubehelixLong.gamma = gamma;
return cubehelix;
return interpolateCubehelixLong;
})(1);
import {hcl} from "d3-color";
import deltaHue from "./deltaHue";
import interpolateColor, {hue as interpolateHue} from "./color";
export default function(a, b) {
a = hcl(a);
b = hcl(b);
var ah = a.h,
ac = a.c,
al = a.l,
bh = b.h,
bc = b.c,
bl = b.l || 0;
if (isNaN(ah)) ah = bh;
if (isNaN(ac)) ac = bc;
if (isNaN(al)) al = bl;
bh = deltaHue(bh, ah) || 0;
bc = (bc - ac) || 0;
bl -= al;
export default function interpolateHcl(start, end) {
var h = interpolateHue((start = hcl(start)).h, (end = hcl(end)).h),
c = interpolateColor(start.c, end.c),
l = interpolateColor(start.l, end.l),
opacity = interpolateColor(start.opacity, end.opacity);
return function(t) {
a.h = ah + bh * t;
a.c = ac + bc * t;
a.l = al + bl * t;
return a + "";
start.h = h(t);
start.c = c(t);
start.l = l(t);
start.opacity = opacity(t);
return start + "";
};
}
import {hcl} from "d3-color";
import interpolateColor from "./color";
export default function(a, b) {
a = hcl(a);
b = hcl(b);
var ah = a.h,
ac = a.c,
al = a.l,
bh = b.h,
bc = b.c,
bl = b.l || 0;
if (isNaN(ah)) ah = bh;
if (isNaN(ac)) ac = bc;
if (isNaN(al)) al = bl;
bh = (bh - ah) || 0;
bc = (bc - ac) || 0;
bl -= al;
export default function interpolateHclLong(start, end) {
var h = interpolateColor((start = hcl(start)).h, (end = hcl(end)).h),
c = interpolateColor(start.c, end.c),
l = interpolateColor(start.l, end.l),
opacity = interpolateColor(start.opacity, end.opacity);
return function(t) {
a.h = ah + bh * t;
a.c = ac + bc * t;
a.l = al + bl * t;
return a + "";
start.h = h(t);
start.c = c(t);
start.l = l(t);
start.opacity = opacity(t);
return start + "";
};
}
import {hsl} from "d3-color";
import deltaHue from "./deltaHue";
import interpolateColor, {hue as interpolateHue} from "./color";
export default function(a, b) {
a = hsl(a);
b = hsl(b);
var ah = a.h,
as = a.s,
al = a.l,
bh = b.h,
bs = b.s,
bl = b.l || 0;
if (isNaN(ah)) ah = bh;
if (isNaN(as)) as = bs;
if (isNaN(al)) al = bl;
bh = deltaHue(bh, ah) || 0;
bs = (bs - as) || 0;
bl -= al;
export default function interpolateHsl(start, end) {
var h = interpolateHue((start = hsl(start)).h, (end = hsl(end)).h),
s = interpolateColor(start.s, end.s),
l = interpolateColor(start.l, end.l),
opacity = interpolateColor(start.opacity, end.opacity);
return function(t) {
a.h = ah + bh * t;
a.s = as + bs * t;
a.l = al + bl * t;
return a + "";
start.h = h(t);
start.s = s(t);
start.l = l(t);
start.opacity = opacity(t);
return start + "";
};
}
import {hsl} from "d3-color";
import interpolateColor from "./color";
export default function(a, b) {
a = hsl(a);
b = hsl(b);
var ah = a.h,
as = a.s,
al = a.l,
bh = b.h,
bs = b.s,
bl = b.l || 0;
if (isNaN(ah)) ah = bh;
if (isNaN(as)) as = bs;
if (isNaN(al)) al = bl;
bh = (bh - ah) || 0;
bs = (bs - as) || 0;
bl -= al;
export default function interpolateHslLong(start, end) {
var h = interpolateColor((start = hsl(start)).h, (end = hsl(end)).h),
s = interpolateColor(start.s, end.s),
l = interpolateColor(start.l, end.l),
opacity = interpolateColor(start.opacity, end.opacity);
return function(t) {
a.h = ah + bh * t;
a.s = as + bs * t;
a.l = al + bl * t;
return a + "";
start.h = h(t);
start.s = s(t);
start.l = l(t);
start.opacity = opacity(t);
return start + "";
};
}
import {lab} from "d3-color";
import interpolateColor from "./color";
export default function(a, b) {
a = lab(a);
b = lab(b);
var al = a.l,
aa = a.a,
ab = a.b,
bl = b.l || 0,
ba = b.a || 0,
bb = b.b || 0;
if (isNaN(al)) al = bl;
if (isNaN(aa)) aa = ba;
if (isNaN(ab)) ab = bb;
bl -= al;
ba -= aa;
bb -= ab;
export default function interpolateLab(start, end) {
var l = interpolateColor((start = lab(start)).l, (end = lab(end)).l),
a = interpolateColor(start.a, end.a),
b = interpolateColor(start.b, end.b),
opacity = interpolateColor(start.opacity, end.opacity);
return function(t) {
a.l = al + bl * t;
a.a = aa + ba * t;
a.b = ab + bb * t;
return a + "";
start.l = l(t);
start.a = a(t);
start.b = b(t);
start.opacity = opacity(t);
return start + "";
};
}

@@ -1,58 +0,24 @@

import {rgb as color} from "d3-color";
import {rgb} from "d3-color";
import {gamma as interpolateGamma} from "./color";
function rgb(a, b) {
a = color(a);
b = color(b);
var ar = a.r,
ag = a.g,
ab = a.b,
br = b.r || 0,
bg = b.g || 0,
bb = b.b || 0;
if (isNaN(ar)) ar = br;
if (isNaN(ag)) ag = bg;
if (isNaN(ab)) ab = bb;
br -= ar;
bg -= ag;
bb -= ab;
return function(t) {
a.r = ar + br * t;
a.g = ag + bg * t;
a.b = ab + bb * t;
return a + "";
};
}
export default (function gamma(y) {
var interpolateColor = interpolateGamma(y);
rgb.gamma = function gamma(y) {
y = +y;
function rgb(a, b) {
a = color(a);
b = color(b);
var ar = Math.pow(a.r, y),
ag = Math.pow(a.g, y),
ab = Math.pow(a.b, y),
br = Math.pow(b.r || 0, y),
bg = Math.pow(b.g || 0, y),
bb = Math.pow(b.b || 0, y);
if (isNaN(ar)) ar = br;
if (isNaN(ag)) ag = bg;
if (isNaN(ab)) ab = bb;
br -= ar;
bg -= ag;
bb -= ab;
y = 1 / y;
function interpolateRgb(start, end) {
var r = interpolateColor((start = rgb(start)).r, (end = rgb(end)).r),
g = interpolateColor(start.g, end.g),
b = interpolateColor(start.b, end.b),
opacity = interpolateColor(start.opacity, end.opacity);
return function(t) {
a.r = Math.pow(ar + br * t, y);
a.g = Math.pow(ag + bg * t, y);
a.b = Math.pow(ab + bb * t, y);
return a + "";
start.r = r(t);
start.g = g(t);
start.b = b(t);
start.opacity = opacity(t);
return start + "";
};
}
rgb.gamma = gamma;
interpolateRgb.gamma = gamma;
return rgb;
};
export default rgb;
return interpolateRgb;
})(1);

Sorry, the diff of this file is not supported yet

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