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.8.0 to 0.8.1

src/basis.js

232

build/d3-interpolate.js

@@ -7,4 +7,36 @@ (function (global, factory) {

var version = "0.8.0";
var version = "0.8.1";
function basis(t1, v0, v1, v2, v3) {
var t2 = t1 * t1, t3 = t2 * t1;
return ((1 - 3 * t1 + 3 * t2 - t3) * v0
+ (4 - 6 * t2 + 3 * t3) * v1
+ (1 + 3 * t1 + 3 * t2 - 3 * t3) * v2
+ t3 * v3) / 6;
}
function basis$1(values) {
var n = values.length - 1;
return function(t) {
var i = Math.min(n - 1, Math.floor(t * n)),
v1 = values[i],
v2 = values[i + 1],
v0 = i > 0 ? values[i - 1] : 2 * v1 - v2,
v3 = i < n - 1 ? values[i + 2] : 2 * v2 - v1;
return basis((t - i / n) * n, v0, v1, v2, v3);
};
}
function basisClosed(values) {
var n = values.length;
return function(t) {
var i = Math.floor(t * n),
v0 = values[(i + n - 1) % n],
v1 = values[i % n],
v2 = values[(i + 1) % n],
v3 = values[(i + 2) % n];
return basis((t - i / n) * n, v0, v1, v2, v3);
};
}
function constant(x) {

@@ -28,3 +60,3 @@ return function() {

function interpolateHue(a, b) {
function hue(a, b) {
var d = b - a;

@@ -45,10 +77,10 @@ return d ? linear(a, d > 180 || d < -180 ? d - 360 * Math.round(d / 360) : d) : constant(isNaN(a) ? b : a);

var rgb$1 = (function gamma$$(y) {
var interpolateColor = gamma(y);
var rgb$1 = (function rgbGamma(y) {
var color = 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);
function rgb(start, end) {
var r = color((start = d3Color.rgb(start)).r, (end = d3Color.rgb(end)).r),
g = color(start.g, end.g),
b = color(start.b, end.b),
opacity = color(start.opacity, end.opacity);
return function(t) {

@@ -63,7 +95,36 @@ start.r = r(t);

interpolateRgb.gamma = gamma$$;
rgb.gamma = rgbGamma;
return interpolateRgb;
return rgb;
})(1);
function rgbSpline(spline) {
return function(colors) {
var n = colors.length,
r = new Array(n),
g = new Array(n),
b = new Array(n),
i, color;
for (i = 0; i < n; ++i) {
color = d3Color.rgb(colors[i]);
r[i] = color.r || 0;
g[i] = color.g || 0;
b[i] = color.b || 0;
}
r = spline(r);
g = spline(g);
b = spline(b);
color.opacity = 1;
return function(t) {
color.r = r(t);
color.g = g(t);
color.b = b(t);
return color + "";
};
};
}
var rgbBasis = rgbSpline(basis$1);
var rgbBasisClosed = rgbSpline(basisClosed);
function array(a, b) {

@@ -372,31 +433,22 @@ var nb = b ? b.length : 0,

function interpolateHsl(start, end) {
var h = interpolateHue((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) {
start.h = h(t);
start.s = s(t);
start.l = l(t);
start.opacity = opacity(t);
return start + "";
};
function hsl$1(hue) {
return function(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) {
start.h = h(t);
start.s = s(t);
start.l = l(t);
start.opacity = opacity(t);
return start + "";
};
}
}
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) {
start.h = h(t);
start.s = s(t);
start.l = l(t);
start.opacity = opacity(t);
return start + "";
};
}
var hsl$2 = hsl$1(hue);
var hslLong = hsl$1(nogamma);
function interpolateLab(start, end) {
function lab$1(start, end) {
var l = nogamma((start = d3Color.lab(start)).l, (end = d3Color.lab(end)).l),

@@ -415,36 +467,6 @@ a = nogamma(start.a, end.a),

function interpolateHcl(start, end) {
var h = interpolateHue((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) {
start.h = h(t);
start.c = c(t);
start.l = l(t);
start.opacity = opacity(t);
return start + "";
};
}
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) {
start.h = h(t);
start.c = c(t);
start.l = l(t);
start.opacity = opacity(t);
return start + "";
};
}
var cubehelix$1 = (function gamma(y) {
y = +y;
function interpolateCubehelix(start, end) {
var h = interpolateHue((start = d3Color.cubehelix(start)).h, (end = d3Color.cubehelix(end)).h),
s = nogamma(start.s, end.s),
function hcl$1(hue) {
return function(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),

@@ -454,4 +476,4 @@ opacity = nogamma(start.opacity, end.opacity);

start.h = h(t);
start.s = s(t);
start.l = l(Math.pow(t, y));
start.c = c(t);
start.l = l(t);
start.opacity = opacity(t);

@@ -461,29 +483,33 @@ return start + "";

}
}
interpolateCubehelix.gamma = gamma;
var hcl$2 = hcl$1(hue);
var hclLong = hcl$1(nogamma);
return interpolateCubehelix;
})(1);
function cubehelix$1(hue) {
return (function cubehelixGamma(y) {
y = +y;
var cubehelixLong = (function gamma(y) {
y = +y;
function cubehelix(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) {
start.h = h(t);
start.s = s(t);
start.l = l(Math.pow(t, y));
start.opacity = opacity(t);
return start + "";
};
}
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) {
start.h = h(t);
start.s = s(t);
start.l = l(Math.pow(t, y));
start.opacity = opacity(t);
return start + "";
};
}
cubehelix.gamma = cubehelixGamma;
interpolateCubehelixLong.gamma = gamma;
return cubehelix;
})(1);
}
return interpolateCubehelixLong;
})(1);
var cubehelix$2 = cubehelix$1(hue);
var cubehelixLong = cubehelix$1(nogamma);

@@ -493,2 +519,4 @@ exports.version = version;

exports.interpolateArray = array;
exports.interpolateBasis = basis$1;
exports.interpolateBasisClosed = basisClosed;
exports.interpolateNumber = number;

@@ -502,10 +530,14 @@ exports.interpolateObject = object;

exports.interpolateRgb = rgb$1;
exports.interpolateHsl = interpolateHsl;
exports.interpolateHslLong = interpolateHslLong;
exports.interpolateLab = interpolateLab;
exports.interpolateHcl = interpolateHcl;
exports.interpolateHclLong = interpolateHclLong;
exports.interpolateCubehelix = cubehelix$1;
exports.interpolateRgbBasis = rgbBasis;
exports.interpolateRgbBasisClosed = rgbBasisClosed;
exports.interpolateHsl = hsl$2;
exports.interpolateHslLong = hslLong;
exports.interpolateLab = lab$1;
exports.interpolateHcl = hcl$2;
exports.interpolateHclLong = hclLong;
exports.interpolateCubehelix = cubehelix$2;
exports.interpolateCubehelixLong = cubehelixLong;
Object.defineProperty(exports, '__esModule', { value: true });
}));

@@ -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_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 a(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 u(t){return 1===(t=+t)?i:function(n,e){return e-n?o(n,e,t):r(isNaN(n)?e:n)}}function i(t,n){var o=n-t;return o?e(t,o):r(isNaN(t)?n:t)}function l(t,n){var r,e=n?n.length:0,o=t?Math.min(e,t.length):0,a=new Array(e),u=new Array(e);for(r=0;o>r;++r)a[r]=y(t[r],n[r]);for(;e>r;++r)u[r]=n[r];return function(t){for(r=0;o>r;++r)u[r]=a[r](t);return u}}function c(t,n){return t=+t,n-=t,function(r){return t+n*r}}function s(t,n){var r,e={},o={};null!==t&&"object"==typeof t||(t={}),null!==n&&"object"==typeof n||(n={});for(r in n)r in t?e[r]=y(t[r],n[r]):o[r]=n[r];return function(t){for(r in e)o[r]=e[r](t);return o}}function f(t){return function(){return t}}function p(t){return function(n){return t(n)+""}}function h(t,n){var r,e,o,a=L.lastIndex=R.lastIndex=0,u=-1,i=[],l=[];for(t+="",n+="";(r=L.exec(t))&&(e=R.exec(n));)(o=e.index)>a&&(o=n.slice(a,o),i[u]?i[u]+=o:i[++u]=o),(r=r[0])===(e=e[0])?i[u]?i[u]+=e:i[++u]=e:(i[++u]=null,l.push({i:u,x:c(r,e)})),a=R.lastIndex;return a<n.length&&(o=n.slice(a),i[u]?i[u]+=o:i[++u]=o),i.length<2?l[0]?p(l[0].x):f(n):(n=l.length,function(t){for(var r,e=0;n>e;++e)i[(r=l[e]).i]=r.x(t);return i.join("")})}function y(t,e){var o,a=typeof e;return null==e||"boolean"===a?r(e):("number"===a?c:"string"===a?(o=n.color(e))?(e=o,H):h:e instanceof n.color?H:Array.isArray(e)?l:s)(t,e)}function d(t,n){return t=+t,n-=t,function(r){return Math.round(t+n*r)}}function g(t,n,r,e,o,a){if(t*e===n*r)return null;var u=Math.sqrt(t*t+n*n);t/=u,n/=u;var i=t*r+n*e;r-=t*i,e-=n*i;var l=Math.sqrt(r*r+e*e);return r/=l,e/=l,i/=l,n*r>t*e&&(t=-t,n=-n,i=-i,u=-u),{translateX:o,translateY:a,rotate:Math.atan2(n,t)*V,skewX:Math.atan(i)*V,scaleX:u,scaleY:l}}function v(t){if("none"===t)return T;A||(A=document.createElement("DIV"),C=document.documentElement,E=document.defaultView),A.style.transform=t,t=E.getComputedStyle(C.appendChild(A),null).getPropertyValue("transform"),C.removeChild(A);var n=t.slice(7,-1).split(",");return g(+n[0],+n[1],+n[2],+n[3],+n[4],+n[5])}function x(t){I||(I=document.createElementNS("http://www.w3.org/2000/svg","g")),I.setAttribute("transform",null==t?"":t);var n=I.transform.baseVal.consolidate().matrix;return g(n.a,n.b,n.c,n.d,n.e,n.f)}function m(t,n,r,e){function o(t){return t.length?t.pop()+" ":""}function a(t,e,o,a,u,i){if(t!==o||e!==a){var l=u.push("translate(",null,n,null,r);i.push({i:l-4,x:c(t,o)},{i:l-2,x:c(e,a)})}else(o||a)&&u.push("translate("+o+n+a+r)}function u(t,n,r,a){t!==n?(t-n>180?n+=360:n-t>180&&(t+=360),a.push({i:r.push(o(r)+"rotate(",null,e)-2,x:c(t,n)})):n&&r.push(o(r)+"rotate("+n+e)}function i(t,n,r,a){t!==n?a.push({i:r.push(o(r)+"skewX(",null,e)-2,x:c(t,n)}):n&&r.push(o(r)+"skewX("+n+e)}function l(t,n,r,e,a,u){if(t!==r||n!==e){var i=a.push(o(a)+"scale(",null,",",null,")");u.push({i:i-4,x:c(t,r)},{i:i-2,x:c(n,e)})}else 1===r&&1===e||a.push(o(a)+"scale("+r+","+e+")")}return function(n,r){var e=[],o=[];return n=t(n),r=t(r),a(n.translateX,n.translateY,r.translateX,r.translateY,e,o),u(n.rotate,r.rotate,e,o),i(n.skewX,r.skewX,e,o),l(n.scaleX,n.scaleY,r.scaleX,r.scaleY,e,o),n=r=null,function(t){for(var n,r=-1,a=o.length;++r<a;)e[(n=o[r]).i]=n.x(t);return e.join("")}}}function b(t){return((t=Math.exp(t))+1/t)/2}function M(t){return((t=Math.exp(t))-1/t)/2}function w(t){return((t=Math.exp(2*t))-1)/(t+1)}function X(t,n){var r,e,o=t[0],a=t[1],u=t[2],i=n[0],l=n[1],c=n[2],s=i-o,f=l-a,p=s*s+f*f;if(Z>p)e=Math.log(c/u)/D,r=function(t){return[o+t*s,a+t*f,u*Math.exp(D*t*e)]};else{var h=Math.sqrt(p),y=(c*c-u*u+Q*p)/(2*u*O*h),d=(c*c-u*u-Q*p)/(2*c*O*h),g=Math.log(Math.sqrt(y*y+1)-y),v=Math.log(Math.sqrt(d*d+1)-d);e=(v-g)/D,r=function(t){var n=t*e,r=b(g),i=u/(O*h)*(r*w(D*n+g)-M(g));return[o+i*s,a+i*f,u*r/b(D*n+g)]}}return r.duration=1e3*e,r}function N(t,r){var e=a((t=n.hsl(t)).h,(r=n.hsl(r)).h),o=i(t.s,r.s),u=i(t.l,r.l),l=i(t.opacity,r.opacity);return function(n){return t.h=e(n),t.s=o(n),t.l=u(n),t.opacity=l(n),t+""}}function Y(t,r){var e=i((t=n.hsl(t)).h,(r=n.hsl(r)).h),o=i(t.s,r.s),a=i(t.l,r.l),u=i(t.opacity,r.opacity);return function(n){return t.h=e(n),t.s=o(n),t.l=a(n),t.opacity=u(n),t+""}}function j(t,r){var e=i((t=n.lab(t)).l,(r=n.lab(r)).l),o=i(t.a,r.a),a=i(t.b,r.b),u=i(t.opacity,r.opacity);return function(n){return t.l=e(n),t.a=o(n),t.b=a(n),t.opacity=u(n),t+""}}function k(t,r){var e=a((t=n.hcl(t)).h,(r=n.hcl(r)).h),o=i(t.c,r.c),u=i(t.l,r.l),l=i(t.opacity,r.opacity);return function(n){return t.h=e(n),t.c=o(n),t.l=u(n),t.opacity=l(n),t+""}}function q(t,r){var e=i((t=n.hcl(t)).h,(r=n.hcl(r)).h),o=i(t.c,r.c),a=i(t.l,r.l),u=i(t.opacity,r.opacity);return function(n){return t.h=e(n),t.c=o(n),t.l=a(n),t.opacity=u(n),t+""}}var A,C,E,I,S="0.8.0",H=function F(t){function r(t,r){var o=e((t=n.rgb(t)).r,(r=n.rgb(r)).r),a=e(t.g,r.g),u=e(t.b,r.b),i=e(t.opacity,r.opacity);return function(n){return t.r=o(n),t.g=a(n),t.b=u(n),t.opacity=i(n),t+""}}var e=u(t);return r.gamma=F,r}(1),L=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,R=new RegExp(L.source,"g"),V=180/Math.PI,T={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1},_=m(v,"px, ","px)","deg)"),P=m(x,", ",")",")"),D=Math.SQRT2,O=2,Q=4,Z=1e-12,z=function G(t){function r(r,e){var o=a((r=n.cubehelix(r)).h,(e=n.cubehelix(e)).h),u=i(r.s,e.s),l=i(r.l,e.l),c=i(r.opacity,e.opacity);return function(n){return r.h=o(n),r.s=u(n),r.l=l(Math.pow(n,t)),r.opacity=c(n),r+""}}return t=+t,r.gamma=G,r}(1),B=function J(t){function r(r,e){var o=i((r=n.cubehelix(r)).h,(e=n.cubehelix(e)).h),a=i(r.s,e.s),u=i(r.l,e.l),l=i(r.opacity,e.opacity);return function(n){return r.h=o(n),r.s=a(n),r.l=u(Math.pow(n,t)),r.opacity=l(n),r+""}}return t=+t,r.gamma=J,r}(1);t.version=S,t.interpolate=y,t.interpolateArray=l,t.interpolateNumber=c,t.interpolateObject=s,t.interpolateRound=d,t.interpolateString=h,t.interpolateTransformCss=_,t.interpolateTransformSvg=P,t.interpolateZoom=X,t.interpolateRgb=H,t.interpolateHsl=N,t.interpolateHslLong=Y,t.interpolateLab=j,t.interpolateHcl=k,t.interpolateHclLong=q,t.interpolateCubehelix=z,t.interpolateCubehelixLong=B});
!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_interpolate||{},t.d3_color)}(this,function(t,n){"use strict";function r(t,n,r,e,o){var a=t*t,u=a*t;return((1-3*t+3*a-u)*n+(4-6*a+3*u)*r+(1+3*t+3*a-3*u)*e+u*o)/6}function e(t){var n=t.length-1;return function(e){var o=Math.min(n-1,Math.floor(e*n)),a=t[o],u=t[o+1],i=o>0?t[o-1]:2*a-u,l=n-1>o?t[o+2]:2*u-a;return r((e-o/n)*n,i,a,u,l)}}function o(t){var n=t.length;return function(e){var o=Math.floor(e*n),a=t[(o+n-1)%n],u=t[o%n],i=t[(o+1)%n],l=t[(o+2)%n];return r((e-o/n)*n,a,u,i,l)}}function a(t){return function(){return t}}function u(t,n){return function(r){return t+r*n}}function i(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 l(t,n){var r=n-t;return r?u(t,r>180||-180>r?r-360*Math.round(r/360):r):a(isNaN(t)?n:t)}function c(t){return 1===(t=+t)?f:function(n,r){return r-n?i(n,r,t):a(isNaN(n)?r:n)}}function f(t,n){var r=n-t;return r?u(t,r):a(isNaN(t)?n:t)}function s(t){return function(r){var e,o,a=r.length,u=new Array(a),i=new Array(a),l=new Array(a);for(e=0;a>e;++e)o=n.rgb(r[e]),u[e]=o.r||0,i[e]=o.g||0,l[e]=o.b||0;return u=t(u),i=t(i),l=t(l),o.opacity=1,function(t){return o.r=u(t),o.g=i(t),o.b=l(t),o+""}}}function p(t,n){var r,e=n?n.length:0,o=t?Math.min(e,t.length):0,a=new Array(e),u=new Array(e);for(r=0;o>r;++r)a[r]=b(t[r],n[r]);for(;e>r;++r)u[r]=n[r];return function(t){for(r=0;o>r;++r)u[r]=a[r](t);return u}}function h(t,n){return t=+t,n-=t,function(r){return t+n*r}}function d(t,n){var r,e={},o={};null!==t&&"object"==typeof t||(t={}),null!==n&&"object"==typeof n||(n={});for(r in n)r in t?e[r]=b(t[r],n[r]):o[r]=n[r];return function(t){for(r in e)o[r]=e[r](t);return o}}function g(t){return function(){return t}}function v(t){return function(n){return t(n)+""}}function y(t,n){var r,e,o,a=P.lastIndex=T.lastIndex=0,u=-1,i=[],l=[];for(t+="",n+="";(r=P.exec(t))&&(e=T.exec(n));)(o=e.index)>a&&(o=n.slice(a,o),i[u]?i[u]+=o:i[++u]=o),(r=r[0])===(e=e[0])?i[u]?i[u]+=e:i[++u]=e:(i[++u]=null,l.push({i:u,x:h(r,e)})),a=T.lastIndex;return a<n.length&&(o=n.slice(a),i[u]?i[u]+=o:i[++u]=o),i.length<2?l[0]?v(l[0].x):g(n):(n=l.length,function(t){for(var r,e=0;n>e;++e)i[(r=l[e]).i]=r.x(t);return i.join("")})}function b(t,r){var e,o=typeof r;return null==r||"boolean"===o?a(r):("number"===o?h:"string"===o?(e=n.color(r))?(r=e,H):y:r instanceof n.color?H:Array.isArray(r)?p:d)(t,r)}function x(t,n){return t=+t,n-=t,function(r){return Math.round(t+n*r)}}function m(t,n,r,e,o,a){if(t*e===n*r)return null;var u=Math.sqrt(t*t+n*n);t/=u,n/=u;var i=t*r+n*e;r-=t*i,e-=n*i;var l=Math.sqrt(r*r+e*e);return r/=l,e/=l,i/=l,n*r>t*e&&(t=-t,n=-n,i=-i,u=-u),{translateX:o,translateY:a,rotate:Math.atan2(n,t)*O,skewX:Math.atan(i)*O,scaleX:u,scaleY:l}}function M(t){if("none"===t)return D;E||(E=document.createElement("DIV"),I=document.documentElement,S=document.defaultView),E.style.transform=t,t=S.getComputedStyle(I.appendChild(E),null).getPropertyValue("transform"),I.removeChild(E);var n=t.slice(7,-1).split(",");return m(+n[0],+n[1],+n[2],+n[3],+n[4],+n[5])}function w(t){_||(_=document.createElementNS("http://www.w3.org/2000/svg","g")),_.setAttribute("transform",null==t?"":t);var n=_.transform.baseVal.consolidate().matrix;return m(n.a,n.b,n.c,n.d,n.e,n.f)}function X(t,n,r,e){function o(t){return t.length?t.pop()+" ":""}function a(t,e,o,a,u,i){if(t!==o||e!==a){var l=u.push("translate(",null,n,null,r);i.push({i:l-4,x:h(t,o)},{i:l-2,x:h(e,a)})}else(o||a)&&u.push("translate("+o+n+a+r)}function u(t,n,r,a){t!==n?(t-n>180?n+=360:n-t>180&&(t+=360),a.push({i:r.push(o(r)+"rotate(",null,e)-2,x:h(t,n)})):n&&r.push(o(r)+"rotate("+n+e)}function i(t,n,r,a){t!==n?a.push({i:r.push(o(r)+"skewX(",null,e)-2,x:h(t,n)}):n&&r.push(o(r)+"skewX("+n+e)}function l(t,n,r,e,a,u){if(t!==r||n!==e){var i=a.push(o(a)+"scale(",null,",",null,")");u.push({i:i-4,x:h(t,r)},{i:i-2,x:h(n,e)})}else 1===r&&1===e||a.push(o(a)+"scale("+r+","+e+")")}return function(n,r){var e=[],o=[];return n=t(n),r=t(r),a(n.translateX,n.translateY,r.translateX,r.translateY,e,o),u(n.rotate,r.rotate,e,o),i(n.skewX,r.skewX,e,o),l(n.scaleX,n.scaleY,r.scaleX,r.scaleY,e,o),n=r=null,function(t){for(var n,r=-1,a=o.length;++r<a;)e[(n=o[r]).i]=n.x(t);return e.join("")}}}function A(t){return((t=Math.exp(t))+1/t)/2}function C(t){return((t=Math.exp(t))-1/t)/2}function N(t){return((t=Math.exp(2*t))-1)/(t+1)}function Y(t,n){var r,e,o=t[0],a=t[1],u=t[2],i=n[0],l=n[1],c=n[2],f=i-o,s=l-a,p=f*f+s*s;if(J>p)e=Math.log(c/u)/z,r=function(t){return[o+t*f,a+t*s,u*Math.exp(z*t*e)]};else{var h=Math.sqrt(p),d=(c*c-u*u+G*p)/(2*u*F*h),g=(c*c-u*u-G*p)/(2*c*F*h),v=Math.log(Math.sqrt(d*d+1)-d),y=Math.log(Math.sqrt(g*g+1)-g);e=(y-v)/z,r=function(t){var n=t*e,r=A(v),i=u/(F*h)*(r*N(z*n+v)-C(v));return[o+i*f,a+i*s,u*r/A(z*n+v)]}}return r.duration=1e3*e,r}function j(t){return function(r,e){var o=t((r=n.hsl(r)).h,(e=n.hsl(e)).h),a=f(r.s,e.s),u=f(r.l,e.l),i=f(r.opacity,e.opacity);return function(t){return r.h=o(t),r.s=a(t),r.l=u(t),r.opacity=i(t),r+""}}}function k(t,r){var e=f((t=n.lab(t)).l,(r=n.lab(r)).l),o=f(t.a,r.a),a=f(t.b,r.b),u=f(t.opacity,r.opacity);return function(n){return t.l=e(n),t.a=o(n),t.b=a(n),t.opacity=u(n),t+""}}function q(t){return function(r,e){var o=t((r=n.hcl(r)).h,(e=n.hcl(e)).h),a=f(r.c,e.c),u=f(r.l,e.l),i=f(r.opacity,e.opacity);return function(t){return r.h=o(t),r.c=a(t),r.l=u(t),r.opacity=i(t),r+""}}}function R(t){return function r(e){function o(r,o){var a=t((r=n.cubehelix(r)).h,(o=n.cubehelix(o)).h),u=f(r.s,o.s),i=f(r.l,o.l),l=f(r.opacity,o.opacity);return function(t){return r.h=a(t),r.s=u(t),r.l=i(Math.pow(t,e)),r.opacity=l(t),r+""}}return e=+e,o.gamma=r,o}(1)}var E,I,S,_,B="0.8.1",H=function rt(t){function r(t,r){var o=e((t=n.rgb(t)).r,(r=n.rgb(r)).r),a=e(t.g,r.g),u=e(t.b,r.b),i=e(t.opacity,r.opacity);return function(n){return t.r=o(n),t.g=a(n),t.b=u(n),t.opacity=i(n),t+""}}var e=c(t);return r.gamma=rt,r}(1),L=s(e),V=s(o),P=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,T=new RegExp(P.source,"g"),O=180/Math.PI,D={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1},Q=X(M,"px, ","px)","deg)"),Z=X(w,", ",")",")"),z=Math.SQRT2,F=2,G=4,J=1e-12,K=j(l),U=j(f),W=q(l),$=q(f),tt=R(l),nt=R(f);t.version=B,t.interpolate=b,t.interpolateArray=p,t.interpolateBasis=e,t.interpolateBasisClosed=o,t.interpolateNumber=h,t.interpolateObject=d,t.interpolateRound=x,t.interpolateString=y,t.interpolateTransformCss=Q,t.interpolateTransformSvg=Z,t.interpolateZoom=Y,t.interpolateRgb=H,t.interpolateRgbBasis=L,t.interpolateRgbBasisClosed=V,t.interpolateHsl=K,t.interpolateHslLong=U,t.interpolateLab=k,t.interpolateHcl=W,t.interpolateHclLong=$,t.interpolateCubehelix=tt,t.interpolateCubehelixLong=nt,Object.defineProperty(t,"__esModule",{value:!0})});
export var name = "d3-interpolate";
export var version = "0.8.0";
export var version = "0.8.1";
export var description = "Interpolate numbers, colors, strings, arrays, objects, whatever!";

@@ -4,0 +4,0 @@ export var keywords = ["d3","interpolate","interpolation","color"];

export {version} from "./build/package";
export {default as interpolate} from "./src/value";
export {default as interpolateArray} from "./src/array";
export {default as interpolateBasis} from "./src/basis";
export {default as interpolateBasisClosed} from "./src/basisClosed";
export {default as interpolateNumber} from "./src/number";

@@ -10,9 +12,6 @@ export {default as interpolateObject} from "./src/object";

export {default as interpolateZoom} from "./src/zoom";
export {default as interpolateRgb} from "./src/rgb";
export {default as interpolateHsl} from "./src/hsl";
export {default as interpolateHslLong} from "./src/hslLong";
export {default as interpolateRgb, rgbBasis as interpolateRgbBasis, rgbBasisClosed as interpolateRgbBasisClosed} from "./src/rgb";
export {default as interpolateHsl, hslLong as interpolateHslLong} from "./src/hsl";
export {default as interpolateLab} from "./src/lab";
export {default as interpolateHcl} from "./src/hcl";
export {default as interpolateHclLong} from "./src/hclLong";
export {default as interpolateCubehelix} from "./src/cubehelix";
export {default as interpolateCubehelixLong} from "./src/cubehelixLong";
export {default as interpolateHcl, hclLong as interpolateHclLong} from "./src/hcl";
export {default as interpolateCubehelix, cubehelixLong as interpolateCubehelixLong} from "./src/cubehelix";
{
"name": "d3-interpolate",
"version": "0.8.0",
"version": "0.8.1",
"description": "Interpolate numbers, colors, strings, arrays, objects, whatever!",

@@ -5,0 +5,0 @@ "keywords": [

@@ -115,6 +115,8 @@ # d3-interpolate

Returns an interpolator between the two views *a* and *b* of a two-dimensional plane, based on [“Smooth and efficient zooming and panning”](https://www.google.com/search?q=Smooth+and+efficient+zooming+and+panning) by Jarke J. van Wijk and Wim A.A. Nuij. Each view is defined as an array of three numbers: *cx*, *cy* and *width*. The first two coordinates *cx*, *cy* represent the center of the viewport; the last coordinate *width* represents the size of the viewport.
Returns an interpolator between the two views *a* and *b* of a two-dimensional plane, based on [“Smooth and efficient zooming and panning”](http://www.win.tue.nl/~vanwijk/zoompan.pdf) by Jarke J. van Wijk and Wim A.A. Nuij. Each view is defined as an array of three numbers: *cx*, *cy* and *width*. The first two coordinates *cx*, *cy* represent the center of the viewport; the last coordinate *width* represents the size of the viewport.
The returned interpolator exposes a *duration* property which encodes the recommended transition duration in milliseconds. This duration is based on the path length of the curved trajectory through *x,y* space. If you want to a slower or faster transition, multiply this by an arbitrary scale factor (<i>V</i> as described in the original paper).
### Color Spaces
<a name="interpolateRgb" href="#interpolateRgb">#</a> d3.<b>interpolateRgb</b>(<i>a</i>, <i>b</i>)

@@ -128,4 +130,12 @@

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.
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 [d3.rgb](https://github.com/d3/d3-color#rgb). The return value of the interpolator is an RGB string.
<a href="#interpolateRgbBasis" name="interpolateRgbBasis">#</a> d3.<b>interpolateRgbBasis</b>(<i>colors</i>)
Returns a uniform nonrational B-spline interpolator through the specified array of *colors*, which are converted to [RGB color space](https://github.com/d3/d3-color#rgb). Implicit control points are generated such that the interpolator returns *colors*[0] at *t* = 0 and *colors*[*colors*.length - 1] at *t* = 1. Opacity interpolation is not currently supported. See also [d3.interpolateBasis](#interpolateBasis), and see [d3-scale-chromatic](https://github.com/d3/d3-scale-chromatic) for examples.
<a href="#interpolateRgbBasisClosed" name="interpolateRgbBasisClosed">#</a> d3.<b>interpolateRgbBasisClosed</b>(<i>colors</i>)
Returns a uniform nonrational B-spline interpolator through the specified array of *colors*, which are converted to [RGB color space](https://github.com/d3/d3-color#rgb). The control points are implicitly repeated such that the resulting spline has cyclical C² continuity when repeated around *t* in [0,1]; this is useful, for example, to create cyclical color scales. Opacity interpolation is not currently supported. See also [d3.interpolateBasisClosed](#interpolateBasisClosed), and see [d3-scale-chromatic](https://github.com/d3/d3-scale-chromatic) for examples.
<a name="interpolateHsl" href="#interpolateHsl">#</a> d3.<b>interpolateHsl</b>(<i>a</i>, <i>b</i>)

@@ -135,3 +145,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 an 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 [d3.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.

@@ -148,3 +158,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 an 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 [d3.lab](https://github.com/d3/d3-color#lab). The return value of the interpolator is an RGB string.

@@ -155,3 +165,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 an 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 [d3.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.

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

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.
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 [d3.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.

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

### Gamma Correction
<a name="interpolate_gamma" href="#interpolate_gamma">#</a> <i>interpolate</i>.<b>gamma</b>(<i>gamma</i>)

@@ -197,1 +205,13 @@

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.
### Splines
Whereas standard interpolators blend from a starting value *a* at *t* = 0 to an ending value *b* at *t* = 1, spline interpolators smoothly blend multiple input values for *t* in [0,1] using piecewise polynomial functions. Only cubic uniform nonrational [B-splines](https://en.wikipedia.org/wiki/B-spline) are currently supported, also known as basis splines.
<a href="#interpolateBasis" name="interpolateBasis">#</a> d3.<b>interpolateBasis</b>(<i>values</i>)
Returns a uniform nonrational B-spline interpolator through the specified array of *values*, which must be numbers. Implicit control points are generated such that the interpolator returns *values*[0] at *t* = 0 and *values*[*values*.length - 1] at *t* = 1. See also [d3.curveBasis](https://github.com/d3/d3-shape#curveBasis).
<a href="#interpolateBasisClosed" name="interpolateBasisClosed">#</a> d3.<b>interpolateBasisClosed</b>(<i>values</i>)
Returns a uniform nonrational B-spline interpolator through the specified array of *values*, which must be numbers. The control points are implicitly repeated such that the resulting one-dimensional spline has cyclical C² continuity when repeated around *t* in [0,1]. See also [d3.curveBasisClosed](https://github.com/d3/d3-shape#curveBasisClosed).

@@ -1,24 +0,29 @@

import {cubehelix} from "d3-color";
import interpolateColor, {hue as interpolateHue} from "./color";
import {cubehelix as colorCubehelix} from "d3-color";
import color, {hue} from "./color";
export default (function gamma(y) {
y = +y;
function cubehelix(hue) {
return (function cubehelixGamma(y) {
y = +y;
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) {
start.h = h(t);
start.s = s(t);
start.l = l(Math.pow(t, y));
start.opacity = opacity(t);
return start + "";
};
}
function cubehelix(start, end) {
var h = hue((start = colorCubehelix(start)).h, (end = colorCubehelix(end)).h),
s = color(start.s, end.s),
l = color(start.l, end.l),
opacity = color(start.opacity, end.opacity);
return function(t) {
start.h = h(t);
start.s = s(t);
start.l = l(Math.pow(t, y));
start.opacity = opacity(t);
return start + "";
};
}
interpolateCubehelix.gamma = gamma;
cubehelix.gamma = cubehelixGamma;
return interpolateCubehelix;
})(1);
return cubehelix;
})(1);
}
export default cubehelix(hue);
export var cubehelixLong = cubehelix(color);

@@ -1,16 +0,21 @@

import {hcl} from "d3-color";
import interpolateColor, {hue as interpolateHue} from "./color";
import {hcl as colorHcl} from "d3-color";
import color, {hue} from "./color";
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) {
start.h = h(t);
start.c = c(t);
start.l = l(t);
start.opacity = opacity(t);
return start + "";
};
function hcl(hue) {
return function(start, end) {
var h = hue((start = colorHcl(start)).h, (end = colorHcl(end)).h),
c = color(start.c, end.c),
l = color(start.l, end.l),
opacity = color(start.opacity, end.opacity);
return function(t) {
start.h = h(t);
start.c = c(t);
start.l = l(t);
start.opacity = opacity(t);
return start + "";
};
}
}
export default hcl(hue);
export var hclLong = hcl(color);

@@ -1,16 +0,21 @@

import {hsl} from "d3-color";
import interpolateColor, {hue as interpolateHue} from "./color";
import {hsl as colorHsl} from "d3-color";
import color, {hue} from "./color";
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) {
start.h = h(t);
start.s = s(t);
start.l = l(t);
start.opacity = opacity(t);
return start + "";
};
function hsl(hue) {
return function(start, end) {
var h = hue((start = colorHsl(start)).h, (end = colorHsl(end)).h),
s = color(start.s, end.s),
l = color(start.l, end.l),
opacity = color(start.opacity, end.opacity);
return function(t) {
start.h = h(t);
start.s = s(t);
start.l = l(t);
start.opacity = opacity(t);
return start + "";
};
}
}
export default hsl(hue);
export var hslLong = hsl(color);

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

import {lab} from "d3-color";
import interpolateColor from "./color";
import {lab as colorLab} from "d3-color";
import color from "./color";
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);
export default function lab(start, end) {
var l = color((start = colorLab(start)).l, (end = colorLab(end)).l),
a = color(start.a, end.a),
b = color(start.b, end.b),
opacity = color(start.opacity, end.opacity);
return function(t) {

@@ -10,0 +10,0 @@ start.l = l(t);

@@ -1,12 +0,14 @@

import {rgb} from "d3-color";
import {gamma as interpolateGamma} from "./color";
import {rgb as colorRgb} from "d3-color";
import basis from "./basis";
import basisClosed from "./basisClosed";
import {gamma} from "./color";
export default (function gamma(y) {
var interpolateColor = interpolateGamma(y);
export default (function rgbGamma(y) {
var color = gamma(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);
function rgb(start, end) {
var r = color((start = colorRgb(start)).r, (end = colorRgb(end)).r),
g = color(start.g, end.g),
b = color(start.b, end.b),
opacity = color(start.opacity, end.opacity);
return function(t) {

@@ -21,5 +23,34 @@ start.r = r(t);

interpolateRgb.gamma = gamma;
rgb.gamma = rgbGamma;
return interpolateRgb;
return rgb;
})(1);
function rgbSpline(spline) {
return function(colors) {
var n = colors.length,
r = new Array(n),
g = new Array(n),
b = new Array(n),
i, color;
for (i = 0; i < n; ++i) {
color = colorRgb(colors[i]);
r[i] = color.r || 0;
g[i] = color.g || 0;
b[i] = color.b || 0;
}
r = spline(r);
g = spline(g);
b = spline(b);
color.opacity = 1;
return function(t) {
color.r = r(t);
color.g = g(t);
color.b = b(t);
return color + "";
};
};
}
export var rgbBasis = rgbSpline(basis);
export var rgbBasisClosed = rgbSpline(basisClosed);
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