Wrapping (graphics)
   HOME

TheInfoList



OR:

In computer graphics, wrapping is the process of limiting a position to an area. A good example of wrapping is
wallpaper Wallpaper is a material used in interior decoration to decorate the interior walls of domestic and public buildings. It is usually sold in rolls and is applied onto a wall using wallpaper paste. Wallpapers can come plain as "lining paper" (so ...
, a single pattern repeated indefinitely over a
wall A wall is a structure and a surface that defines an area; carries a load; provides security, shelter, or soundproofing; or, is decorative. There are many kinds of walls, including: * Walls in buildings that form a fundamental part of the sup ...
. Wrapping is used in
3D computer graphics 3D computer graphics, or “3D graphics,” sometimes called CGI, 3D-CGI or three-dimensional computer graphics are graphics that use a three-dimensional representation of geometric data (often Cartesian) that is stored in the computer for t ...
to repeat a
texture Texture may refer to: Science and technology * Surface texture, the texture means smoothness, roughness, or bumpiness of the surface of an object * Texture (roads), road surface characteristics with waves shorter than road roughness * Texture ...
over a
polygon In geometry, a polygon () is a plane figure that is described by a finite number of straight line segments connected to form a closed ''polygonal chain'' (or ''polygonal circuit''). The bounded plane region, the bounding circuit, or the two to ...
, eliminating the need for large textures or multiple polygons. To wrap a position ''x'' to an area of width ''w'', calculate the value x' \equiv x \pmod.


Implementation

For computational purposes the wrapped value ''x of ''x'' can be expressed as :x' = x - \lfloor (x - x_) / (x_ - x_) \rfloor \cdot (x_ - x_) where x_ is the highest value in the range, and x_ is the lowest value in the range. Pseudocode for wrapping of a value to a range other than 0–1 is function wrap(X, Min, Max: Real): Real; X := X - Int((X - Min) / (Max - Min)) * (Max - Min); if X < 0 then // This corrects the problem caused by using Int instead of Floor X := X + Max - Min; return X; Pseudocode for wrapping of a value to a range of 0–1 is function wrap(X: Real): Real; X := X - Int(X); if X < 0 then X := X + 1; return X; Pseudocode for wrapping of a value to a range of 0–1 without branching is, function wrap(X: Real): Real; return ((X mod 1.0) + 1.0) mod 1.0;


See also text wrapping

* Clamping {{DEFAULTSORT:Wrapping (Graphics) Computer graphics algorithms