This article needs additional citations for verification. (December 2009) (Learn how and when to remove this template message)
In computer graphics, clamping is the process of limiting a position to an area. Unlike wrapping, clamping merely moves the point to the nearest available value.
To put clamping into perspective, pseudocode for clamping is as follows:
function clamp(x, min, max): if (x < min) then x = min else if (x > max) then x = max return x
|Y = clamp(X, 1, 5)|
|X < 1||1|
|X > 5||5|
One of the many uses of clamping in computer graphics is the placing of a detail inside a polygon—for example, a bullet hole on a wall. It can also be used with wrapping to create a variety of effects.
- "OpenGL 4 Reference Pages". www.khronos.org. Retrieved 2018-10-31.