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.3.0 to 0.4.0

2

build/bundle.js

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

var version = "0.3.0"; export * from "../index"; export {version};
var version = "0.4.0"; export * from "../index"; export {version};

@@ -24,2 +24,21 @@ (function (global, factory) {

// TODO sparse arrays?
function array(a, b) {
var x = [],
c = [],
na = a ? a.length : 0,
nb = b ? b.length : 0,
n0 = Math.min(na, nb),
i;
for (i = 0; i < n0; ++i) x.push(value(a[i], b[i]));
for (; i < na; ++i) c[i] = a[i];
for (; i < nb; ++i) c[i] = b[i];
return function(t) {
for (i = 0; i < n0; ++i) c[i] = x[i](t);
return c;
};
};
function number(a, b) {

@@ -36,2 +55,5 @@ return a = +a, b -= a, function(t) {

if (a === null || typeof a !== "object") a = {};
if (b === null || typeof b !== "object") b = {};
for (k in a) {

@@ -136,21 +158,2 @@ if (k in b) {

// TODO sparse arrays?
function array(a, b) {
var x = [],
c = [],
na = a.length,
nb = b.length,
n0 = Math.min(a.length, b.length),
i;
for (i = 0; i < n0; ++i) x.push(value(a[i], b[i]));
for (; i < na; ++i) c[i] = a[i];
for (; i < nb; ++i) c[i] = b[i];
return function(t) {
for (i = 0; i < n0; ++i) c[i] = x[i](t);
return c;
};
};
function round(a, b) {

@@ -474,24 +477,24 @@ return a = +a, b -= a, function(t) {

var version = "0.3.0";
var version = "0.4.0";
exports.version = version;
exports.array = array;
exports.number = number;
exports.object = object;
exports.round = round;
exports.string = string;
exports.transform = transform;
exports.values = values;
exports.value = value;
exports.zoom = zoom;
exports.rgb = rgb;
exports.hsl = hsl;
exports.hslLong = hslLong;
exports.lab = lab;
exports.hcl = hcl;
exports.hclLong = hclLong;
exports.cubehelix = cubehelix;
exports.cubehelixLong = cubehelixLong;
exports.bind = bind;
exports.interpolate = value;
exports.interpolators = values;
exports.interpolateArray = array;
exports.interpolateNumber = number;
exports.interpolateObject = object;
exports.interpolateRound = round;
exports.interpolateString = string;
exports.interpolateTransform = transform;
exports.interpolateZoom = zoom;
exports.interpolateRgb = rgb;
exports.interpolateHsl = hsl;
exports.interpolateHslLong = hslLong;
exports.interpolateLab = lab;
exports.interpolateHcl = hcl;
exports.interpolateHclLong = hclLong;
exports.interpolateCubehelix = cubehelix;
exports.interpolateCubehelixLong = cubehelixLong;
exports.interpolateBind = bind;
}));

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

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

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

export {default as array} from "./src/array";
export {default as number} from "./src/number";
export {default as object} from "./src/object";
export {default as round} from "./src/round";
export {default as string} from "./src/string";
export {default as transform} from "./src/transform";
export {default as values} from "./src/values";
export {default as value} from "./src/value";
export {default as zoom} from "./src/zoom";
export {default as rgb} from "./src/rgb";
export {default as hsl} from "./src/hsl";
export {default as hslLong} from "./src/hslLong";
export {default as lab} from "./src/lab";
export {default as hcl} from "./src/hcl";
export {default as hclLong} from "./src/hclLong";
export {default as cubehelix} from "./src/cubehelix";
export {default as cubehelixLong} from "./src/cubehelixLong";
export {default as bind} from "./src/bind";
export {default as interpolate} from "./src/value";
export {default as interpolators} from "./src/values";
export {default as interpolateArray} from "./src/array";
export {default as interpolateNumber} from "./src/number";
export {default as interpolateObject} from "./src/object";
export {default as interpolateRound} from "./src/round";
export {default as interpolateString} from "./src/string";
export {default as interpolateTransform} from "./src/transform";
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 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 interpolateBind} from "./src/bind";
{
"name": "d3-interpolate",
"version": "0.3.0",
"version": "0.4.0",
"description": "Interpolate numbers, colors, strings, arrays, objects, whatever!",

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

"dependencies": {
"d3-color": "~0.3.2"
"d3-color": "~0.3.3"
},

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

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

```js
var i = d3_interpolate.number(10, 20);
var i = d3.interpolateNumber(10, 20);
i(0.0); // 10

@@ -19,9 +19,9 @@ i(0.2); // 12

```js
d3_interpolate.lab("steelblue", "brown")(0.5); // "#8e5c6d"
d3.interpolateLab("steelblue", "brown")(0.5); // "#8e5c6d"
```
Here’s a more elaborate example demonstrating type inference used by [value](#value):
Here’s a more elaborate example demonstrating type inference used by [interpolate](#interpolate):
```js
var i = d3_interpolate.value({colors: ["red", "blue"]}, {colors: ["white", "black"]});
var i = d3.interpolate({colors: ["red", "blue"]}, {colors: ["white", "black"]});
i(0.0); // {colors: ["#ff0000", "#0000ff"]}

@@ -40,3 +40,3 @@ i(0.5); // {colors: ["#ff8080", "#000080"]}

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

@@ -48,15 +48,15 @@

<a name="value" href="#value">#</a> d3_interpolate.<b>value</b>(<i>a</i>, <i>b</i>)
<a name="interpolate" href="#interpolate">#</a> d3.<b>interpolate</b>(<i>a</i>, <i>b</i>)
Returns an interpolator between the two arbitrary values *a* and *b*. The interpolator implementation is based on the type of the end value *b*, using the following algorithm:
1. If *b* is a [color](https://github.com/d3/d3-color#color), [rgb](#rgb) is used.
2. If *b* is a string, [string](#string) is used.
3. If *b* is an array, [array](#array) is used.
4. If *b* is an object and not coercible to a number, [object](#object) is used.
5. Otherwise, [number](#number) is used.
1. If *b* is a [color](https://github.com/d3/d3-color#color), [interpolateRgb](#interpolateRgb) is used.
2. If *b* is a string, [interpolateString](#interpolateString) is used.
3. If *b* is an array, [interpolateArray](#interpolateArray) is used.
4. If *b* is an object and not coercible to a number, [interpolateObject](#interpolateObject) is used.
5. Otherwise, [interpolateNumber](#interpolateNumber) is used.
Based on the chosen interpolator, *a* is coerced to a suitable corresponding type. The behavior of this method may be augmented to support additional types by pushing custom interpolator factories onto the [values](#values) array.
Based on the chosen interpolator, *a* is coerced to a suitable corresponding type. The behavior of this method may be augmented to support additional types by pushing custom interpolator factories onto the [interpolators](#interpolators) array.
<a name="number" href="#number">#</a> d3_interpolate.<b>number</b>(<i>a</i>, <i>b</i>)
<a name="interpolateNumber" href="#interpolateNumber">#</a> d3.<b>interpolateNumber</b>(<i>a</i>, <i>b</i>)

@@ -73,17 +73,38 @@ Returns an interpolator between the two numbers *a* and *b*. The returned interpolator is equivalent to:

<a name="round" href="#round">#</a> d3_interpolate.<b>round</b>(<i>a</i>, <i>b</i>)
<a name="interpolators" href="#interpolators">#</a> d3.<b>interpolators</b>
Returns an interpolator between the two numbers *a* and *b*; the interpolator is similar to [number](#number), except it will round the resulting value to the nearest integer.
The array of built-in interpolator factories, as used by [interpolate](#interpolate). Additional interpolator factories may be pushed onto the end of this array. Each factory should return an interpolator if it supports interpolating the two specified input values; otherwise, the factory should return a falsey value and other interpolators will be tried.
<a name="string" href="#string">#</a> d3_interpolate.<b>string</b>(<i>a</i>, <i>b</i>)
For example, to register a custom interpolator that formats dollars and cents, you might say:
```js
d3.interpolators.push(function(a, b) {
var re = /^\$([0-9,.]+)$/, ma, mb, f = d3.format(",.02f");
if ((ma = re.exec(a)) && (mb = re.exec(b))) {
a = parseFloat(ma[1]);
b = parseFloat(mb[1]) - a;
return function(t) {
return "$" + f(a + b * t);
};
}
});
```
Subsequently, `d3.interpolate("$20", "$10")(1/3)` returns `$16.67`.
<a name="interpolateRound" href="#interpolateRound">#</a> d3.<b>interpolateRound</b>(<i>a</i>, <i>b</i>)
Returns an interpolator between the two numbers *a* and *b*; the interpolator is similar to [interpolateNumber](#interpolateNumber), except it will round the resulting value to the nearest integer.
<a name="interpolateString" href="#interpolateString">#</a> d3.<b>interpolateString</b>(<i>a</i>, <i>b</i>)
Returns an interpolator between the two strings *a* and *b*. The string interpolator finds numbers embedded in *a* and *b*, where each number is of the form understood by JavaScript. A few examples of numbers that will be detected within a string: `-1`, `42`, `3.14159`, and `6.0221413e+23`.
For each number embedded in *b*, the interpolator will attempt to find a corresponding number in *a*. If a corresponding number is found, a numeric interpolator is created using [number](#number). The remaining parts of the string *b* are used as a template: the static parts of the string *b* remain constant for the interpolation, with the interpolated numeric values embedded in the template.
For each number embedded in *b*, the interpolator will attempt to find a corresponding number in *a*. If a corresponding number is found, a numeric interpolator is created using [interpolateNumber](#interpolateNumber). The remaining parts of the string *b* are used as a template: the static parts of the string *b* remain constant for the interpolation, with the interpolated numeric values embedded in the template.
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"`.
<a name="array" href="#array">#</a> d3_interpolate.<b>array</b>(<i>a</i>, <i>b</i>)
<a name="interpolateArray" href="#interpolateArray">#</a> d3.<b>interpolateArray</b>(<i>a</i>, <i>b</i>)
Returns an interpolator between the two arrays *a* and *b*. Internally, an array template is created that is the same length in *b*. For each element in *b*, if there exists a corresponding element in *a*, a generic interpolator is created for the two elements using [value](#value). If there is no such element, the static value from *b* is used in the template. Then, for the given parameter *t*, the template’s embedded interpolators are evaluated. The updated array template is then returned.
Returns an interpolator between the two arrays *a* and *b*. Internally, an array template is created that is the same length in *b*. For each element in *b*, if there exists a corresponding element in *a*, a generic interpolator is created for the two elements using [interpolate](#interpolate). If there is no such element, the static value from *b* is used in the template. Then, for the given parameter *t*, the template’s embedded interpolators are evaluated. The updated array template is then returned.

@@ -94,5 +115,5 @@ 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]`.

<a name="object" href="#object">#</a> d3_interpolate.<b>object</b>(<i>a</i>, <i>b</i>)
<a name="interpolateObject" href="#interpolateObject">#</a> d3.<b>interpolateObject</b>(<i>a</i>, <i>b</i>)
Returns an interpolator between the two objects *a* and *b*. Internally, an object template is created that has the same properties as *b*. For each property in *b*, if there exists a corresponding property in *a*, a generic interpolator is created for the two elements using [value](#value). If there is no such property, the static value from *b* is used in the template. Then, for the given parameter *t*, the template's embedded interpolators are evaluated and the updated object template is then returned.
Returns an interpolator between the two objects *a* and *b*. Internally, an object template is created that has the same properties as *b*. For each property in *b*, if there exists a corresponding property in *a*, a generic interpolator is created for the two elements using [interpolate](#interpolate). If there is no such property, the static value from *b* is used in the template. Then, for the given parameter *t*, the template's embedded interpolators are evaluated and the updated object template is then returned.

@@ -105,7 +126,7 @@ 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}`.

<a name="transform" href="#transform">#</a> d3_interpolate.<b>transform</b>(<i>a</i>, <i>b</i>)
<a name="interpolateTransform" href="#interpolateTransform">#</a> d3.<b>interpolateTransform</b>(<i>a</i>, <i>b</i>)
Returns an interpolator between the two 2D affine transforms represented by *a* and *b*. Each transform is decomposed to a standard representation of translate, rotate, *x*-skew and scale; these component transformations are then interpolated. This behavior is standardized by CSS: see [matrix decomposition for animation](http://www.w3.org/TR/css3-2d-transforms/#matrix-decomposition).
<a name="zoom" href="#zoom">#</a> d3_interpolate.<b>zoom</b>(<i>a</i>, <i>b</i>)
<a name="interpolateZoom" href="#interpolateZoom">#</a> d3.<b>interpolateZoom</b>(<i>a</i>, <i>b</i>)

@@ -116,80 +137,59 @@ 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.

<a name="values" href="#values">#</a> d3_interpolate.<b>values</b>
<a name="interpolateRgb" href="#interpolateRgb">#</a> d3.<b>interpolateRgb</b>(<i>a</i>, <i>b</i>)
The array of built-in interpolator factories, as used by [value](#value). Additional interpolator factories may be pushed onto the end of this array. Each factory should return an interpolator if it supports interpolating the two specified input values; otherwise, the factory should return a falsey value and other interpolators will be tried.
<img src="https://raw.githubusercontent.com/d3/d3-interpolate/master/img/rgb.png" width="100%" height="40" alt="rgb">
For example, to register a custom interpolator that formats dollars and cents, you might say:
```js
d3_interpolate.values.push(function(a, b) {
var re = /^\$([0-9,.]+)$/, ma, mb, f = d3.format(",.02f");
if ((ma = re.exec(a)) && (mb = re.exec(b))) {
a = parseFloat(ma[1]);
b = parseFloat(mb[1]) - a;
return function(t) {
return "$" + f(a + b * t);
};
}
});
```
Subsequently, `d3_interpolate.value("$20", "$10")(1/3)` returns `$16.67`.
<a name="rgb" href="#rgb">#</a> d3_interpolate.<b>rgb</b>(<i>a</i>, <i>b</i>)
<img src="https://raw.githubusercontent.com/d3/d3-interpolate/master/img/rgb.png" width="100%" height="80" alt="rgb">
Returns an RGB color space interpolator between the two colors *a* and *b*. 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.
<a name="hsl" href="#hsl">#</a> d3_interpolate.<b>hsl</b>(<i>a</i>, <i>b</i>)
<a name="interpolateHsl" href="#interpolateHsl">#</a> d3.<b>interpolateHsl</b>(<i>a</i>, <i>b</i>)
<img src="https://raw.githubusercontent.com/d3/d3-interpolate/master/img/hsl.png" width="100%" height="80" alt="hsl">
<img src="https://raw.githubusercontent.com/d3/d3-interpolate/master/img/hsl.png" width="100%" height="40" alt="hsl">
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.
<a name="hslLong" href="#hslLong">#</a> d3_interpolate.<b>hslLong</b>(<i>a</i>, <i>b</i>)
<a name="interpolateHslLong" href="#interpolateHslLong">#</a> d3.<b>interpolateHslLong</b>(<i>a</i>, <i>b</i>)
<img src="https://raw.githubusercontent.com/d3/d3-interpolate/master/img/hslLong.png" width="100%" height="80" alt="hslLong">
<img src="https://raw.githubusercontent.com/d3/d3-interpolate/master/img/hslLong.png" width="100%" height="40" alt="hslLong">
Like [hsl](#hsl), but does not use the shortest path between hues.
Like [interpolateHsl](#interpolateHsl), but does not use the shortest path between hues.
<a name="lab" href="#lab">#</a> d3_interpolate.<b>lab</b>(<i>a</i>, <i>b</i>)
<a name="interpolateLab" href="#interpolateLab">#</a> d3.<b>interpolateLab</b>(<i>a</i>, <i>b</i>)
<img src="https://raw.githubusercontent.com/d3/d3-interpolate/master/img/lab.png" width="100%" height="80" alt="lab">
<img src="https://raw.githubusercontent.com/d3/d3-interpolate/master/img/lab.png" width="100%" height="40" alt="lab">
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.
<a name="hcl" href="#hcl">#</a> d3_interpolate.<b>hcl</b>(<i>a</i>, <i>b</i>)
<a name="interpolateHcl" href="#interpolateHcl">#</a> d3.<b>interpolateHcl</b>(<i>a</i>, <i>b</i>)
<img src="https://raw.githubusercontent.com/d3/d3-interpolate/master/img/hcl.png" width="100%" height="80" alt="hcl">
<img src="https://raw.githubusercontent.com/d3/d3-interpolate/master/img/hcl.png" width="100%" height="40" alt="hcl">
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.
<a name="hclLong" href="#hclLong">#</a> d3_interpolate.<b>hclLong</b>(<i>a</i>, <i>b</i>)
<a name="interpolateHclLong" href="#interpolateHclLong">#</a> d3.<b>interpolateHclLong</b>(<i>a</i>, <i>b</i>)
<img src="https://raw.githubusercontent.com/d3/d3-interpolate/master/img/hclLong.png" width="100%" height="80" alt="hclLong">
<img src="https://raw.githubusercontent.com/d3/d3-interpolate/master/img/hclLong.png" width="100%" height="40" alt="hclLong">
Like [hcl](#hcl), but does not use the shortest path between hues.
Like [interpolateHcl](#interpolateHcl), but does not use the shortest path between hues.
<a name="cubehelix" href="#cubehelix">#</a> d3_interpolate.<b>cubehelix</b>(<i>a</i>, <i>b</i>[, <i>gamma</i>])
<a name="interpolateCubehelix" href="#interpolateCubehelix">#</a> d3.<b>interpolateCubehelix</b>(<i>a</i>, <i>b</i>[, <i>gamma</i>])
<img src="https://raw.githubusercontent.com/d3/d3-interpolate/master/img/cubehelix.png" width="100%" height="80" alt="cubehelix">
<img src="https://raw.githubusercontent.com/d3/d3-interpolate/master/img/cubehelix.png" width="100%" height="40" alt="cubehelix">
Or, with a 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="80" alt="cubehelixGamma">
<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 the specified *gamma*. If *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.
<a name="cubehelixLong" href="#cubehelixLong">#</a> d3_interpolate.<b>cubehelixLong</b>(<i>a</i>, <i>b</i>[, <i>gamma</i>])
<a name="interpolateCubehelixLong" href="#interpolateCubehelixLong">#</a> d3.<b>interpolateCubehelixLong</b>(<i>a</i>, <i>b</i>[, <i>gamma</i>])
<img src="https://raw.githubusercontent.com/d3/d3-interpolate/master/img/cubehelixLong.png" width="100%" height="80" alt="cubehelixLong">
<img src="https://raw.githubusercontent.com/d3/d3-interpolate/master/img/cubehelixLong.png" width="100%" height="40" alt="cubehelixLong">
Or, with a gamma of 3.0 to emphasize high-intensity values:
<img src="https://raw.githubusercontent.com/d3/d3-interpolate/master/img/cubehelixGammaLong.png" width="100%" height="80" alt="cubehelixGammaLong">
<img src="https://raw.githubusercontent.com/d3/d3-interpolate/master/img/cubehelixGammaLong.png" width="100%" height="40" alt="cubehelixGammaLong">
Like [cubehelix](#cubehelix), but does not use the shortest path between hues.
Like [interpolateCubehelix](#interpolateCubehelix), but does not use the shortest path between hues.
<a name="bind" href="#bind">#</a> d3_interpolate.<b>bind</b>(<i>type</i>[, <i>parameters…</i>])
<a name="interpolateBind" href="#interpolateBind">#</a> d3.<b>interpolateBind</b>(<i>type</i>[, <i>parameters…</i>])

@@ -199,4 +199,4 @@ A convenience function for binding zero or more *parameters* to the specified interpolation function *type*. If no *parameters* are specified, this function simply returns *type*. The returned function takes two arguments *a* and *b* and passes any optional *parameters* to the underlying function *type*. For example, the following statements are equivalent:

```js
d3_interpolate.bind(d3_interpolate.cubehelix, 3)("purple", "orange");
d3_interpolate.cubehelix("purple", "orange", 3);
d3.interpolateBind(d3.interpolateCubehelix, 3)("purple", "orange");
d3.interpolateCubehelix("purple", "orange", 3);
```

@@ -7,5 +7,5 @@ import value from "./value";

c = [],
na = a.length,
nb = b.length,
n0 = Math.min(a.length, b.length),
na = a ? a.length : 0,
nb = b ? b.length : 0,
n0 = Math.min(na, nb),
i;

@@ -12,0 +12,0 @@

@@ -8,2 +8,5 @@ import value from "./value";

if (a === null || typeof a !== "object") a = {};
if (b === null || typeof b !== "object") b = {};
for (k in a) {

@@ -10,0 +13,0 @@ if (k in b) {

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