import java.awt.*;

public class Example {

  public static void main (String[] args) {
    int width = 500;
    int height = 500;

    Slate slate = Slate.makeSlate (width, height);
    Graphics g = Slate.getGraphics (slate);
    g.setColor (Color.blue);
    draw (g, 0, 0, width, height);
  }

  public static void draw (Graphics g, int x, int y, int width, int height) {
    if (height == 0) return;

    g.drawOval (x, y, width, height);

    draw (g, x, y, width/2, height/2);
    draw (g, x+width/2, y, width/2, height/2);
  }
}

class Slate extends Frame {
  Image image;

  public static Slate makeSlate (int width, int height) {
    Slate s = new Slate ();
    s.setSize (width, height);
    s.setBackground (Color.white);
    s.setVisible (true);
    s.image = s.createImage (width, height);
    return s;
  }

  public static Graphics getGraphics (Slate s) {
    return s.image.getGraphics ();
  }

  public void update (Graphics g) {
    paint (g);
  }

  public void paint (Graphics g) {
    g.drawImage (image, 0, 0, null);
  }
}



