Constrains a value to not exceed a maximum and minimum value. Ported from processing.js