private Pos rot(int x, int y) {
        switch (rotation) {
            case 0:
                return new Pos(x, y);
            case 1:
                return new Pos(y, getWidth() - 1 - x);
            case 2:
                return new Pos(getWidth() - 1 - x, getHeight() - 1 - y);
            case 3:
                return new Pos(getHeight() - 1 - y, x);
            default:
                throw new AssertionError();
        }
    }