next up previous contents
Nächste Seite: Sortierverfahren Aufwärts: Fraktale Vorherige Seite: Quadrate rekursiv ausgeben   Inhalt

Kreise rekursiv baumartig darstellen

import java.awt.*;
import java.applet.*;

public class Kreise extends Applet {

    public void paint (Graphics g) {
        kreise(this, 100, 200, 200);
    }

    public void kreise(Container ct, double l, double x, double y) {
        Graphics g = ct.getGraphics();
        if (l>1) {
            kreise(ct, l/2, x-l, y+l);
            kreise(ct, l/2, x+l, y+l);
            g.setColor(Color.black);
            g.drawOval((int) (x-l),(int) (y-l), (int) (2*l), (int) (2*l));
            g.setColor(Color.yellow);
            g.fillOval((int) (x-l+1),(int) (y-l+1),(int) (2*l-1), (int) (2*l)-1);
        }
    }
}



Alfred Nussbaumer 2003-02-10