clamp

taichi_glsl.scalar.clamp(x, xmin=0, xmax=1)

Constrain a value to lie between two further values. clamp returns the value of x constrained to the range xmin to xmax.

Parameters
  • x – Specify the value to constrain.

  • xmin – Specify the lower end of the range into which to constrain x.

  • xmax – Specify the upper end of the range into which to constrain x.

Returns

The returned value is computed as min(xmax, max(xmin, x)).