srecord noeq FillOnePath(OnePathWithOrigin path) { // do we fill the right-hand side or the left-hand side when // walking the path settable bool rhsIsInside; Rect r; // bounds of path BitSet inBorder; // is pixel part of path itself? BitSet inside; // is pixel inside the filled path? run { r = path.bounds(); int size = r.w*r.h; inBorder = new BitSet(size); inside = new BitSet(size); Pt last = null; for (Pt p : path.pointIterator()) { int idx = (p.x-r.x)+(p.y-r.y)*r.w; inBorder.set(idx); if (last != null) { int dx = p.x-last.x, dy = p.y-last.y; if (dx == 0 && dy == 0) {} else if (dy == 0) setInside(rhsIsInside ? last.x+dx : last.y-dx, p.y); else if (dx == 0) setInside(p.x, rhsIsInside ? last.x-dx : last.x+dx); else { /*TODO*/ } } last = p; } } void setInside(int x, int y) { if (!rectContains(r, x, y)) ret; int idx = (x-r.x)+(y-r.y)*r.w; inside.set(idx); } }