MathHelper.Clamp Method

Restricts a value to be within a specified range.

Namespace: Microsoft.Xna.Framework
Assembly: Microsoft.Xna.Framework (in microsoft.xna.framework.dll)

public static float Clamp (
         float value,
         float min,
         float max
)

Parameters

value
The value to clamp.
min
The minimum value. If value is less than min, min will be returned.
max
The maximum value. If value is greater than max, max will be returned.

Return Value

The clamped value.
  • If value > max, max will be returned.
  • If value < min, min will be returned.
  • If minvaluemax, value will be returned.

Xbox 360, Windows XP SP2, Windows Vista, Zune

Community Additions

ADD
Show: