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).
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.
Scalability means you can view or export your drawing at any resolution, and you’ll never see any jaggedness, pixelation, or unwanted blurring. Everything remains perfectly crisp regardless of size. This is often cited as the main advantage of vector graphics, although in my view, other advantages are no less important.
Vector images are editable at any time.
No matter how complex your drawing is, you can always pick any object in it and edit away. It’s a bit like a Photoshop file in which every single brush stroke is placed on a layer of its own—automatically. Furthermore, in a raster editor, you are supposed to eventually “flatten” your image, so that all separate layers are merged. By contrast, there’s no need—indeed no possibility—to flatten a vector drawing (except by exporting it to a raster image).
Vector images are easy to create and read.
Vector objects conform much better to human visual perception: When we look at a scene, we tend to mentally separate it into objects, just as is done in a vector drawing. This makes vector graphics a very natural medium to work in. Also, since many vector formats (including SVG) are text-based, it is easy to write a simple vector drawing manually (without a graphic editor of any kind) or to program a script to generate or modify such a drawing.
Vector images are laconic.
Since you don’t have to store information about every pixel, a vector image usually takes much fewer bytes to store and transmit than the corresponding raster image. As a nice side effect of this, Inkscape has unlimited undo history, simply because each undo step takes much less memory as a vector than it would as a raster.
Vector images are infinite.
A raster always has a fixed size in pixels—for example, 468 by 60 pixels. In an uncompressed bitmap, doubling the dimensions will quadruple the size of the file because the extra pixels need to be stored even if they are empty. Not so with vector images. A vector image is virtually boundless, and expanding it by moving an object an inch or a mile away costs nothing in terms of file size or computer memory. Similarly, a vector document is virtually infinite in terms of depth: You can zoom in as close as you want and create any number of microscopic-sized objects in any given space. (In reality, of course, both canvas size and zoom level are limited, but these limits are much, much larger than in a raster editor.)
Vector images can be animated.
Since objects are stored separately in a vector drawing, it’s easy to animate them by moving them, transforming them, changing their colors, and so on. That’s why some vector formats such as SVG or Flash naturally provide animation capabilities as well. Although Inkscape does not yet support animated SVG, this feature is planned for implementation in a future release.
Vector images can be interactive.
Not only can you animate objects, but you can make them interactive as well. A drawing can change the properties of objects in response to user actions, which makes it possible to implement complex user interfaces with buttons, links, drag-and-drop, and so on. Again, Inkscape’s current capabilities in this area are limited, but you can manually edit an SVG file created in Inkscape, adding interactivity which can then be played in an SVG viewer.
Vector objects are reusable.
It’s very easy to pick an object from one drawing, transform or restyle it without any loss of quality, and then insert it into another drawing.
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.
A vector image format (of which there are many, just as there are many different raster formats) always limits you to a certain repertoire of objects and their properties. New versions of formats invent and introduce new capabilities, but that only highlights the fact that perfection is unattainable. Vector formats are always “under construction.”
There are many images that are very difficult or even impossible to reproduce exactly in vector form. For example, images that require complex textures, such as human skin, hair, or wood, are not vector-friendly. The world of vectors is traditionally made up of precise shapes, flat colors, and smooth gradients; if what you like is naturalistic noise, scratches, or dirt, you will probably have a hard time rendering that in a typical vector editor.
Still, with Inkscape’s transparency, gradients, and filters, you can create amazingly photorealistic vector images (see Figure 1 on the color insert). Also note that, being a higher-level abstraction, a vector drawing may include raster images as a special kind of object. Thus, you can always insert a photo into an Inkscape drawing and freely combine it with vector objects.
Vector format conversions are unreliable.
For the same reason, it is never trivial to convert an image from one vector format into another. The repertoires of object types and capabilities of the formats always differ, sometimes in less than obvious ways; different versions of formats muddy the picture even more. For example, SVG supports blurring objects (17.1 Blur) while PDF does not; on the other hand, PDF supports gradient meshes (1.5.4 . . . and Inkscape), a feature presently missing in SVG. This makes any kind of vector conversion an iffy business. In the best case, you get an approximation of the source object that the target format cannot represent directly (for example, for exporting SVG to PDF, you may need to replace blurred objects with embedded rasters). In the worst case, you’ll simply get a broken image after the conversion.
This is one of the reasons Inkscape’s vector format, SVG, is so important. It is an acknowledged international standard with rich and well-defined capabilities, which therefore has the potential to become the lingua franca of vector graphics (although Adobe’s PDF is still much more common in this role). We will discuss SVG in more detail later in this chapter.
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).
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).