Restrict x to the range low, high.
low, high
static num clamp(num x, num low, num high) => x < low ? low : (x > high ? high : x);