Clamping (graphics)

From Wikipedia, the free encyclopedia
Jump to: navigation, search

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:

Pseudocode (clamping):
function clamp(x, min, max):

if (x < min) then
x = min;
else if (x > max) then
x = max;

return x;

end clamp

Uses[edit]

One of the many uses of clamping in computer graphics is the placing of a detail inside a polygon—for example, a bullethole on a wall. It can also be used with wrapping to create a variety of effects.

Can also mean clamped to a certain value. For example, in OpenGL, the glClearColor takes a GLclampf value which is a gl float value 'clamped' to the range [0,1].

References[edit]