Saturday, April 30, 2011

Vector graphics and Inkscape

On a whim, I decided to try Inkscape. It's a completely free open-source vector graphics editor.

Most images, like those taken by digital cameras, are raster graphics - they consists of thousands and millions of individual pixels, a bitmap. The storage and compression algorithms are different, but all raster graphics share one thing - they take up a lot of space on hard drives. Now, that's a pretty hefty disadvantage. A 500x500 pixel image may be just 250kB, but a typical 1000x2000 image is 2MB, and it just scales up from there.

Raster graphics also pixelate. Try to take a tiny 100x100 image and blow it up to screen-size and it just becomes fuzzy.

Vector graphics solve both those problems. They store images as a series of vectors, which can represent curves, polygons, and lines. For simple images - maps, diagrams, graphs, basic 3D images, and line drawings - vector graphics can have absurdly small filesizes, often smaller than Word documents.

And, the vectors can be scaled infinitely. So you could take a postage-stamp-sized .SVG file, and blow it up to the size of a billboard, and it'd still be perfectly smooth. PDF files use vector graphics, so they can be zoomed in nicely.

They're not perfect for everything; normal photographs do not work as vectors. But for simple images, vectors have another advantage: Each object that you create remains a separate piece, even after saving. You can move each independently at any time, thus making changes that are laborious in raster images extremely simple. For example, if there is text on top of a complex background, it's impossible to move it in a raster image if it's not in a separate layer. In Inkscape? Click, drag.

Here's my first image created in Inkscape, the aforementioned station schematic. Below is a rasterized version of the vector image (Blogger doesn't accept vector images); for the (now slightly updated) vector version, see the file page on Commons. (The new version has more street names and a compass rose).

No comments: