Where's polygon odd/even fill mode?



HOCHSTETLER, BRUCE W. (JSC-DV3/T) (TSI) writes:
This app uses the XFillPolygon function. [...] polygons that cross
regions

By "cross regions", I assume you mean the path is self-intersecting?

set to 'NonConvex. The effect is the image the polygons are drawing
are completely filled.

That is just a coincidence, on the particular X server you happen to
be using. If you read the docs for XFillPolygon, it says:

        If shape is Nonconvex, the path does not self-inter­
        sect, but the shape is not wholly convex.  If known
        by the client, specifying Nonconvex instead of Com­
        plex may improve performance.  If you specify Noncon­
        vex for a self-intersecting path, the graphics
        results are undefined.

I.e. if you *know* that the path might be self-intersecting, you
shouldn't be using Nonconvex. You should tell X11 that it
self-intersects, and intead use XSetFillRule to set the graphic
context's fill rule to WindingRule.

On windows the SetPolyFillMode method accomplishes the
same thing by setting the fill mode to WINDING. 

Where's the same capability in GDK? 

There doesn't seem to be... For some reason that functionality was
left out of GDK. Quite possibly it was just an oversight when GDK was
initially written, at which time it was just a rather thin wrapping
over Xlib.

You have to draw the polygon in non-overlapping pieces, and only those
pieces that WindingRule would fill. (If you draw it in pieces that
overlap, that won't necessarily produce the intended result if you use
GdkGC function values like GDK_INVERT or GDK_XOR that depend on the
source bits, as the overlapping regions will be painted several
times.)

--tml





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]