Vector graphics in pseudo-3D

The Depths of Space


Vector graphics often look much like comics: although you can hint at shading and highlights, it is more or less impossible to achieve photorealism. But this could all change now that Xara LX has been released as an open source program.

By Peter Kreussel

Dani marin, Fotolia

If you compare the effort involved in drawing a 3D scene using a pencil and paper with the 3D modeling approach, you will soon discover that you are quicker doing things the old fashioned way. The closest you can get to the pen and paper feel on a computer is to use a drawing tablet with a bitmap editor such as the Gimp. But with vector graphics, which are freely scalable without affecting quality, artists typically find it hard to implement reflected light gradients or shading.

Vector graphics applications such as Inkscape only offer linear, radial, or conical gradients that are not suited to the task of depicting the kind of highlighting and shading you see on objects with more complex shapes.

The professional Adobe Illustrator program includes a Gradient mesh tool that lets artists portray complex gradients. It divides objects into a grid with fields that allow the artist to assign different color values - Illustrator then calculates smooth transitions. But no matter how powerful this tool may be, it is still not particularly well suited to achieving realistic spatial highlighting effects.

Xara, which can look back on ten years of history as a commercial Windows program, has amazing potential. If you don't believe me, check out the image gallery on the Xara homepage [1].

Introducing Xara

In late 2005, the developers decided to publish a free, Open Source version of the commercial Windows program Xara Xtreme for Linux and Mac OS. Xara LX has all the major features of the Windows program with the exception of licensed technologies such as Pantone palettes. According to the Xara developers, the current version 0.7 is "almost complete." That means that almost all the drawing tools included with the Linux verstion work like they work in the Windows versions.

Development efforts on Xara LX are progressing quickly. Two months ago, a printer function was not even available with Xara LX. Now, the developers' website states that Xara is almost complete. It is now as stable as you could expect a Beta application to be, and if the port carries on at the same pace as the previous development, we can all look forward to a reliable tool that stands up to professional demands in about a year from now.

The homepage has a binary archive, and an autopackage of Xara LX [2]. The source code, and instructions for accessing the Subversion repository, are available at [3]. Xara builds on wxWidgets, which you can build before you install Xara if it isn't already present on your system.

Plain, but Good

When you launch Xara LX for the first time, you might wonder how a program with such a plain looking user interface could ever create the photorealistic drawings in the Examples folder. Most of the Xara tools are available in Inkscape, too. With regard to drawing, there is very little to choose between Inkscape and Xara, although Xara has a Snap to Object function, a big advantage. The other differences are harder to find; you need to look at the Xara Shadow Tool, Transparency Tool, and Bevel Tool.

The Shadow tool creates a realistic looking cast shadow, just like Adobe Illustrator. If you drag an object with the tool, Xara creates a cast shadow to reflect the distance you dragged the object, using soft edges to reflect the kind of shadow objects cast in the atmosphere. The shadow contributes greatly to giving drawings a natural appearance.

Where there's shade, there's light, of course: and light cast on objects causes highlighting. The sides facing the light appear brighter, and those facing away from the light are darker. Color gradients, typically with complex shapes, exist everywhere apart from at the edges.

Naturally, color gradients are extremely difficult to portray as vectors. One options for implementing complex color gradients in vector graphics uses the Adobe Illustrator approach with gradient meshes. But Xara uses a different principle. Gradients are implemented as small, semi-transparent objects that overlay the basic shape.

In principle, there is nothing to stop you using this approach with Inkscape. The big advantage that Xara offers is that it has a far greater choice of gradient types. Besides flat transparency, the program supports linear, spherical, elliptic, conical, and diamond shaped gradients for transparent objects (Figure 1). Besides multidimensional gradients defined by two or three reference points (center row, right, and far right), Xara also supports two fractal patterns (bottom row, far left).

Figure 1: The secret of realistic spatial vector drawings: different kinds of transparent gradients give a natural appearance to shading.

All transparency gradients can be iterated (bottom row, left). And Xara can convert brightness values in bitmaps to object transparencies (bottom row, right).

The surfaces of realistic looking 3D models are typically based on photographs: the renderer applies a square display detail that depicts a wood grain to the surface of the model, just like tiling. The problem that arises with this approach is that tiles based on photographs can't typically be juxtaposed seamlessly (Figure 2, right).

Figure 2: Objects with a fill based on tiles with photo details give a drawing a realistic appearance after Xara has smoothed the edges.

Xara resolves this juxtaposition problem by applying an algorithm that smooths the edges. The Repeat inverted option removes the edges at joints (Figure 2, left). This approach is also available for bitmap tiles used as the basis for transparency effects (Figure 2, bottom row, far right).

Practical Applications

Figure 3 shows a simple example of a drawing with a spatial effect: an apple with highlights and shading to reflect the light source. The lighter and darker areas are easy to draw with the freehand tool (on the right in the Figure), and you can color them to reflect the ambient lighting. The feather function (which softens the edges) in combination with an elliptical gradient, whose expanse you can control interactively via the center and two radii, give you soft transitions. This is how to achieve the realistic looking highlights, and the light shading on the underside of the apple. The Shadow tool lets you add the shadow a genuine apple would cast on the underground. To achieve the woodgrain effect, I used a photo of a piece of wood. The Repeat inverted smooths out the transitions where the tiles meet in the repeated woodgrain effect.

Figure 3: Xara applies semi-transparent objects over a basic shape to achieve highlighting and shading. A color gradient to match gives the drawing a photorealistic touch.

The drawings in the Xara image gallery at [2] all follow the same simple principle of overlaying a basic shape with multiple objects, many of them transparent in order to reflect the play of light and shadow in the real world. Figure 4 shows a small excerpt from one of the sample graphics that accompany the Xara distribution.

Figure 4: Mirror effects on a car hood are easily emulated with simple gradients and some manual shading, assuming you have the necessary artistic talent.

The bottom layer of the hood on the blue mini is a simple linear gradient. Some craftily placed shading and mirroring give the image an almost perfect photorealistic finish. Although it takes a lot of practice and skill to create realistic drawings like the image shown in Figure 4, one thing separates Xara from 3D modeling tools. Whereas a 3D modeling tool will use raytracing to calculate perfect shading and highlighting, Xara gives the artist perfect control over the effects. And Xara's powerful transparency and fill tools are the best support an artist can ask for.

Conclusions

Xara brings a lot of interesting functions to the world of Linux. The program should not be viewed as a competitor to Inkscape. Inkscape creates graphics in SVG format, an Internet standard. The Inkscape package now includes an XML editor that supports low-level manipulation of the files, and thus has its own specific target group. In contrast to a tool like Inkscape, Xara is targeted primarily at graphic artists who will appreciate the program's effects and photorealistic gradients.

The Business Designs section of the gallery at [1] prove that the commercial version of Xara is well up to designing premium, professional products such as covers or packing. And the development process thus far leaves little doubt that the free Linux version of Xara will soon be up to these tasks. For those of you who do not require these premium, top-end features, it is well worth trying out Xara LX right now; after all, the autopackage or binary archive based installation is child's play.

INFO
[1] Image gallery for the commercial Xara version (Xara Xtreme): http://www.xara.com/gallery
[2] Binary download: http://www.xaraxtreme.org/download/
[3] Source code and SVN access: http://www.xaraxtreme.org/developers/general/source_code__building.html
THE AUTHOR

Corel Draw was the program that sparked Peter Kreussel's interesest in computers. Peter is happy to say that applications such as Inkscape or Xara have long since ousted Windows and expensive Adobe programs from his machine.