I am trying to create three concentric circles of different color using GraphicsProgram. However the circles never appear to be concentric..they appear to be pushed off on the sides of each other as if trying to show another dimension. I am simply creating and adding the GOval objects. May be I am missing something. Is there a way to set transparency of the circles?
Adding code below:
import acm.graphics.*;
import acm.program.*;
import java.awt.*;
public class Target extends GraphicsProgram {
final static double radiusOuterCircle = 72.0;
final static double radiusMiddleCircle = 47.0;
final static double radiusInnerCircle = 22.0;
public void run() {
final double centerX = this.getWidth() / 2.0;
final double centerY = this.getHeight() / 2.0;
GOval g = makeCircle(centerX, centerY,radiusOuterCircle , Color.RED);
add(g);
g = makeCircle(centerX, centerY,radiusMiddleCircle , Color.WHITE);
add(g);
g = makeCircle(centerX, centerY,radiusInnerCircle , Color.RED);
add(g);
}
private GOval makeCircle(double centerX, double centerY, double radius, Color color)
{
GOval g = new GOval(centerX, centerY, radius, radius);
g.setFillColor(color);
g.setFilled(true);
return g;
}
}
According to the manual the first two parameters to the four parameter GOval constructor are the coordinates for the upper left corner of the bounding box.