Wrapping (graphics)
In-game article clicks load inline without leaving the challenge.
In computer graphics, wrapping is the process of limiting a position to an area. A good example of wrapping is wallpaper, a single pattern repeated indefinitely over a wall. Wrapping is used in 3D computer graphics to repeat a texture over a polygon, eliminating the need for large textures or multiple polygons.
To wrap a position x to an area of width w, calculate the value x ′ = x mod w {\displaystyle x'=x{\text{ mod }}w}.
Implementation
For computational purposes the wrapped value x' of x can be expressed as
x ′ = x − ⌊ ( x − x min ) / ( x max − x min ) ⌋ ⋅ ( x max − x min ) {\displaystyle x'=x-\lfloor (x-x_{\text{min}})/(x_{\text{max}}-x_{\text{min}})\rfloor \cdot (x_{\text{max}}-x_{\text{min}})}
where x max {\displaystyle x_{\text{max}}} is the highest value in the range, and x min {\displaystyle x_{\text{min}}} is the lowest value in the range.
Pseudocode for wrapping of a value to a range other than 0–1 is
Pseudocode for wrapping of a value to a range of 0–1 is
Pseudocode for wrapping of a value to a range of 0–1 without branching is,