QuickDraw was the 2D
graphics
Graphics () are visual images or designs on some surface, such as a wall, canvas, screen, paper, or stone, to inform, illustrate, or entertain. In contemporary usage, it includes a pictorial representation of the data, as in design and manufa ...
library and associated
application programming interface
An application programming interface (API) is a connection between computers or between computer programs. It is a type of software Interface (computing), interface, offering a service to other pieces of software. A document or standard that des ...
(API) which is a core part of
classic Mac OS
Mac OS (originally System Software; retronym: Classic Mac OS) is the series of operating systems developed for the Mac (computer), Macintosh family of personal computers by Apple Computer, Inc. from 1984 to 2001, starting with System 1 and end ...
. It was initially written by
Bill Atkinson and
Andy Hertzfeld. QuickDraw still existed as part of the libraries of
Mac OS X, but had been largely superseded by the more modern
Quartz
Quartz is a hard, crystalline mineral composed of silica (silicon dioxide). The Atom, atoms are linked in a continuous framework of SiO4 silicon–oxygen Tetrahedral molecular geometry, tetrahedra, with each oxygen being shared between two tet ...
graphics system. In
Mac OS X Tiger, QuickDraw has been officially
deprecated. In
Mac OS X Leopard applications using QuickDraw cannot make use of the added 64-bit support. In
OS X Mountain Lion, QuickDraw header support was removed from the operating system. Applications using QuickDraw still ran under OS X Mountain Lion to macOS High Sierra; however, the current versions of Xcode and the macOS SDK do not contain the header files to compile such programs.
Principles of QuickDraw
QuickDraw was grounded in the
Apple Lisa's LisaGraf of the early 1980s and was designed to fit well with the
Pascal-based interfaces and development environments of the early
Apple
An apple is a round, edible fruit produced by an apple tree (''Malus'' spp.). Fruit trees of the orchard or domestic apple (''Malus domestica''), the most widely grown in the genus, are agriculture, cultivated worldwide. The tree originated ...
systems. In addition, QuickDraw was a
raster graphics system, which defines the
pixel
In digital imaging, a pixel (abbreviated px), pel, or picture element is the smallest addressable element in a Raster graphics, raster image, or the smallest addressable element in a dot matrix display device. In most digital display devices, p ...
as its basic unit of graphical information. This is in contrast to
vector graphics systems, where graphics primitives are defined in mathematical terms and rasterized as required to the display resolution. A raster system requires much less processing power however, and was the prevailing paradigm at the time that QuickDraw was developed.
QuickDraw defined a key data structure, the graphics ''port'', or GrafPort. This was a logical drawing area where graphics could be drawn. The most obvious on-screen "object" corresponding to a GrafPort was a
window, but the entire desktop view could be a GrafPort, and off-screen ports could also exist.
The GrafPort defined a
coordinate system. In QuickDraw, this had a resolution of 16
bits, giving 65,536 unique vertical and horizontal locations. These are numbered from -32,767 on the extreme left (or top), to +32,767 on the extreme right (or bottom). A window was usually set up so that the top, left corner of its content area was located at 0,0 in the associated GrafPort. A window's content area did not include the window's frame,
drop shadow or title bar (if any).
QuickDraw coordinates referred to the infinitely thin lines ''between''
pixel
In digital imaging, a pixel (abbreviated px), pel, or picture element is the smallest addressable element in a Raster graphics, raster image, or the smallest addressable element in a dot matrix display device. In most digital display devices, p ...
locations. An actual pixel was drawn in the space to the immediate right and below the coordinate. This made it easier for programmers to avoid graphical glitches caused by
off-by-one errors.
On the Macintosh, pixels were square, and a GrafPort had a default resolution of 72 pixels per inch, chosen to match conventions established by the printing industry of having 72
points per inch.
QuickDraw also contained a number of scaling and mapping functions.
QuickDraw maintained a number of
global variables per process, chief among these being the current port. This originally simplified the API, since all operations pertained to "the current port," but as the OS developed, this use of global state has also made QuickDraw much harder to integrate with modern design approaches such as
multi-threading and
pre-emptive multitasking. To address these problems, the
Carbon
Carbon () is a chemical element; it has chemical symbol, symbol C and atomic number 6. It is nonmetallic and tetravalence, tetravalent—meaning that its atoms are able to form up to four covalent bonds due to its valence shell exhibiting 4 ...
API (a bridge between Mac OS 9 and Mac OS X) added additional parameters to some of the routines, allowing for the (opaque) storage of thread information and a new (non-polled) event structure.
Graphics primitives
Everything seen 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
* Rounded (and oval) cornered rectangles
* Ovals (including circles and ellipses)
* Arcs (and wedges), both circular and oval
* Polygons (arbitrary closed shapes built from a list of points joined by lines)
* Regions (arbitrary sets of pixels—see below)
*
Bitmaps and
Pixmaps
* Text
Each of these objects (except text) may be drawn using a "pen", which can have any rectangular dimensions, pattern or color. Note that, because the pen is rectangular and axis-aligned, diagonal lines will end up thicker than horizontal or vertical ones. Shapes may be drawn filled or framed, using any pattern or color. A filled Arc forms a wedge. Text may be drawn in any installed font, in a variety of stylistic variations, and at any size and color. Depending on how the selected font is stored, text can be scaled in a variety of ways -
TrueType fonts will scale smoothly to any size, whereas
bitmap fonts do not usually scale well.
An important feature of QuickDraw was support for ''transfer modes'', which governed how a destination pixel value was related to its previous value and the color of the object being drawn.
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. They 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. Although regions could allow powerful graphic manipulations they are limited by the current implementation that restricts the maximum region data storage size to a sixteen bit value and so are not practical as a general-purpose drawing composition tool and practical use at high resolution is also restricted. Regions underpin the rest of QuickDraw, permitting clipping to arbitrary shapes, essential for the implementation of multiple overlapping windows. Invented by Bill Atkinson, Regions were patented as a separate invention by Appl
A region is specified (after initial creation) by an ''opening'' of the region, drawing various QuickDraw shapes, and ''closing'' the region. Hidden routines construct the region as the QuickDraw commands are executed. Bitmaps may also be converted to regions, and bitmaps may be made from regions by "painting" or "filling" the region into a graphics port.
The internal structure of a region, other than the storage length and its bounding rectangle, is opaque - there are no Apple-published documents available, though the mechanism is outlined in the patent. Regions are implemented using both vertical and horizontal
Data compression, compression. A region is stored as a series of horizontal scan lines ("
rasters"), each of which contains a vertical coordinate followed by a list of horizontal inversion coordinates. Each inversion point can be thought of as toggling inclusion in the region for all the points after it: the first point turns the region on, the second turns it off, and so on. Further compression is achieved by storing each line differentially: each line contains only the differences from the previous line rather than a full set of inversion points. Finally, identical adjacent scan lines are efficiently encoded by simply skipping them. In this way, a commonly used region, the rounded corner rectangle, is efficiently encoded, and complex operations such as region composition and image clipping may be done without requiring either extensive processor cycles or large amounts of memory. (The original systems executing QuickDraw code used processors operating at 8 megahertz clock rates and systems had but 128 kilobytes of writable memory.)
Because regions are bound to a specific orientation, a ninety degree rotation of a region would require both detailed
reverse engineering
Reverse engineering (also known as backwards engineering or back engineering) is a process or method through which one attempts to understand through deductive reasoning how a previously made device, process, system, or piece of software accompl ...
of the structure and extensive coding. A general rotation is impractical when compared to rotating the original source boundary description and simply creating a new region. However, the API includes conversion routines to and from BitMaps. (Bitmaps may also be rotated using well known methods, but with various degrees of image degradation depending upon angle chosen, the storage and processor cycles available to the operation, and the complexity of the algorithm.)
Apple has recently (in the
Carbon API) defined regions as an opaque structure under some program compilation options.
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 without the loss of resolution commonly encountered in bitmap scaling. A picture can be saved to disk in which form it defines the Apple
PICT
PICT is a graphics file format introduced on the original Apple Macintosh computer as its standard metafile format. It allows the interchange of graphics (both bitmapped and vector), and some limited text support, between Mac applications, an ...
format.
An entire BitMap (or PixMap, when referring to color images) may be copied from one GrafPort to another, with scaling and clipping. Known as
blitting, or ''CopyBits'', after the name of the function, 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 the StdProcs, a series of
function pointer
A function pointer, also called a subroutine pointer or procedure pointer, is a pointer referencing executable code, rather than data. Dereferencing the function pointer yields the referenced function, which can be invoked and passed arguments ...
s stored in the GrafPort. This limited
polymorphism permits individual operations to be overridden or replaced by custom functions, allowing
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
Desktop publishing (DTP) is the creation of documents using dedicated software on a personal ("desktop") computer. It was first used almost exclusively for print publications, but now it also assists in the creation of various forms of online co ...
.
Similar to a
subclass, the Window data structure began with the associated GrafPort, thus basically making windows exchangeable with any GrafPort. While convenient, this made it easy to write erroneous code that passed an offscreen graphics port into API that expected a full-blown window.
History
QuickDraw started life as Lisa Graf 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×342 pixels. Limited color was supported using a crude
planar model, allowing QuickDraw to drive some types of
dot-matrix printer
Dot matrix printing, sometimes called impact matrix printing, is a computer printing process in which ink is applied to a surface using a relatively low-resolution dot matrix for layout. Dot matrix printers are a type of impact printer that p ...
that used multi-colored ribbons, but very few applications supported this feature.
In 1987, the
Macintosh II was launched, which was designed as a more conventional three-box design -
Computer
A computer is a machine that can be Computer programming, programmed to automatically Execution (computing), carry out sequences of arithmetic or logical operations (''computation''). Modern digital electronic computers can perform generic set ...
,
monitor
Monitor or monitor may refer to:
Places
* Monitor, Alberta
* Monitor, Indiana, town in the United States
* Monitor, Kentucky
* Monitor, Oregon, unincorporated community in the United States
* Monitor, Washington
* Monitor, Logan County, Wes ...
and
keyboard all separate. Because the monitor was separate, and larger than the original Mac, the
video
Video is an Electronics, electronic medium for the recording, copying, playback, broadcasting, and display of moving picture, moving image, visual Media (communication), media. Video was first developed for mechanical television systems, whi ...
architecture had to necessarily change. In addition, the Mac II took the Macintosh from black-and-white to full color. 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. At this time Bill Atkinson was busy with
HyperCard
HyperCard is a application software, software application and software development kit, development kit for Apple Macintosh and Apple IIGS computers. It is among the first successful hypermedia systems predating the World Wide Web.
HyperCard com ...
, so the Color QuickDraw work was done by Ernie Beernink (then still 23 years old):
Apple's Dave Allen also credited Dave Fung.
The original architecture lacked much provision for expandability, but using a series of
hack
Hack may refer to:
Arts, entertainment, and media Games
* Hack (Unix video game), ''Hack'' (Unix video game), a 1984 roguelike video game
* .hack (video game series), ''.hack'' (video game series), a series of video games by the multimedia fran ...
s, the Apple developers managed to make the addition of color and the new video architecture virtually seamless to both developers and end users.
Color QuickDraw introduced new data structures, including GDevices to represent each attached video card/monitor, and a new color GrafPort (CGrafPort) structure to handle color, as well as PixMaps instead of BitMaps for multiple bits-per-pixel images. One of the hacks for compatibility used here was that the new structure was exactly the same size as the old one, with most data members in the same place, but with additional handles and pointers to color structures in place of the BitMap fields. The upper two bits of the ''rowBytes'' field were pressed into use as flags to distinguish a GrafPort from a CGrafPort (they were always zero on old-style GrafPorts because a BitMap could never feasibly be so wide as to ever set these bits). The use of these two high bits would come back to haunt QuickDraw later, as it forced a maximum row width of just 4,095 on 32-bit PixMaps, which became problematic for high-resolution graphics work. Later development (Mac OS 8.5/Carbon) eliminated this limitation but was not fully backward compatible. A Palette Manager was also added in Color QuickDraw which managed the arbitration of colors on indexed video devices. Most graphics primitives operations remained either unchanged (but would operate in color), or else new color versions of the black and white APIs were added.
Initially, Color QuickDraw was only capable of operating with 1, 2, 4 and 8-bit video cards, which were all that was available at the time. Soon after however, 24-bit video cards appeared (so-called true color), and QuickDraw was updated again to support up to 32 bits per pixel (in reality, 24 bits, with 8 unused) of color data ("32-Bit QuickDraw"). The architecture always allowed for this, however, so no new APIs were necessary. The color data structures themselves allowed a color depth of 1, 2, 4, 8, 15 and 24 bits, yielding 2, 4, 16, 256, 32,768 and 16,777,216 colors respectively, or 4, 16 and 256 scales of grey. QuickDraw took care of managing the resampling of colors to the available color depths of the actual video hardware, or transfer between offscreen image buffers, including optionally
dither
Dither is an intentionally applied form of noise used to randomize quantization error, preventing large-scale patterns such as color banding in images. Dither is routinely used in processing of both digital audio and video data, and is ofte ...
ing images down to a lower depth to improve image quality. A set of color sampling utilities were also added so that programmers could generate optimal color palettes for use with indexed video devices.
The architecture of QuickDraw had always allowed the creation of GrafPorts and their associated BitMaps or PixMaps "offscreen", where graphics could be composed in memory without it being visible immediately on the screen. Pixels could be transferred between these offscreen ports and the screen using the QuickDraw
blitting function CopyBits. Such offscreen compositing is the workhorse for games and graphics-intensive applications. However, until the advent of 32-Bit QuickDraw, such offscreen worlds had to be created and set up by hand by programmers within their applications. This could be error-prone, as it involved three or more separate and fairly complex data structures (CGrafPort, PixMap and GDevice, and for indexed devices, the color look-up table and its inverse). With 32-Bit QuickDraw, OS support for handling this was added, with the "Offscreen Graphics World" or GWorld. The video buffer (PixMap) of a GWorld could be stored in main memory, or when available in unused parts of video ram where copying to the screen could be optimized for speed by avoiding the need to transfer a large amount of pixel data across the main memory bus.
With the advent of
QuickTime
QuickTime (or QuickTime Player) is an extensible multimedia architecture created by Apple, which supports playing, streaming, encoding, and transcoding a variety of digital media formats. The term ''QuickTime'' also refers to the QuickTime Pla ...
, QuickDraw gained the ability to deal with compressed raster data, such as
JPEG
JPEG ( , short for Joint Photographic Experts Group and sometimes retroactively referred to as JPEG 1) is a commonly used method of lossy compression for digital images, particularly for those images produced by digital photography. The degr ...
. The QuickTime Image Compression Manager integrated closely with QuickDraw: in particular, image decompression calls were full-fledged QuickDraw drawing calls, and if a picture was being recorded, the ''compressed'' data would be saved as part of the picture, for display when the picture was later drawn. The Image Compression Manager also added integration with
ColorSync color matching.
After this, apart from back-end changes to optimize for new processor architectures (
PowerPC
PowerPC (with the backronym Performance Optimization With Enhanced RISC – Performance Computing, sometimes abbreviated as PPC) is a reduced instruction set computer (RISC) instruction set architecture (ISA) created by the 1991 Apple Inc., App ...
), QuickDraw remained largely unchanged throughout the rest of the life of the classic Mac OS.
QuickDraw GX and
QuickDraw 3D shared the QuickDraw name and were able to interoperate with QuickDraw PixMap and picture data structures, but were otherwise completely separate in functionality.
With Mac OS X, QuickDraw became part of the
Carbon
Carbon () is a chemical element; it has chemical symbol, symbol C and atomic number 6. It is nonmetallic and tetravalence, tetravalent—meaning that its atoms are able to form up to four covalent bonds due to its valence shell exhibiting 4 ...
API. In 2005, with the release of Mac OS X 10.4, QuickDraw was officially deprecated.
In 2010 with
MacPaint 1.3's
source code
In computing, source code, or simply code or source, is a plain text computer program written in a programming language. A programmer writes the human readable source code to control the behavior of a computer.
Since a computer, at base, only ...
release through the
Computer History Museum
The Computer History Museum (CHM) is a computer museum in Mountain View, California. The museum presents stories and artifacts of Silicon Valley and the Information Age, and explores the Digital Revolution, computing revolution and its impact ...
, a historical version of QuickDraw source code became available too.
See also
*
Bresenham's line algorithm
References
External links
* - original QuickDraw documentation from developer.apple.com
* - later QuickDraw documentation from developer.apple.com
QuickDraw- list of QuickDraw resources from developer.apple.com
Folklore.org: Macintosh Stories: Round Rects Are Everywhere! May 1981, story about creating QuickDraw
MacPaint and QuickDraw source code Computer History Museum
The Computer History Museum (CHM) is a computer museum in Mountain View, California. The museum presents stories and artifacts of Silicon Valley and the Information Age, and explores the Digital Revolution, computing revolution and its impact ...
-2000 Lines Of Code
{{Mac OS
Graphics libraries
Apple Inc. software
Macintosh operating systems APIs