Chapter 35. Programming Vector Graphics
Drawing programmatically allows you much greater freedom in creating and modifying your graphics at runtime, enabling you to create rich and exciting interactivity. It also enables you to make incredibly small files without embedded graphics — all the drawing executed at runtime by ActionScript. Vector graphics are drawn with lines and fills. Like vector graphics imported into your SWF, they look good at any scale. When programming vector graphics, you have many of the same tools in code that you may be familiar with from drawing software packages like Adobe Illustrator or Inkscape, such as curved and straight lines, rectangles, and ellipses.
Flash Player 10 adds new vector drawing methods that let you efficiently batch drawing commands, draw in three dimensions, and use shaders. The new APIs provide a great low-level toolkit for building three-dimensional graphics engines. Look for the Version notes that indicate features only available in Flash Player 10 and later.
This chapter needs to cover a lot of ground. A high-level view of the drawing API helps you keep oriented as you learn about the details of each part.
The classes involved in the drawing API are part of the
flash.display package. Primarily, you'll be using the
Graphics class, which acts as a canvas for drawing vector graphics. The
Graphics class is an abstract class; you can't create instances of it directly with