Quick on the Draw – Vector Graphics

Affinity Designer in action.

With so many images being passed around social media, it is easy to overlook the power and value of the other type of graphics, based on vectors instead of pixels.

From the earliest days of computer graphics, distinction has been drawn between pixel-based images and vector graphics. These are most apparent when you look at an image of a chessboard, and one created using a drawing application. The image contains areas of very dark pixels, and others of very light pixels, but has no sense of structure, of the lines or shapes that make up that image.

chessboardbchessboardvThe drawn chessboard, on the other hand, is an assembly of regular squares, each filled in black or white, and can be broken down into those constituents, allowing them to be rejigged and the drawing change.

chessboard2One very visible insight into the differences can be obtained by zooming in repeatedly on the document. Once an image is shown at 200% or greater, you can see that it is an array of individual pixels, but vector graphics should remain crisp and smooth even at 1000% or more, as the computer renders each line and curve in the fairest way possible. (Unfortunately I cannot illustrate this directly here, as SVG vector graphics are not a supported format in these blogs.)

Common formats

Classical pixel-based document formats include JPEG, TIFF, GIF and its replacement PNG. Vector file types include Scalable Vector Graphics (SVG), AutoCAD Drawing Exchange Format (DXF), and the venerable HP Graphics Language (HPGL). Vector information is also commonly found in popular compound formats, which can contain images as well, such as PostScript, and its derivatives Encapsulated PostScript (EPS) and Adobe Acrobat Portable Document Format (PDF), Flash’s SWF, and Apple’s old QuickDraw PICT.

Pixels -v- vectors

Working in a pixel-based application, if you sketch in an arbitrary wiggly curve with anti-aliasing, the software will paint in the pixels that constitute the backbone of the curve in the active colour, then apply anti-aliasing to those pixels immediately adjacent to the curve to make it appear fair and not jagged. Once fixed into the pixels you cannot readjust the curve in any way.

A vector-based drawing application builds that curve using geometric constructions such as a series of Bézier or spline curves. You can then edit the control points and vectors that make up the whole curve, and the software renders it with anti-aliasing. Instead of consisting of a large array of individual pixels, the vector graphic file is made up of curves, lines, polygons, and other geometric components.

This distinction is even more clearly visible in the rendering of text. In a pixel-based image, text is just an area of pixels of different colours. Zoom into it and it becomes blurred or pixellated like the rest of the image. The document does not contain the text content either, so you cannot alter the text except by changing the pixels.

A vector-based image contains the text, which remains editable, and renders that appropriately to the level of magnification. Although the letters may be illegible when zoomed out at 25%, they should be distinct at 100% or more, and rendered smoothly.

Rendering

OS X contains extensive support for both pixel- and vector-based graphics, and in all modern Macs graphics primitives and more sophisticated drawing and rendering commands are delegated to the specialist hardware in the graphics card, using OpenGL or (most recently) Metal.

When an application wants to render a spline curve, it merely generates the OpenGL commands needed to define and render the splines, and the graphics card does the rest. To make this more powerful still, OS X provides an additional layer of support in Quartz 2D, which handles the drawing of text, PostScript and PDF, and colour management using ColorSync. When accelerated by the graphics card, Quartz 2D becomes known as ‘Quartz Extreme’ or ‘QuartzGL’, and is the standard required from Mountain Lion onwards.

The larger a pixel-based image is, the larger the file required to store it. Although compression can limit this, doubling the linear dimensions of an image will normally increase the disk space by a factor of four, the square of the increase in linear dimension. A vector-based drawing, though, consists of resolution independent commands, such as
MoveTo(100.0f, 100.0f)
LineTo(100.0f, 200.0f)
which draws a straight line between those points. To scale that up by a factor of 10, the co-ordinates of the points are scaled by 10, and the file remains identical in size. Vector document sizes thus depend on the complexity of the drawings within them, not their scale.

Use

Converting between different pixel-based image formats is not difficult, and many image editors and painting apps cope happily with all the more popular types. However vector graphic conversions are usually more tricky, and the results usually less satisfactory. This is because existing formats often have their roots in the proprietary – DXF with AutoCAD, EPS with Adobe Illustrator, for instance – and their popularity differs according to the nature of the drawing.

Scale designs and engineering work are most commonly cast in DXF, whilst graphic design work is most commonly saved in formats belonging to the PostScript family. However you may come across graphic design work that has been performed in AutoCAD and thus ended up in DXF, which can cause problems.

SVG

In theory SVG should have seen an end to all that, but it has been lamentably slow to catch on. Based on PostScript, it uses XML, and has been used for web graphics. However Microsoft Internet Explorer has only had built-in basic support for rendering SVG since version 9, released in 2011, so many of those accessing websites will still be unable to see SVG graphics, requiring messy code to provide substitutes that can be visualised.

Support in drawing, design, and painting applications has also been limited: whilst high-end products such as Affinity Designer and Adobe Illustrator can open and save to plain and compressed SVG formats, few other Mac products are as capable. Indeed tools known for their ability to work with a wide range of file types, such as Graphic Converter, do not even recognise SVG documents; Graphic Converter can only import SVG with the help of ImageMagick.

OS X is no particular friend to SVG either, as Quartz and printing are based on Acrobat PDF instead. If Apple or Microsoft had put SVG at the heart of their operating systems, they might have given it greater leverage against long and deep-rooted dependence on PostScript and its derivatives. If we also had a flourishing font scheme based on SVG that would have assisted. Being XML text, raw SVG files can quickly become very large, but there is a standard compressed format using the .svgz filename extension.

Beyond 2D

Vector graphics come into their own when you add a third dimension, and start modelling solids, which have to be stored as 3D surfaces and solids, although surface textures and patterns are commonly designed and applied as pixel images. These open a new and even more challenging world of file formats that make 2D vector graphics look plane sailing.

The Mac has enjoyed a succession of superb drawing software: on Classic Macs, MacDraw and ClarisCAD for those who were only occasional users or who wanted a clean and uncluttered interface, through the graphic designer’s favourites of Aldus Freehand and Adobe Illustrator. Today’s OS X users still have a wide choice that should cater for every need, whether you are sketching out home or garden improvements, or creating the front page of a leading magazine.

Tools: Drawing Tools

Autodesk Graphic in action.
Autodesk Graphic in action.

You are spoilt for choice of excellent drawing applications. If you want to keep it simple, either because of infrequent use or because you do not need your life complicated by bells and whistles, take a look at Autodesk Graphic (formerly iDraw, Mac App Store, £18.99). Native file format is proprietary, but drawings can be exported in a range of formats including (vector) PDF, SVG, and popular pixel-based image formats. iPad and iPhone versions which share over iCloud are available in the iTunes App Store.

Affinity Designer in action.
Affinity Designer in action.

Affinity Designer, sibling of the Affinity Photo image editor, is also very accessible, and probably better suited to those with greater demands. It costs £29.99 from the App Store, and shares human interface metaphors with its sibling. Although it normally works with files in its own proprietary format, it exports to PDF, SVG, EPS, Photoshop’s PSD, and the four popular pixel-based formats.

Adobe Illustrator CC is perhaps the benchmark, an established professional platform for graphic designers and artists. Although Adobe has enhanced Photoshop with various vector tools, its prime purpose remains the production of pixel-based images, whilst Illustrator is centred on vector graphics. It can import AutoCAD Drawing (.dwg) and DXF, CorelDRAW, EPS, Pixar, Targa, SVG, PDF, and more. Regular output formats include EPS, PDF, and SVG in addition to its own native format (.ai), and files can be exported to AutoCAD DWG and DXF, Targa, Flash, and other formats.

Tools: Specialist Apps

When you need to work with special types of vector graphics, it is worth looking for a specialist application, or extensions to a suitably capable drawing application such as Adobe Illustrator.

Magic Maps is designed to make mapping data particularly simple.
Magic Maps is designed to make mapping data particularly simple.

For example, if you need to create a series of country-level maps, you can purchase vector graphic maps drawn for you, create your own using a specialist application like Cartographica, or work with Avenza’s MAPublisher tools for Illustrator. Magic Maps from the App Store is a more modest and affordable (£29.99) mapping tool worth looking at.

OmniGraffle is a very versatile diagramming tool, which can also do sophisticated mapping.
OmniGraffle is a very versatile diagramming tool, which can also do sophisticated mapping.

A lot of drawing tasks involve placement of standardised elements such as flowchart, computer, and other symbols. Although you can build your own libraries, OmniGraffle (£79.99 from the Mac App Store, Pro upgrade £79.99 in-app purchase), and its iOS companion, have extensive stencil libraries that include a surprising number of quite unusual themes such as camera staging and lighting, as well as standards such as maps, and household fixtures and fittings. Scapple (App Store, £10.99) is another excellent tool for creating diagrams, flow charts, and the like very quickly.

Scapple makes this type of diagram extremely quick and simple.
Scapple makes this type of diagram extremely quick and simple.

Generating graphs and charts can also be slow and painful if you work with only standard tools. OmniGraphSketcher (now Open Source) is a unique application that lets you sketch a graph freehand, then tweak it directly or by editing the underlying numbers. Once you are ready, you can export the graph in EPS or PDF vector formats, or to a pixel-based image. Although it does not offer general drawing tools, you can import as EPS into another app to add final touches for publication.

There are also many specialist vector drawing applications aimed at specific industries. ArchiCAD is popular among architects. Vectorworks has a broader range of appeal, encompassing architecture, construction, landscaping, interior design, lighting and set design, and more. However pricing on these sophisticated suites is as serious as their intent, and not aimed to cater for amateurs.

Graphics by Nevit Dilmen and Whidou, via Wikimedia Commons.
Updated from the original, which was first published in MacUser volume 29 issue 1, 2013.