-
大小: 2KB文件類型: .java金幣: 1下載: 0 次發(fā)布日期: 2021-05-17
- 語言: Java
- 標(biāo)簽:
資源簡介
java采用Bresenham算法畫直線
代碼片段和文件信息
package?Line;
import?java.awt.Color;
import?java.awt.Graphics;
import?javax.swing.Jframe;
public?class?BresenhamLine?extends?Jframe?{
???
private?static?final?long?serialVersionUID?=?1L;
?int?x1=10;
?????int?y1=20;
?????int?x2=25;
?????int?y2=25;
????
????public??BresenhamLine(){
????
????????super(“Bresenham算法畫直線“);
????????this.setSize(800?600);
????????this.setVisible(true);
????????this.setDefaultCloseOperation(Jframe.EXIT_ON_CLOSE);
????}
????@Override
????public?void?paint(Graphics?g){
????????
????????g.fillRect(0?0this.getWidth()this.getHeight());
???????
????????g.setColor(Color.GRAY);
????????
????????//繪制表格
????????for(int?i=0;i ????????????g.drawLine(i?0?i?this.getHeight());
????????for(int?i=0;i ????????????g.draw
評論
共有 條評論