```
class Vertex {
public:
void set(float x, float y, bool gap = false) { pX = x; pY = y; pIsGap = gap; }
float pX, pY;
bool pIsGap;
};
void Fl_Android_Graphics_Driver::end_complex_polygon()
{
if (pnVertex < 2) return;
gap(); // adds the first coordinate of this loop and marks it as a gap
int begin = 0, end = pnVertex;
Vertex *v = pVertex+0;
int xMin = v->pX, xMax = xMin, yMin = v->pY, yMax = yMin;
for (int i = begin+1; i < end; i++) {
v = pVertex+i;
if (v->pX < xMin) xMin = v->pX;
if (v->pX > xMax) xMax = v->pX;
if (v->pY < yMin) yMin = v->pY;
if (v->pY > yMax) yMax = v->pY;
}
xMax++; yMax++;
int nodes, nodeX[end - begin], pixelX, pixelY, i, j, swap;
// Loop through the rows of the image.
for (pixelY = yMin; pixelY < yMax; pixelY++) {
// Build a list of nodes.
nodes = 0;
for (i = begin+1; i < end; i++) {
j = i-1;
if (pVertex[j].pIsGap)
continue;
if ( (pVertex[i].pY < pixelY && pVertex[j].pY >= pixelY)
|| (pVertex[j].pY < pixelY && pVertex[i].pY >= pixelY) )
{
float dy = pVertex[j].pY - pVertex[i].pY;
if (fabsf(dy)>.0001) {
nodeX[nodes++] = (int)(pVertex[i].pX +
(pixelY - pVertex[i].pY) / dy
* (pVertex[j].pX - pVertex[i].pX));
} else {
nodeX[nodes++] = pVertex[i].pX;
}
}
}
//Fl_Android_Application::log_e("%d nodes (must be even!)", nodes);
// Sort the nodes, via a simple “Bubble” sort.
i = 0;
while (i < nodes - 1) {
if (nodeX[i] > nodeX[i + 1]) {
swap = nodeX[i];
nodeX[i] = nodeX[i + 1];
nodeX[i + 1] = swap;
if (i) i--;
} else {
i++;
}
}
// Fill the pixels between node pairs.
for (i = 0; i < nodes; i += 2) {
if (nodeX[i] >= xMax) break;
if (nodeX[i + 1] > xMin) {
if (nodeX[i] < xMin) nodeX[i] = xMin;
if (nodeX[i + 1] > xMax) nodeX[i + 1] = xMax;
xyline(nodeX[i], pixelY, nodeX[i + 1]);
}
}
}
}
```