UNPKG

697 BJavaScriptView Raw
1import constant from "./constant";
2
3function linear(a, d) {
4 return function(t) {
5 return a + t * d;
6 };
7}
8
9function exponential(a, b, y) {
10 return a = Math.pow(a, y), b = Math.pow(b, y) - a, y = 1 / y, function(t) {
11 return Math.pow(a + t * b, y);
12 };
13}
14
15export function hue(a, b) {
16 var d = b - a;
17 return d ? linear(a, d > 180 || d < -180 ? d - 360 * Math.round(d / 360) : d) : constant(isNaN(a) ? b : a);
18}
19
20export function gamma(y) {
21 return (y = +y) === 1 ? nogamma : function(a, b) {
22 return b - a ? exponential(a, b, y) : constant(isNaN(a) ? b : a);
23 };
24}
25
26export default function nogamma(a, b) {
27 var d = b - a;
28 return d ? linear(a, d) : constant(isNaN(a) ? b : a);
29}