 | 2D computer graphics: Encyclopedia II - 2D computer graphics - 2D graphics techniques
2D computer graphics - 2D graphics techniques
2D graphics models may combine geometric models (also called vector graphics), digital images (also called raster graphics), text to be typeset (defined by content, font style and size, color, position, and orientation), 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.
2D computer graphics - Direct painting
A convenient way to create a complex image is to start with a blank canvas—a raster map (array of pixels — also known as a bitmap (or pixmap if it is in colour)) filled with some uniform background color—and then "draw", "paint" or "paste" simple patches of color onto it, in an appropriate order. In particular, the canvas may be the frame buffer for a computer display.
Some programs will set the pixel colors directly, but most will rely on some 2D graphics library and/or the machine's graphics card, which usually implement the following operations:
- paste a given image at a specified offset onto the canvas;
- write a string of characters with a specified font, at a given position and angle;
- paint a simple geometric shape, such as a triangle defined by three corners, or a circle with given center and radius;
- draw a line segment, arc of circle, or simple curve with a virtual pen of given width.
2D computer graphics - Extended color models
Text, shapes and lines are rendered with a client-specified color. Many libraries and cards provide color gradients, which are handy for the generation of smoothly-varying backgrounds, shadow effects, etc.. (See also Gouraud shading). The pixel colors can also be taken from a texture, e.g. a digital image (thus emulating rub-on screentones and the fabled "checker paint" which used to be available only in cartoons).
Painting a pixel with a given color usually replaces its previous color. However, many systems support painting with transparent and translucent colors, which only modify the previous pixel values.
The two colors may also be combined in fancier ways, e.g. by computing their bitwise exclusive or. This technique is known as inverting color or color inversion, and is often used in graphical user interfaces for highlighting, rubber-band drawing, and other volatile painting—since re-painting the same shapes with the same color will restore the original pixel values.
2D computer graphics - 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 drafting 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 graphics editors. Layered models also allow better anti-aliasing of complex drawings and provide a sound model for certain techniques such as mitered joints and the even-odd rule.
Layered models are also used to allow the user to suppress unwanted information when viewing or printing a document, e.g. roads and/or railways from a map, certain process layers from an integrated circuit diagram, or hand annotations from a business letter.
In a layer-based model, the target image is produced by "painting" or "pasting" each layer, in order of decreasing depth, on the virtual canvas. Conceptually, each layer is first rendered on its own, yielding 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.
See also Portable Document Format#Layers.
Other related archives1950s, 1984, 2D geometric models, 2D graphic files, 3D computer graphics, 8-bit, ANTIC, Adobe Illustrator, Apple, Atari, Bit blit, Blitter, CTIA, Commodore, Computer graphics, Computer painting, CorelDraw, Editing digital images, GIMP, GPU, GTIA, Gouraud shading, Graphics, Image editors, Image scaling, Logo programming language, MOS Technology, Mac OS, MacDraw, MacPaint, Macintosh, Macromedia Flash, Microsoft Windows, Paint Shop Pro, Photoshop, Portable Document Format#Layers, PostScript, Root page, SVG, TIA, Transparency in graphic files, Turtle graphics, VIC, VIC-II, Windowing system, X Window System, advertising, aliasing, anti-aliasing, background color, bitmap, bitwise, blitting, business, cartography, cartoons, characters, chess, circle, co-processor, computer, computer display, computer games, computer science, desktop publishing, digital image, digital images, digital photography, drawing, engineering, equations, exclusive or, font, frame buffer, functions, geometric models, geometric shape, graphical user interfaces, graphics card, graphics chips, graphics editors, graphics files, graphics tablet, home computers, image, input devices, integrated circuit, line segment, line segments, mahjongg, map, mouse, object-oriented programming, output devices, pen, photography, pixel, pixels, pixmap, polylines, printing, raster graphics, raster map, raster-based devices, reflection, refraction, rendered, rendering, resolution, resolutions, rotation, scaling, screentones, shadows, signal processing, solitaire, sprite, technical drawing, text, texture, translation, translucent, transparent, triangle, typeset, typography, vector graphics, vector graphics devices, video, video game consoles, window manager, xfig
 Adapted from the Wikipedia article "2D graphics techniques", under the G.N U Free Docmentation License. Please also see http://en.wikipedia.org/wiki |