⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 circle.java

📁 该程序是用JAVA来实现图形学中的中点算法来画直线
💻 JAVA
字号:
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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -