srecord noeq G22RegionThinner(IImageRegion originalRegion) is Steppable { Rect bounds; // true = part of region // index is in bounds coordinates bool[] pixels; IImageRegion region = new { public Rect bounds() { ret bounds; } public bool contains(int x, int y) { ret containsPt(bounds, x, y) && pixels[idx(x, y)]; } public Iterator pixelIterator() { ret iff_null(new IF0 { int idx = 0; public Pt get() { for (; idx < pixels.length; idx++) if (pixels[idx]) ret idxToPt(idx); null; } }); } }; int idx(int x, int y) { ret (y-bounds.y)*bounds.w+x-bounds.x; } Pt idxToPt(int idx) { ret pt(bounds.x+(idx % bounds.w), bounds.y+idx/bounds.w); } void init { if (bounds != null) ret; boudns = originalRegion.bounds(); pixels = new byte[area(bounds)]; for (Pt p : originalRegion.pixelIterator()) pixels[idx(p.x, p.y)] = true; } public bool step() { init(); false; } }