[cairo] Curve drawing question (from GUADEC)

Christopher Barker Chris.Barker at noaa.gov
Thu Jun 29 11:57:42 PDT 2006


Liam Girdwood wrote:
> I asked what was the best sequence of cairo function calls to draw a
> scaled curve in cairo (e.g. lines of longitude/latitude on a spherical
> projection of the Earth). Iirc, Carl mentioned that getting the ordering
> of cairo function calls wrong in this case could cause the line
> thickness to vary slightly from one end of the curve to the other.

Yes, setting up the drawing, and then applying a ATM, scales the line 
thicknesses as well as the point coordinates. If you do the right calls, 
in the right order, you can get around that. There was a bit of 
discussion about this a few months back. Look for a thread from April 
called "Adventures in Line widths"

However: Are you using Cairo to do the projection? I've been thinking 
about his a lot (and not just with Cairo), and I think it's probably 
better to keep your projection out of the rendering engine. Rather, do 
your projection yourself, and pass only projected coordinates to Cairo. 
Unless you want to be doing projection "on the fly" that will make this 
much easier. Even then, it's probably a better approach. For one thing, 
not every projection can be represented by a affine transform.

So in your case, you would define your lat-long lines as polylines, 
project the coords, then pass the projected coords to Cairo. This does 
have the disadvantage of you needing to pick a scale ahead of time (how 
many points to define your line with), but I imagine you generally have 
an idea what sort of scale you are working with.

-Chris


-- 
Christopher Barker, Ph.D.
Oceanographer
                                     		
NOAA/OR&R/HAZMAT         (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov


More information about the cairo mailing list