[cairo] Bezier curve

Inderjit Singh inderjit.singh at spaceapplications.com
Mon Nov 7 06:42:21 PST 2011


Hi, 

I'm new to cairo and I'm trying to draw a smooth curve between using an array of points. 

Say I have an array with (x,y) coordinates as: POS_T pos = {{0.0, 0.0}, {1.0,1.0}, {1.5, 2.0}, {0.5, 3.0}, {0.0, 4.0}}; 

So basically, a half round 'circle'. I've been looking in cairo docs but the closest thing I get to is the cairo_curve_to but for that it requires control points. How is it determined? I want a simple smooth line but using Bezier algorithm requires additional data to make it happen. Is that correct? 

Or can I simply use curve_line_to and then interpolate this? currently the code looks like this for line: 

... 
for(uint32_t i = 0; i < boundary; i=i++) 
{ 
cairo_move_to(cr, station->coverage[i].x, station->coverage[i].y); 

// cairo_line_to(cr, 
// station->coverage[(i+1) % boundary].x, 
// station->coverage[(i+1) % boundary].y); 

cairo_curve_to(cr, 
station->coverage[i].x, 
station->coverage[(i].y, 
station->coverage[i+1].x, 
station->coverage[i+1].y, 
station->coverage[i+2].x, 
station->coverage[i+2].y); 
} 

cairo_set_line_width (cr, 1.5); 
cairo_stroke(cr); 

cairo_destroy(cr); 


Any help would be appreciated. Thanks. 
Indy 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20111107/924cad6a/attachment.html>


More information about the cairo mailing list