function clamp(value, lower, upper) {
    return value < lower ? lower : value > upper ? upper : value;
}
Helper function to clamp a value to a given range.

@method
@private
@param {Number} value The value to clamp.
@param {Number} lower The lower end.
@param {Number} upper The upper end.
@return {Number} The clamped value.