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.0 to 0.5.1

img/rgbGamma.png

2

build/bundle.js

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

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

@@ -13,5 +13,11 @@ (function (global, factory) {

ab = a.b,
br = b.r - ar,
bg = b.g - ag,
bb = b.b - ab;
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) {

@@ -25,2 +31,34 @@ a.r = ar + br * t;

rgb$1.gamma = function gamma(y) {
y = +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;
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 + "";
};
}
rgb.gamma = gamma;
return rgb;
};
// TODO sparse arrays?

@@ -341,8 +379,14 @@ function array(a, b) {

b = d3Color.hsl(b);
var ah = isNaN(a.h) ? b.h : a.h,
as = isNaN(a.s) ? b.s : a.s,
var ah = a.h,
as = a.s,
al = a.l,
bh = isNaN(b.h) ? 0 : deltaHue(b.h, ah),
bs = isNaN(b.s) ? 0 : b.s - as,
bl = b.l - al;
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;
return function(t) {

@@ -359,8 +403,14 @@ a.h = ah + bh * t;

b = d3Color.hsl(b);
var ah = isNaN(a.h) ? b.h : a.h,
as = isNaN(a.s) ? b.s : a.s,
var ah = a.h,
as = a.s,
al = a.l,
bh = isNaN(b.h) ? 0 : b.h - ah,
bs = isNaN(b.s) ? 0 : b.s - as,
bl = b.l - al;
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;
return function(t) {

@@ -380,5 +430,11 @@ a.h = ah + bh * t;

ab = a.b,
bl = b.l - al,
ba = b.a - aa,
bb = b.b - ab;
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;
return function(t) {

@@ -395,8 +451,14 @@ a.l = al + bl * t;

b = d3Color.hcl(b);
var ah = isNaN(a.h) ? b.h : a.h,
ac = isNaN(a.c) ? b.c : a.c,
var ah = a.h,
ac = a.c,
al = a.l,
bh = isNaN(b.h) ? 0 : deltaHue(b.h, ah),
bc = isNaN(b.c) ? 0 : b.c - ac,
bl = b.l - al;
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;
return function(t) {

@@ -413,8 +475,14 @@ a.h = ah + bh * t;

b = d3Color.hcl(b);
var ah = isNaN(a.h) ? b.h : a.h,
ac = isNaN(a.c) ? b.c : a.c,
var ah = a.h,
ac = a.c,
al = a.l,
bh = isNaN(b.h) ? 0 : b.h - ah,
bc = isNaN(b.c) ? 0 : b.c - ac,
bl = b.l - al;
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;
return function(t) {

@@ -434,8 +502,14 @@ a.h = ah + bh * t;

b = d3Color.cubehelix(b);
var ah = isNaN(a.h) ? b.h : a.h,
as = isNaN(a.s) ? b.s : a.s,
var ah = a.h,
as = a.s,
al = a.l,
bh = isNaN(b.h) ? 0 : deltaHue(b.h, ah),
bs = isNaN(b.s) ? 0 : b.s - as,
bl = b.l - al;
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;
return function(t) {

@@ -460,8 +534,14 @@ a.h = ah + bh * t;

b = d3Color.cubehelix(b);
var ah = isNaN(a.h) ? b.h : a.h,
as = isNaN(a.s) ? b.s : a.s,
var ah = a.h,
as = a.s,
al = a.l,
bh = isNaN(b.h) ? 0 : b.h - ah,
bs = isNaN(b.s) ? 0 : b.s - as,
bl = b.l - al;
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;
return function(t) {

@@ -480,3 +560,3 @@ a.h = ah + bh * t;

var version = "0.5.0";
var version = "0.5.1";

@@ -483,0 +563,0 @@ exports.version = version;

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

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

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

@@ -134,4 +134,18 @@ # d3-interpolate

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.
Or, with a corrected [gamma](#rgb_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.
<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>)

@@ -138,0 +152,0 @@

@@ -10,8 +10,14 @@ import {cubehelix as color} from "d3-color";

b = color(b);
var ah = isNaN(a.h) ? b.h : a.h,
as = isNaN(a.s) ? b.s : a.s,
var ah = a.h,
as = a.s,
al = a.l,
bh = isNaN(b.h) ? 0 : deltaHue(b.h, ah),
bs = isNaN(b.s) ? 0 : b.s - as,
bl = b.l - al;
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;
return function(t) {

@@ -18,0 +24,0 @@ a.h = ah + bh * t;

@@ -9,8 +9,14 @@ import {cubehelix as color} from "d3-color";

b = color(b);
var ah = isNaN(a.h) ? b.h : a.h,
as = isNaN(a.s) ? b.s : a.s,
var ah = a.h,
as = a.s,
al = a.l,
bh = isNaN(b.h) ? 0 : b.h - ah,
bs = isNaN(b.s) ? 0 : b.s - as,
bl = b.l - al;
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;
return function(t) {

@@ -17,0 +23,0 @@ a.h = ah + bh * t;

@@ -7,8 +7,14 @@ import {hcl} from "d3-color";

b = hcl(b);
var ah = isNaN(a.h) ? b.h : a.h,
ac = isNaN(a.c) ? b.c : a.c,
var ah = a.h,
ac = a.c,
al = a.l,
bh = isNaN(b.h) ? 0 : deltaHue(b.h, ah),
bc = isNaN(b.c) ? 0 : b.c - ac,
bl = b.l - al;
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;
return function(t) {

@@ -15,0 +21,0 @@ a.h = ah + bh * t;

@@ -6,8 +6,14 @@ import {hcl} from "d3-color";

b = hcl(b);
var ah = isNaN(a.h) ? b.h : a.h,
ac = isNaN(a.c) ? b.c : a.c,
var ah = a.h,
ac = a.c,
al = a.l,
bh = isNaN(b.h) ? 0 : b.h - ah,
bc = isNaN(b.c) ? 0 : b.c - ac,
bl = b.l - al;
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;
return function(t) {

@@ -14,0 +20,0 @@ a.h = ah + bh * t;

@@ -7,8 +7,14 @@ import {hsl} from "d3-color";

b = hsl(b);
var ah = isNaN(a.h) ? b.h : a.h,
as = isNaN(a.s) ? b.s : a.s,
var ah = a.h,
as = a.s,
al = a.l,
bh = isNaN(b.h) ? 0 : deltaHue(b.h, ah),
bs = isNaN(b.s) ? 0 : b.s - as,
bl = b.l - al;
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;
return function(t) {

@@ -15,0 +21,0 @@ a.h = ah + bh * t;

@@ -6,8 +6,14 @@ import {hsl} from "d3-color";

b = hsl(b);
var ah = isNaN(a.h) ? b.h : a.h,
as = isNaN(a.s) ? b.s : a.s,
var ah = a.h,
as = a.s,
al = a.l,
bh = isNaN(b.h) ? 0 : b.h - ah,
bs = isNaN(b.s) ? 0 : b.s - as,
bl = b.l - al;
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;
return function(t) {

@@ -14,0 +20,0 @@ a.h = ah + bh * t;

@@ -9,5 +9,11 @@ import {lab} from "d3-color";

ab = a.b,
bl = b.l - al,
ba = b.a - aa,
bb = b.b - ab;
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;
return function(t) {

@@ -14,0 +20,0 @@ a.l = al + bl * t;

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

import {rgb} from "d3-color";
import {rgb as color} from "d3-color";
export default function(a, b) {
a = rgb(a);
b = rgb(b);
function rgb(a, b) {
a = color(a);
b = color(b);
var ar = a.r,
ag = a.g,
ab = a.b,
br = b.r - ar,
bg = b.g - ag,
bb = b.b - ab;
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) {

@@ -19,1 +25,35 @@ a.r = ar + br * t;

}
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;
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 + "";
};
}
rgb.gamma = gamma;
return rgb;
};
export default rgb;
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