-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
362 additions
and
417 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import constant from "./constant"; | ||
|
||
function linear(a, d) { | ||
return function(t) { | ||
return a + t * d; | ||
}; | ||
} | ||
|
||
function exponential(a, b, y) { | ||
return a = Math.pow(a, y), b = Math.pow(b, y) - a, y = 1 / y, function(t) { | ||
return Math.pow(a + t * b, y); | ||
}; | ||
} | ||
|
||
export function hue(a, b) { | ||
var d = b - a; | ||
return d ? linear(a, d > 180 || d < -180 ? d - 360 * Math.round(d / 360) : d) : constant(isNaN(a) ? b : a); | ||
} | ||
|
||
export function gamma(y) { | ||
return (y = +y) === 1 ? nogamma : function(a, b) { | ||
return b - a ? exponential(a, b, y) : constant(isNaN(a) ? b : a); | ||
}; | ||
} | ||
|
||
export default function nogamma(a, b) { | ||
var d = b - a; | ||
return d ? linear(a, d) : constant(isNaN(a) ? b : a); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export default function(x) { | ||
return function() { | ||
return x; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,24 @@ | ||
import {cubehelix as color} from "d3-color"; | ||
import deltaHue from "./deltaHue"; | ||
import {cubehelix} from "d3-color"; | ||
import interpolateColor, {hue as interpolateHue} from "./color"; | ||
|
||
export default (function gamma(y) { | ||
y = +y; | ||
|
||
function cubehelix(a, b) { | ||
a = color(a); | ||
b = color(b); | ||
var ah = a.h, | ||
as = a.s, | ||
al = a.l, | ||
bh = b.h, | ||
bs = b.s, | ||
bl = b.l || 0; | ||
if (isNaN(ah)) ah = bh; | ||
if (isNaN(as)) as = bs; | ||
if (isNaN(al)) al = bl; | ||
bh = deltaHue(bh, ah) || 0; | ||
bs = (bs - as) || 0; | ||
bl -= al; | ||
function interpolateCubehelix(start, end) { | ||
var h = interpolateHue((start = cubehelix(start)).h, (end = cubehelix(end)).h), | ||
s = interpolateColor(start.s, end.s), | ||
l = interpolateColor(start.l, end.l), | ||
opacity = interpolateColor(start.opacity, end.opacity); | ||
return function(t) { | ||
a.h = ah + bh * t; | ||
a.s = as + bs * t; | ||
a.l = al + bl * Math.pow(t, y); | ||
return a + ""; | ||
start.h = h(t); | ||
start.s = s(t); | ||
start.l = l(Math.pow(t, y)); | ||
start.opacity = opacity(t); | ||
return start + ""; | ||
}; | ||
} | ||
|
||
cubehelix.gamma = gamma; | ||
interpolateCubehelix.gamma = gamma; | ||
|
||
return cubehelix; | ||
return interpolateCubehelix; | ||
})(1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,24 @@ | ||
import {cubehelix as color} from "d3-color"; | ||
import {cubehelix} from "d3-color"; | ||
import interpolateColor from "./color"; | ||
|
||
export default (function gamma(y) { | ||
y = +y; | ||
|
||
function cubehelix(a, b) { | ||
a = color(a); | ||
b = color(b); | ||
var ah = a.h, | ||
as = a.s, | ||
al = a.l, | ||
bh = b.h, | ||
bs = b.s, | ||
bl = b.l || 0; | ||
if (isNaN(ah)) ah = bh; | ||
if (isNaN(as)) as = bs; | ||
if (isNaN(al)) al = bl; | ||
bh = (bh - ah) || 0; | ||
bs = (bs - as) || 0; | ||
bl -= al; | ||
function interpolateCubehelixLong(start, end) { | ||
var h = interpolateColor((start = cubehelix(start)).h, (end = cubehelix(end)).h), | ||
s = interpolateColor(start.s, end.s), | ||
l = interpolateColor(start.l, end.l), | ||
opacity = interpolateColor(start.opacity, end.opacity); | ||
return function(t) { | ||
a.h = ah + bh * t; | ||
a.s = as + bs * t; | ||
a.l = al + bl * Math.pow(t, y); | ||
return a + ""; | ||
start.h = h(t); | ||
start.s = s(t); | ||
start.l = l(Math.pow(t, y)); | ||
start.opacity = opacity(t); | ||
return start + ""; | ||
}; | ||
} | ||
|
||
cubehelix.gamma = gamma; | ||
interpolateCubehelixLong.gamma = gamma; | ||
|
||
return cubehelix; | ||
return interpolateCubehelixLong; | ||
})(1); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,16 @@ | ||
import {hcl} from "d3-color"; | ||
import deltaHue from "./deltaHue"; | ||
import interpolateColor, {hue as interpolateHue} from "./color"; | ||
|
||
export default function(a, b) { | ||
a = hcl(a); | ||
b = hcl(b); | ||
var ah = a.h, | ||
ac = a.c, | ||
al = a.l, | ||
bh = b.h, | ||
bc = b.c, | ||
bl = b.l || 0; | ||
if (isNaN(ah)) ah = bh; | ||
if (isNaN(ac)) ac = bc; | ||
if (isNaN(al)) al = bl; | ||
bh = deltaHue(bh, ah) || 0; | ||
bc = (bc - ac) || 0; | ||
bl -= al; | ||
export default function interpolateHcl(start, end) { | ||
var h = interpolateHue((start = hcl(start)).h, (end = hcl(end)).h), | ||
c = interpolateColor(start.c, end.c), | ||
l = interpolateColor(start.l, end.l), | ||
opacity = interpolateColor(start.opacity, end.opacity); | ||
return function(t) { | ||
a.h = ah + bh * t; | ||
a.c = ac + bc * t; | ||
a.l = al + bl * t; | ||
return a + ""; | ||
start.h = h(t); | ||
start.c = c(t); | ||
start.l = l(t); | ||
start.opacity = opacity(t); | ||
return start + ""; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,16 @@ | ||
import {hcl} from "d3-color"; | ||
import interpolateColor from "./color"; | ||
|
||
export default function(a, b) { | ||
a = hcl(a); | ||
b = hcl(b); | ||
var ah = a.h, | ||
ac = a.c, | ||
al = a.l, | ||
bh = b.h, | ||
bc = b.c, | ||
bl = b.l || 0; | ||
if (isNaN(ah)) ah = bh; | ||
if (isNaN(ac)) ac = bc; | ||
if (isNaN(al)) al = bl; | ||
bh = (bh - ah) || 0; | ||
bc = (bc - ac) || 0; | ||
bl -= al; | ||
export default function interpolateHclLong(start, end) { | ||
var h = interpolateColor((start = hcl(start)).h, (end = hcl(end)).h), | ||
c = interpolateColor(start.c, end.c), | ||
l = interpolateColor(start.l, end.l), | ||
opacity = interpolateColor(start.opacity, end.opacity); | ||
return function(t) { | ||
a.h = ah + bh * t; | ||
a.c = ac + bc * t; | ||
a.l = al + bl * t; | ||
return a + ""; | ||
start.h = h(t); | ||
start.c = c(t); | ||
start.l = l(t); | ||
start.opacity = opacity(t); | ||
return start + ""; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,16 @@ | ||
import {hsl} from "d3-color"; | ||
import deltaHue from "./deltaHue"; | ||
import interpolateColor, {hue as interpolateHue} from "./color"; | ||
|
||
export default function(a, b) { | ||
a = hsl(a); | ||
b = hsl(b); | ||
var ah = a.h, | ||
as = a.s, | ||
al = a.l, | ||
bh = b.h, | ||
bs = b.s, | ||
bl = b.l || 0; | ||
if (isNaN(ah)) ah = bh; | ||
if (isNaN(as)) as = bs; | ||
if (isNaN(al)) al = bl; | ||
bh = deltaHue(bh, ah) || 0; | ||
bs = (bs - as) || 0; | ||
bl -= al; | ||
export default function interpolateHsl(start, end) { | ||
var h = interpolateHue((start = hsl(start)).h, (end = hsl(end)).h), | ||
s = interpolateColor(start.s, end.s), | ||
l = interpolateColor(start.l, end.l), | ||
opacity = interpolateColor(start.opacity, end.opacity); | ||
return function(t) { | ||
a.h = ah + bh * t; | ||
a.s = as + bs * t; | ||
a.l = al + bl * t; | ||
return a + ""; | ||
start.h = h(t); | ||
start.s = s(t); | ||
start.l = l(t); | ||
start.opacity = opacity(t); | ||
return start + ""; | ||
}; | ||
} |
Oops, something went wrong.