Polygon fill algo?

Richard Gaskin ambassador at fourthworld.com
Tue Feb 16 03:20:35 EST 2021


Super helpful, Mark. Thank you.

I can better understand how the existing modes work, but I need 
something a little different.

Imagine if we had a mode where each successive set of points is rendered 
so it completely paints over anything rendered before it, vertices and 
all - e.g.:


    |--->---|
    |.......|
    |...|--->---|
    ^...|.......|
    |...|.......|
    |-- |.......v
        |.......|
        |-------|


   set the fillmode to layered --?

--
  Richard Gaskin
  Fourth World Systems


Mark Waddingham wrote:

> 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
>        |.......|
>        |-------|
> 
> Notionally:
>     - 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 
> filled.
>     - if an edge is crossed which goes 'down', the winding counter is 
> decreased
>     - if an edge is crossed which goes 'up', the winding counter is 
> increased
> 
> Hope this helps!
> 
> Warmest Regards,
> 
> Mark.





More information about the use-livecode mailing list