blob: 7c2a39fefa0622c50defade75a01eeb60160b4cd [file] [log] [blame]
function constrain(value, low, high) {
if (value < low)
return low;
if (value > high)
return high;
return value;
}
function mapRange(value, start1, stop1, start2, stop2) {
return (value - start1) / (stop1 - start1) * (stop2 - start2) + start2;
}
function percentile(values, percentile) {
var cutoff = values.length * percentile;
return values.slice(cutoff, cutoff + 1)[0];
}