I wanted to start creating fractals, which I think are fascinating. But I cant get the following code to work.
void drawcircle(int x, int y, int radius) {
g.drawOval(x,y, radius,radius); //g is to call the graphic functions
if(radius>2)
{
radius=radius/2;
drawcircle(x, y, radius);
}
}
Its supposed to give concentric circles, but theres just not output at all. Even a wrong output would work, as it'd allow me to fix it, but just nothing comes up in the frame. In the output window, it shows a huge block of red lines, but I dont understand what the error is. Can someone point me to the error? It'd be much appreciated. Edit : The code is used as follows. The code dosen't actually work for these values on my system, but it dosen't work for any other values either.
int x=0; int y=0;
drawcircle(x,y,256);
This is the error I'm getting :
Edit : Thanks to all the comments, I figured out the issue with the code. The correct code is
void conccircle(int x,int y, int radius,Graphics G) {
G.drawOval(x-radius,y-radius,radius*2,radius*2);
if(radius>=2)
{
radius=radius/2;
conccircle(x,y,radius,G);
}
}