Drawing and Painting in Flash
In this chapter
Understanding Vector Graphics
Flash was originally designed as an animation application to translate old-style, incremental animation to the Web. Given its roots in early cel animation, drawing has always been at the core of Flash. Although perhaps not as sexy as the scripting and complex interaction now possible in MX, drawing is still essential to getting the most out of Flash.
Computers display graphics in two formats: vector and bitmap. Bitmaps are made up of discrete units called pixels. Each pixel contains a single color. When combined, the variations in pixel color create the patterns that make up an image. Bitmaps contain color information for each pixel in an image plus the dimensions for the image, and transmit images pixel by pixel. Bitmaps are great for displaying subtle variations in color, such as photographic images. But what if you want to change the size of a bitmap image? Well, you either have to re-create the image at the desired dimensions or stretch the image, usually with undesirable results.
By comparison, vector graphics store a series of commands necessary to create an image using lines and curves. The commands, called vectors, dictate attributes of lines and curves such as thickness, direction, color, and position, which are then calculated by your computer. Vector graphics allow for much finer detail and can easily be resized without losing definition. When you edit a vector graphic, you simply change the attributes of your lines and curves. Vector graphics are best for displaying simple shapes with flat areas of color, such as icons, logos, and cartoon-style drawings. Both vector and bitmap graphics are drawn on request, but vectors have much smaller file sizes and can be drawn much more quickly. Bitmaps have to be transmitted pixel by pixel, so file size and download time are directly tied to an image's dimensions. Vector graphics transmit instructions, which are then carried out by your processor, so that file size and rendering speed are determined by the complexity of the instructions, not the size of the graphic.
Given its history as an animation program, it's not surprising that Flash is vector-based. Flash can display bitmaps as well but is designed to take advantage of vectors.