OK, nope, I can't help myself, I have to try one more time. ๐
Consider the polygon below. This could be the Qix area, even though I've drawn it with funny angles instead of only right angles โ it doesn't make any difference.
I've labeled the points A through J. But it's important to note that this should be thought of as a circular buffer, or a ring. It doesn't really have a beginning and an end. The point after J is A, and the point before A is J. A comes between J and B. So it's just as valid to write it as DEFGHIJABC, or GHIJABCDEF, or whatever.
Now let's draw some stix (blue lines below) from one side of this figure to another.
Here we left the border of the Qix area somewhere on edge IJ (this is easy to tell), and called that exit point, point 1. We took a zig-zaggy path, generating points 2, 3, and 4, and then hit the wall again on edge CD, and called that point 5. OK so far?
Now, recall our original ring ABCDEFGHIJ. We are going to cut that ring in two points, corresponding to the two edges that our stix hit. (This works also if it's the same edge, but in this example it's not, so bear with me.) So we're going to cut between I and J, and we're going to cut between C and D. That cuts the ring into two pieces: JABC and DEFGHI. Right?
Now we simply substitute our stix line (12345) in for each of those pieces. When it replaces JABC, we get the new polygon DEFGHI12345. When it replaces DEFGHI, then we get ABC54321J. (The order of our stix is swapped in this case, because we can see that the point next to C is 5, and the point next to J is 1.)
And that's it. We have our two new polygons. One of them gets filled in (and then forgotten); the other becomes the new Qix area. Repeat as needed, with shapes as crazy as you like; it always works.