import java.awt.*;
import java.applet.*;
import java.awt.event.*;
class New_Canvas extends Canvas //New_Canvas繼承Canvas類別
{
New_Canvas()
{
setBackground(Color.white);
setSize(280,280);
}
public void paint(Graphics g) //覆寫paint方法,使其在Canvas上畫圖
{
double x[] = new double[10];
double y[] = new double[10];
double x_cen=140,y_cen=140,dis=100;
int i,j;
for(i=0;i<10;i++)
{
x[i]=x_cen+dis*Math.cos(36*i*Math.PI/180);
y[i]=y_cen+dis*Math.sin(36*i*Math.PI/180);
}
for(i=0;i<10;i++)
{
for(j=0;j<10;j++)
g.drawLine((int)x[i],(int)y[i],(int)x[j],(int)y[j]);
}
}
}
public class Ten extends Applet
{
public void init()
{
New_Canvas canv = new New_Canvas();
add(canv);
}
}
創作者介紹

My Life Going By My Style

Neo Chao 發表在 痞客邦 PIXNET 留言(0) 人氣()