Re: Where's polygon odd/even fill mode?



On Thu, 2003-08-14 at 20:10, Tor Lillqvist wrote:

 > 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.)

Presumably the reason that you got away with using NonConvex
in the older code was simply that the X servers just always
use the same algorithm that works for Complex. Or they 
ignored fill_rule when NonComplex was passed.

Anyways, as long as you only care about X11, then 

 #include <gdkx.h>

 GdkGC *gc;

 gc = gdk_gc_new(); /* Or new_with_values() */
 XSetFillRule (GDK_DISPLAY_XDISPLAY (gc),
               GDK_DISPLAY_XGC (gc),
               WindingRule);

Is probably pretty safe. I won't *guarantee* that will work
with all future GTK+-2.x versions, but I don't see what
would break it.

You might want to file a bug in bugzilla to add the missing
pieces to GdkGC. Considering our current interest in moving
to Cairo (http://www.cairographics.org) as the GDK rendering
API, I'm not sure if we'll bother with a lot of tweaking
of the X API at this point. (And if nobody has complained in 
7 years, it can't be a common need :-), but it can't
hurt.

Regards,
                                Owen





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