sclass CheckerBoard2 is G2Drawable { settable int w = 256; settable int h = 256; settable double shiftX; settable double shiftY; settable double cellW = 8; settable double cellH = 8; settable Color color1 = Color.lightGray; settable Color color2 = Color.gray; selfType cellSize(double cellSize) { ret cellW(cellSize).cellH(cellSize); } public int getWidth() { ret w; } public int getHeight() { ret h; } public void drawOn(Graphics2D g) { int xofs = idiv_floor(shiftX, cellW); int yofs = idiv_floor(shiftY, cellH); double x1 = mod(shiftX, cellW)-cellW; double y1 = mod(shiftY, cellH)-cellH; bool bRow = odd(yofs^xofs); for (double y = y1; y < h; y += cellH) { bRow = !bRow; bool b = bRow; for (double x = x1; x < w; x += cellW) { b = !b; g.setColor(b ? color1 : color2); g.fill(new Rectangle2D.Double(x, y, cellW, cellH)); } } } }