Skip to main content

blockly > utils > math > clamp

utils.math.clamp() function

Clamp the provided number between the lower bound and the upper bound.

Signature:

export declare function clamp(lowerBound: number, number: number, upperBound: number): number;

Parameters

Parameter

Type

Description

lowerBound

number

The desired lower bound.

number

number

The number to clamp.

upperBound

number

The desired upper bound.

Returns:

number

The clamped number.