我试图让一个小程序绘制一个圆,从起始半径的大小开始,一遍又一遍地扩大,直到它达到半径的最终大小。只需要朝着正确的方向前进,这就是我到目前为止所拥有的..
import javax.swing.JApplet;
import java.awt.Graphics;
import java.util.Scanner;
public class circleExpandv1 extends JApplet
{
public void paint( Graphics g )
{
super.paint( g ); //instantiate g with paint
Scanner scan = new Scanner( System.in );
System.out.print( "\nEnter beginning radius > " );
int radiusStart = scan.nextInt();
System.out.print( "\nEnter ending radius > " );
int radiusEnd = scan.nextInt();
int centerX0 = 150, centerY0 = 50; // set x y cordinates
int radius0 = radiusStart; // set radius
int centerX1 = 150, centerY1 = 50; // set x y cordinates
int radius1 = radiusEnd; // set radius
while ( radiusStart != radiusEnd )
{
if ( radius0 < radius1 )
{
g.drawOval( centerX0 - radius0, centerY0 - radius0, radius0 * 2, radius0 * 2 ); //draw oval
}
}
//g.clearOval( centerX0 - radius0, centerY0 - radius0, radius0 * 2, radius0 * 2 ); //clear oval
}
}