[cairo] Elliptical Arcs

Adrian Johnson ajohnson at redneon.com
Fri Mar 28 07:24:42 PDT 2008


Peter wrote:
> Is it planned to have elliptical arcs within Cairo?
> 
> The suggested procedure of scaling a circular arc with a transform seems not
> to work with 'thick' arcs, since the outline thickness is scaled as well.

The way to do this is to transform the ctm before calling cairo_arc() to
get the elliptical shape, then restore the ctm before calling
cairo_stroke(). Once the path is set, changing the ctm will not change
the path. The stroke pen shape is based on the current ctm, not the ctm
when the path was set.

For example:

    cairo_save (cr);
    cairo_scale (cr, 1, 2);
    cairo_arc (cr, 100, 100, 50, 0, 2*M_PI);
    cairo_restore (cr);
    cairo_set_line_width (cr, 10);
    cairo_stroke(cr);


More information about the cairo mailing list