[cairo] Path Holes

Bill Spitzak spitzak at thefoundry.co.uk
Mon Jul 28 10:50:55 PDT 2008


It's using non-zero winding rule as in PostScript. Draw a line from a 
point to infinitiy (in any direction) and then count all the parts of 
the path that cross it, adding 1 if it crosses from left to right and 
subtracting 1 if it crosses from right to left. If the result is not 
zero then that point is in the interior if the shape.

This is really useful so that your path can be a bunch of disconnected 
shapes that *may* overlap. The other popular fill method is even/odd, in 
that case the point is in the interior if the sum calculated above is 
odd. Many software renderers do this because it is easy, but it is 
useless for drawing a shape that contains overlapping parts as the xor 
effect is not wanted.

You can't just say a subpath "is" or "is not" a hole, as a single 
subpath can produce more than one closed loop:

     _______
    |   _   |
    |  / \  |
    |  \ /  |
    |   X   |
    |__/ \__|


Bobby Salazar wrote:
> How does Cairo decide whether or not a sub path is to be a hole and not painted, or is supposed to be part of the shape?
> 
> Currently, it looks like Cairo assumes it's a hole if the points go counter-clockwise and the original path points go clockwise. There must be a better way. Is it possible to explicity tell Cairo that a specific sub path is a hole or not?
> 
> Does anyone know what the reasoning is for the current behavior?
> _______________________________________________
> cairo mailing list
> cairo at cairographics.org
> http://lists.cairographics.org/mailman/listinfo/cairo


-- 
Bill Spitzak, Senior Software Engineer
The Foundry, 1 Wardour Street, London, W1D 6PA, UK
Tel: +44 (0)20 7434 0449 * Fax: +44 (0)20 7434 1550 * Web: 
www.thefoundry.co.uk
The Foundry Visionmongers Ltd * Registered in England and Wales No: 4642027



More information about the cairo mailing list