// Abstract base class for tiling an image (G22Tiling)
abstract srecord noeq G22AbstractTiler
(Img image) is Runnable {
int w, h, runner;
gettable int size; // =w*h
// iterator that provides points to be looked at
// (e.g. a WeightlessShuffledIterator)
IndexIterator pointIterator;
new IntBuffer stack; // locations to be looked at as y*w+x
G22Tiling
tiling; // the tiling we are making
bool verbose;
// The one method subclasses need to override
abstract int getColor(int pos);
// calculations for positions (pixel index)
int x(int pos) { ret pos % w; }
int y(int pos) { ret pos / w; }
int pos(int x, int y) { ret y*w+x; }
Pt pt(int pos) { ret Pt(x(pos), y(pos)); }
bool validPos(int x, int y) { ret x >= 0 && y >= 0 && x < w && y < h; }
run {
w = image.getWidth(); h = image.getHeight();
size = w*h;
tiling = new G22Tiling(image);
}
}