Encyclopedia > QuickDraw

  Article Content


QuickDraw is the 2D graphics[?] library which is a core part of the classic Macintosh OS. It was written by Andy Herzfield[?] and Bill Atkinson. QuickDraw still exists as part of the libraries of Mac OS X, but has been largely superceded by the more modern Quartz graphics system.

Table of contents

Principles of QuickDraw

QuickDraw, being grounded in the LisaDraw development work of the early 1980s, uses a data structures + algorithms programming paradigm (as opposed to the more modern object-oriented paradigm). This fitted well with the Pascal based interfaces and development environments of the early Apple systems.

Quickdraw defines a key data structure, the graphics port, or Grafport. This is a logical drawing area where graphics can be drawn. The most obvious on-screen "object" corresponding to a grafport is a window.

The Grafport defines a coordinate system. In QuickDraw, this has a resolution of 16 bits, giving 65,535 unique vertical and horizontal locations. These are numbered from -32,767 on the extreme left (or top), to +32,768 on the extreme right (or bottom). A window is usually set up so that its top, left corner is located at 0,0 in the associated grafport.

QuickDraw coordinates refer to the infinitely thin lines between pixel locations. An actual pixel is drawn in the space to the immediate right and below the coordinate. This is supposed to eliminate the so-called "end-point paranoia" and associated off-by-one errors.

On the Macintosh, pixels are square and a grafport has a default resolution of 72 pixels to the inch, chosen to match conventions established by the printing industry of having 72 points to the inch.

QuickDraw also contains a number of scaling and mapping functions.

Graphics Primitives

Everything you see on a classic Mac OS screen is drawn by QuickDraw, but the library itself is quite low level. The primitive objects it can draw are:

  • Lines
  • Rectangles
  • Round-cornered rectangles
  • Ovals (including circles)
  • Arcs
  • Regions (arbitrary sets of pixels)
  • Bitmaps
  • Text

Each of these objects may be drawn using a "pen", which can have any size, pattern or colour. Shapes may be drawn filled or framed, using any pattern or colour. A filled Arc forms a wedge. Text may be drawn in any installed font, in a variety of stylistic variations, and at any size. Text is scaled in a variety of ways depending on how it is stored - TrueType fonts will scale smoothly to any size, whereas bitmapped fonts do not usually scale well.

The set of attributes of the pen and text drawing are associated with the grafport.

Regions are a key data structure in Quickdraw. They define an arbitrary set of pixels, rather like a bitmap, but in a compressed form which can be very rapidly manipulated in complex ways. Regions can be combined (union), subtracted (difference), and XORed to form other regions. Regions can be used within a grafport for clipping, or drawn filled or framed like any other shape. A series of framed shapes and connected lines may be combined into a region. A region need not consist of a contiguous set of pixels - disconnected regions are possible and common.

Higher level operations

Any series of graphics calls to Quickdraw can be recorded in a structure called a Picture. This can then be saved in memory and "played back" at any time, reproducing the graphics sequence. At playback time the picture may be placed at new coordinates or scaled. A picture can be saved to disk in which form it defines the Apple PICT format.

An entire BitMap (or PixMap, when referring to colour images) may be copied from one grafport to another, with scaling and clipping. Known as blitting, this operation is the basis for most animation and sprite-like effects on the Mac.

Quickdraw provides a similar blitting function which is designed to implement scrolling within a grafport - the image in the port can be shifted to a new location without scaling (but with clipping if desired).

Each graphics primitive operation is vectored through a series of pointers stored in the grafport. This permits individual operations to be overridden or replaced by custom functions (in this respect Quickdraw does offer some small degree of object-oriented design). This ability permits printer drivers to intercept graphics commands and translate them to suitable printer operations. In this way, Quickdraw can be rendered using PostScript, a fact that enabled the Macintosh to practically invent desktop publishing.


QuickDraw started life as LisaDraw, as part of the Apple Lisa development. For the Macintosh it was initially simplified, but then later extended. Originally, QuickDraw grafports only supported a bit depth of 1, that is one bit per pixel, or black and white. This suited the built-in screen of the early Macintosh, with its fixed size of 512 x 342 pixels.

In 1986, the Macintosh II was developed and launched, which was designed as a more conventional three-box design - CPU, monitor and keyboard all separate. Because the monitor was separate, and larger than the original Mac, the video architecture had to necessarily change. In addition, the Mac II had colour. Apple also decided at this time to support a seamless desktop spanning multiple monitors, an industry first. Thus Color QuickDraw, a significant extension of the original QuickDraw, was created. The original architecture lacked much provision for expandability, but using a series of inspired hacks, the Apple developers managed to make the addition of colour and the new video architecture virtually seamless to both developers and end users.

Colour Quickdraw introduced new data structures - GDevices to represent each attached video card/monitor, and a new colour GrafPort (CGrafPort) structure to handle colour, as well as PixMaps for multiple bits-per-pixel images. In addition, a Palette manager was added which managed the arbitration of colours on indexed video devices. Most graphics primitives operations remained either unchanged (but would operate in colour), or else new colour versions of the black and white APIs were added.

Initially, colour QuickDraw was only capable of operating with 8-bit (256 colour) video cards, which were all that was available at the time. Soon after however, 24-bit video cards appeared (so-called true colour), and QuickDraw was updated again to support up to 32 bits per pixel of colour data. The architecture always allowed for this however, so no new APIs were necessary.

Apart from back-end changes to optimise for new processor architectures (Power PC), QuickDraw remained largely unchanged throughout the rest of the life of the classic Mac OS.

All Wikipedia text is available under the terms of the GNU Free Documentation License

  Search Encyclopedia

Search over one million articles, find something about almost anything!
  Featured Article
North Lindenhurst, New York

... married couples living together, 12.2% have a female householder with no husband present, and 21.9% are non-families. 17.7% of all households are made up of individuals ...

This page was created in 39.6 ms