You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
9 lines
310 B
9 lines
310 B
1 year ago
|
export default function piecewise(interpolate, values) {
|
||
|
var i = 0, n = values.length - 1, v = values[0], I = new Array(n < 0 ? 0 : n);
|
||
|
while (i < n) I[i] = interpolate(v, v = values[++i]);
|
||
|
return function(t) {
|
||
|
var i = Math.max(0, Math.min(n - 1, Math.floor(t *= n)));
|
||
|
return I[i](t - i);
|
||
|
};
|
||
|
}
|