[GRASS-dev] Cairo monitor driver
lars at ahlzen.com
Sat Oct 13 19:20:08 EDT 2007
My apologies if this has been done and/or discussed before, but a search
of grass-dev came up empty.
Since the Cairo graphics library (http://www.cairographics.org, LGPL
licensed) provides very high-quality graphics output in several vector
and raster formats, I thought it would make sense to create a "pseudo"
monitor driver for it (similar to the PNG and PS drivers). So I did.
Cairo does all of the hard work, so it's really mostly simple "glue" code.
It seems stable, and is fairly complete in terms of features. I've used
for most of my own work recently.
* High quality antialiased output. See
http://lars.ahlzen.com/cairograss/ for a few simple examples and a
comparison with the PNG driver.
* Several output format options, both vector and bitmap. The driver
currently supports PNG, PDF, PS and SVG. Output to X or Win32 windows
might be possible in the future, since Cairo supports such formats as well.
Of course, such niceness comes at a price. It takes longer to draw
complex vector data, compared to the PNG driver. However, I imagine that
in most cases drawing is not the main bottleneck anyway.
Also, it obviously pulls in Cairo as an additional dependency. Cairo is
probably found on most systems nowadays, though, since many other
applications (including some mapping and GIS software) already use it.
Additionally, the fact that GRASS monitors (unfortunately) receive
integer data (screen coordinates, line widths, etc) somewhat limits the
effectiveness of the high-precision output from the CAIRO driver. For
example, in the "Massachusetts Counties and roads" example, the
antialiasing breaks down for certain lines because they are divided into
smaller segments whose coordinates are rounded before they are drawn.
Similarly, zooming in on vector output will also reveal this drawback.
My main question is: Does all of this seem useful to anyone else? I do
realize that most of these things can be achieved in other ways, but
I've personally found this driver to produce high quality output in a
very convenient way. Feedback is appreciated!
I can of course post code too, if anyone would be interested in actually
lars at ahlzen.com
More information about the grass-dev