Clamping (graphics)
Get Clamping Graphics essential facts below. View Videos or join the Clamping Graphics discussion. Add Clamping Graphics to your PopFlock.com topic list for future reference or share this resource on social media.
Clamping Graphics

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

Uses

In general, clamping is used to restrict a value to a given range. For example, in OpenGL the glClearColor function takes four GLfloat values which are then 'clamped' to the range .[1]

Y = clamp(X, 1, 5)
X Y
X < 1 1
1 1
1.5 1.5
2 2
3 3
4 4
5 5
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.

References

  1. ^ "OpenGL 4 Reference Pages". www.khronos.org. Retrieved .



  This article uses material from the Wikipedia page available here. It is released under the Creative Commons Attribution-Share-Alike License 3.0.

Clamping_(graphics)
 



 



 
Music Scenes