Contents
Clamping (graphics)
In computer science, clamping, or clipping is the process of limiting a value to a range between a minimum and a maximum value. Unlike wrapping, clamping merely moves the point to the nearest available value. In Python, clamping can be defined as follows: This is equivalent to max(minimum, min(x, maximum)) for languages that support the functions min and max.
Uses
Several programming languages and libraries provide functions for fast and vectorized clamping. In Python, the pandas library offers the and methods. The NumPy library offers the function. In the Wolfram Language, it is implemented as Clip[x, {minimum, maximum}]. In OpenGL, the function takes four values which are then 'clamped' to the range [0,1]. 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.
This article is derived from Wikipedia and licensed under CC BY-SA 4.0. View the original article.
Wikipedia® is a registered trademark of the
Wikimedia Foundation, Inc.
Bliptext is not
affiliated with or endorsed by Wikipedia or the
Wikimedia Foundation.