public void buildDiagonallyNestedWindows(double size, int levels) { System.out.println("buildDiagonallyNestedWindows("+size+", "+levels+");"); if (levels>0) { window(size); buildDiagonallyNestedWindows(size/2,levels-1); moveToNext(size/2); buildDiagonallyNestedWindows(size/2, levels-1); returnToStart(size/2); } }
// build a window (a square) with sides of the specified size public void window(double size) { System.out.println("window size "+size); fd(size); lt(90); fd(size); lt(90); fd(size); lt(90); fd(size); lt(90); }
public void moveToNext(double size) { System.out.println("moveToNext"); pu(); fd(size); lt(90); fd(size); rt(90); pd(); }
public void returnToStart(double size) { System.out.println("returnToStart"); pu(); rt(90); fd(size); rt(90); fd(size); rt(180); pd(); }