Polygon fill algo?

Mark Waddingham mark at livecode.com
Tue Feb 16 02:23:44 EST 2021

On 2021-02-16 05:55, Richard Gaskin via use-livecode wrote:
> My expectation was almost beyond anything reasonable, but it would
> seem useful if there was some way to make it happen:  imagine if each
> segment within a list of discontiguous points was rendered as though
> it's a separate object, back to front.
> It's not going to kill me to use separate graphics to hide the
> portions of the vertices I need covered, but it sure would have been
> nifty if I'd found a way to have a single poly object render as though
> it were many.

So the even-odd fill rule will not give you what you want - overlapping 
regions alternate.

The non-zero fill rule can give you what you want - but you need to make 
sure that all your sub-polygons go 'in the same direction'. (NB: Fixed 
width font ASCII art follows):

These two overlapping rects both go clock-wise so everything is filled.

   |-- |---|...v

The left rect goes anti-clockwise and the right rect goes clockwise:

   v...|   |...|
   |...|   |...|
   |-- |---|...v

    - the non-zero winding rule works by starting on the left of each 
scanline and scanning to the right
    - there is a winding counter which starts at 0.
    - at any pixel, if the winding counter is non-zero the pixel is 
    - if an edge is crossed which goes 'down', the winding counter is 
    - if an edge is crossed which goes 'up', the winding counter is 

Hope this helps!

Warmest Regards,


Mark Waddingham ~ mark at livecode.com ~ http://www.livecode.com/
LiveCode: Everyone can create apps

More information about the use-livecode mailing list