SIF file: doodle.sif:

How is it decided which parts of the region are filled in, and which are not? I can't work it out.
After staring at the source code for a long time I worked out what it's doing... Draw arrows on the region's outline, all the way around, then, for each row of pixels, start at the left edge, with a count of zero in your head. Each time you cross the outline and the arrows are going upwards, add one to the count, and each time you cross an outline with arrows going down, take one off the count. Whenever the count is zero, you're outside the region. That is all.
SIF file: doodle4.sif:

Here's a messy example: SIF file: spiral2.sif:

SIF file: regions3.sif:

SIF file: regions3-labelled.sif:

I added a new parameter which lets the user select how regions are filled in. It's called 'winding style' and offers 'non zero' and 'even/odd'. The behaviour described above (non zero) is the default. Here's the previous .SIF file but with even/odd turned on: regions3-region.sif:

The new parameter also appears for outlines. When 'even/odd' is selected for an outline, the outline cancels itself out wherever it crosses itself. SIF file: regions3-outline.sif:
