circle.java
来自「该程序是用JAVA来实现图形学中的中点算法来画直线」· Java 代码 · 共 36 行
JAVA
36 行
import java.applet.Applet;
import java.util.Scanner;
import java.awt.Color;
import java.awt.Graphics;
public class Circle extends Applet{
int x,y;
int radius;
public void init(){
Scanner scanner = new Scanner(System.in);
System.out.println("please input the radius of the circle");
radius = scanner.nextInt();
x = 0;
y = radius;
}
public void paint(Graphics g){
int d;
d = 5-4*radius;
g.setColor(Color.black);
g.drawString("。", x, y);
// System.out.println("circle");
while (y > x){
if(d <= 0)
d = d+8*x+12;
else
{
d = d+8*(x-y)+20;
y--;
}
x++;
g.drawString("。", x, y);
//System.out.println("radius ");
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?