Jump to content

2D computer graphics

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Jorge Stolfi (talk | contribs) at 23:32, 7 March 2004 (added 2D geometric transformations). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.


2D computer graphics refers to the generation of digital images with the aid of digital computers -- mostly from two-dimensional models (such as 2D geometric models, text, and digital images) and by techniques specific to them. The word may stand for the branch of computer science that covers such techniques, or for the models themselves.

2D computer graphics are mostly used in applications that were originally developed upon traditional printing and drawing technologies, such as digital typography, cartography, technical drafting, package design, etc.. In those applications, the two-dimensional image is not just a representation of a real-world object, but an independent artifact with added semantic value; two-dimensional models are therefore preferred, because they give more direct control of the image than 3D computer graphics (whose "user model" is more akin to photography than to typography).

In many domains, such as desktop publishing, engineering, and business, a description of a document based on 2D computer graphics techniques can be much smaller than the correspoding digital image -- often by a factor of 1/1000 or more. This representation ia also more flexible since it can be rendered at different resolutions to suit different output devices. For these reasons, documents and illustrations are often stored or transmitted as graphic files.

2D graphics techniques

2D graphics models may combine geometric shapes (also called vector graphics), digital images (or raster graphics), text (to be rendered with specific fonts), mathematical functions and equations, and more. These components can be modified and manipulated by two-dimensional geometric transformations such as translation, rotation, scaling.

In object oriented graphics, the image is described indirectly by an object endowed with a self-rendering method -- a procedure which assigns colors to the image pixels by an arbitrary algorithm. Complex models can be built by combining simpler objects, in the paradigms of object-oriented programming.

Layers

The models used in 2D computer graphics usually do not provide for three-dimensional shapes, or three-dimensional optical phenomena such as lighting, shadows, reflection, refraction, etc.. However, they usually can model multiple layers (conceptually of ink, paper, or film; opaque, translucent, or transparent -- stacked in a specific order. The ordering is usually defined by a single number (the layer's depth, or distance from the viewer).

Layered models are sometimes called 2 1/2-D computer graphics. They make it possible to mimic traditional trafting and printing techniques based on film and paper, such as cutting and pasting; and allow the user to edit any layer without affecting the others. For these reasons, they are used in most graphical editors. Layered models also allow better anti-aliasing of complex drawings and a sound model for some popular modeling concepts such as mitered joints and the even-odd rule.

In a layer-based model, the target image is produced by "painting" or "pasting" each layer, in order of decreasing depth, on a virtual canvas -- a digital image initially colored with an uniform background color. Painting one color over another at a particular pixel results in the second color, or in a combination of the two colors if the layer includes some transparency.

Conceptually, each layer is first rendered on its own, yelding a digital image with the desired resolution; which is then painted over the canvas, pixel by pixel. Fully transparent parts of a layer need not be rendered, of course. The rendering and painting may be done in parallel, i.e. each layer pixel may be painted on the canvas as soon as it is produced by the rendering procedure.

Layers that consist of complex geometric objects (such as text or polylines) may be broken down into simpler elements (characters or line segments, respectively), which are then painted as separate layers, in some order. However, this solution may create undesirable aliasing artifacts wherever two elements overlap the same pixel.

2D Graphics Hardware

Modern computer graphics card displays almost overwhelmingly use raster techniques, dividing the screen into a rectangular grid of pixels, due to the relatively low cost of raster-based video hardware as compared with vector graphic hardware. Most graphic hardware has internal support for blitting operations and sprite drawing.

2D Graphics Software

Many graphical user interfaces (GUIs), including Mac OS, Microsoft Windows, or the X Window System, are primarily based on 2D graphical concepts. Such software provides a visual environment for interacting with the computer, and commonly includes some form of window manager to aid the user in conceptually distinguishing between different applications. The user interface within individual software applications is typically 2D in nature as well, due in part to the fact that most common input devices, such as the mouse, are constrained to two dimensions of movement.

Another common software implementation of 2D graphics takes the form of paint and drawing programs. These may also be conceptually divided into the Raster and Vector models. Raster graphics software, such as The GIMP, Photoshop, and Paint Shop Pro, customarily provides a two-dimensional drawing surface, analogous to a sheet of paper or canvas, which can be colored with lines, shapes, pasted graphics, and a wide array of other 2D visual objects. Images are manipulated and stored as a rectangular array of colored pixels.

Vector drawing programs include Adobe Illustrator and CorelDraw. Such software utilizes concepts similar to the canvas and paint, but lines, shapes, and text are manipulated and stored as mathematical objects, rather than an array of pixels.

Graphics applications may often make use of both techniques in a complementary fashion; Photoshop and The GIMP, for example, include capabilities for drawing vector-based shapes, while Illustrator and CorelDRAW permit the inclusion of raster-based graphical elements.

Most early video games used only 2D graphics.

See also: