sclass RecognitionGrid { double cellW, cellH; int rows, cols; Cell[] cells; *() {} *(double *cellW, double *cellH, int w, int h) { rows = iceil(w/cellW); cols = iceil(h/cellH); cells = new Cell[rows*cols]; } sclass Cell { int outerColor, middleColor, centerColor; // RGB + alpha } Cell getCell(int col, int row) { ret inRange(col, 0, cols) && inRange(row, 0, rows) ? cells[row*cols+col] : null; } Rect cellRect(int col, int row) { ret rectFromPoints(iround(col*cellW), iround(row*cellH), iround((col+1)*cellW), iround((row+1)*cellH)); } }