[cairo] [Fwd: Problem with stroke vs. fill]
cworth at east.isi.edu
Fri Apr 2 19:56:05 PST 2004
On Apr 2, Duncan Mak wrote:
> Thanks so much for working on Cairo, I've been happily using it to
> implement the various 2D geometry drawing/filling functions in the GDI+
> Graphics class. We're making good progress!
You're quite welcome. I have fun working on it, and I'm glad you're
having some luck using it.
> I found an algorithm  from the comp.text.pdf FAQ for drawing
> elliptical arcs using bezier curves. Using this algorithm, I was able to
> implement the functions for drawing and filling arcs and pies.
Cool. I don't know if it was there already when you started this work,
but we now have the following function in cairo that may help you drop
a bunch of code:
cairo_arc (cairo_t *cr,
double xc, double yc,
double angle1, double angle2);
That will let you do any circles you want. For an ellipse you'll just
just need to to precede it with a cairo_scale as appropriate.
> All being the same, with stroke working and fill not working, I'm
> wondering, is this a Cairo bug?
I don't think so. Looking through your code I see several calls to
cairo_move_to, so your final path is a complex path consisting of
several independent sub-paths. When you call cairo_fill on a complex
path it implicitly closes each sub-path and fills them. So I think
that's what you're seeing here.
To fix this you'll want to fix make_pie so that it creates a simple
path, (ie. one cairo_move_to, followed by several calls to
cairo_line_to and cairo_curve_to). Does that make sense?
Although, frankly, I think it will be a lot easier to just switch to
using cairo_arc directly.
Let me know if you have any more problems.
More information about the cairo