static ItIt pixelIterator(Rect r) { ret new ItIt { int x2 = r.x2(), y2 = r.y2(); int x = r.x, y = r.y; public bool hasNext() { ret y < y2 && x < x2; } public Pt next() { Pt p = pt(x, y); if (++x >= x2) { x = r.x; ++y; } ret p; } }; }