Vector graphics
From Better Practices
Vector graphics are graphics that are described using pre-defined objects, transformations, colors, strings, and other mathematical and programmatic primitives. Unlike raster graphics, grid elements are not painted, and therefore vector graphics require a less naïve method for constructing them. Virtually all mathematical drawings and graphs are (naturally) in vector format. However, many applications (such as digital cameras, computer screens, printers, etc.) in their final output rasterize all graphics.
The primary advantage of vector graphics is its scalability. An example of this would be in order to scale a circle centered at the origin to 200% of its original size, it is enough to simply multiply the radius of the circle by 2 and the new description is complete. Therefore, there is no loss in quality in performing such scalings.
Another advantage of vector graphics is its small filesize. Since the graphics are described by mathematical primitives, the storage required to characterize this description is minimal.
Common vector formats include EPS, PDF, PS, SVG, among others.
[edit] Generating Vector Graphics
There are many graphics programs designed to generate vector graphics. Among these include Microsoft Visio, CorelDraw, Inkscape, Dia, MetaPost, (among others). Furthermore, most mathematics software including Matlab, Octave, Maple, Mathematica, Maxima (and others) can export graphics in at least an EPS vector format.
A common problem that Microsoft Windows users often encounter is the inability of their applications to export EPS or PDF graphics. If these graphics are not raster in nature, then a simple solution to this problem is to install a generic PostScript printer driver and print to this printer. Any PostScript printer driver, e.g., the Apple Color LaserWriter 12/600, may be used, but the driver should be instructed to print to FILE instead of a physical printer port. Once this is configured, printing to this “printer” will prompt for a filename to save the resulting PostScript document. This PostScript document will generally not be an EPS since it will lack a BoundingBox. This problem can be solved using GSview by selecting “PS to EPS”. The user will then have the option of having GSview automatically compute the BoundingBox or manually specifying it. Note that GSview relies on Ghostscript to perform much of its backend processing. GSview can also convert PS and EPS to PDF using the pdfwrite device.
Microsoft Windows user may also want to try PDFCreator.
In order to convert PDF to SVG, Troy Henderson's PDF to SVG Converter can be used.
[edit] Rasterizing Vector Graphics
As mentioned above, virtually all applications that preview vector graphics are rasterizing them in order to display them on the resulting media. Two methods for presenting vector graphics on the web include:
- Convert the vector graphic to SVG format
- Rasterize the vector graphic
Since many browsers now natively support SVG, it may be desirable to simply leave the vector graphic in a vector format (by converting to SVG) and include the SVG in the webpage.
A more compatible (but less elegant) solution is to convert the vector graphic to a raster format such as PNG and include the PNG in the webpage. Most raster graphic editors, such as Gimp, Paint Shop Pro, and Photoshop (among others) can import EPS, PDF, and SVG (as well as other vector formats). These programs naturally rasterize vector graphics while importing, and thus simply saving (i.e., exporting) them provides a method of converting vector to raster.
