1.1 What Vector Graphics Is and Why It Matters

Inkscape is a vector graphics editor. What does that mean?

The majority of images stored and processed on computers today are represented as rasters, also called bitmaps. A raster image is a rather primitive representation—just a lattice of small rectangular areas called pixels. For each pixel, the only information a raster file stores is its color and, possibly, its transparency.

For example, if you have a bitmap image with a black circle on white background (Figure 1-1, left), there is in fact no black circle stored in the image at all. It’s only you, when viewing this image, who may (or may not) get the idea of a black circle. All the computer knows about the image is that some of its pixels are black and some are white (and a few are an in-between gray).

A circle as a bitmap (left) and vector (right)

Figure 1-1. A circle as a bitmap (left) and vector (right)

As a result, there is precious little that the computer can do with such an image without human guidance. It can paint all the white pixels blue, but it cannot move or transform the circle because it does not see it as a separate object. These kinds of tasks may be difficult even for humans, as anyone who has used the GIMP or Photoshop would attest; you’ll have to use complex and unreliable tools to “select” the circle, and you can hardly ever do this perfectly if, for example, the edge of the circle is antialiased (so that some pixels on the edge have intermediate values between black and white) as it is in Figure 1-1.

It’s all different with vector graphics (Figure 1-1, right). In a vector format, the actual circle can be stored along with its properties as an object. This means you can easily separate it from other objects and do whatever you please with it. Moreover, with such an image, your computer can do many smart things automatically—for example, it can automatically delete all circles, paint all red objects with green, or scale all black circles to twice their size.

No more frustrating pixel selections: Just pick any object and edit it as needed. That’s how Inkscape works, and this is its main point of difference from raster editors such as Photoshop.

Let’s look at the most prominent advantages of the vector approach:

Vector images are scalable.

Vector images are editable at any time.

Vector images are easy to create and read.

Vector images are laconic.

Vector images are infinite.

Vector images can be animated.

Vector images can be interactive.

Vector objects are reusable.

If you are into digital music, you may better understand the distinction between vector and raster graphics if I liken vector graphics to a MIDI sound file and raster graphics to a WAV sound recording. Another analogy, suited to programmers, might be to compare vectors to the source code of a program and rasters to compiled binaries.

Of course it can’t be all roses and no thorns. Here are the two main disadvantages of vector graphics compared to rasters:

Formats are fundamentally limited.

Vector format conversions are unreliable.

So, what is actually stored in a vector drawing? Apart from the embedded raster objects just mentioned, the most common vector object type is a path. A path is just a sequence of commands like “draw a straight line to such-and-such point” and “draw a smooth curve through such-and-such points.” There may be any number of such commands in a sequence, which means a path can approximate any geometric figure or real-world shape with any desired accuracy. A path can have fill (paint in the area enclosed by the path) and stroke (paint along the path itself), as well as many other properties that define how the path looks (Figure 1-2).

A path object can represent any shape.

Figure 1-2. A path object can represent any shape.

There are several other object types (such as text objects, clones, and groups) and many other object properties (such as font size, visibility, and blur). Many properties can apply to all kinds of objects, while others are specific to particular object types. A drawing is just a collection of objects of various types; these objects can be placed whenever you need them, including on top of each other, and they can even be made partially or fully transparent so that whatever is beneath them shows through. Figure 1 on the color insert shows an example of a complex Inkscape drawing that makes heavy use of opacity, gradients, and blur to achieve realism (you can load it from Inkscape’s examples directory if you want to examine it in full glory).