畫星星函式
public void cad_drawstar(Graphics g,int x,int y,int r,int angle)
{
Graphics2D graph = (Graphics2D)g;
double deg,temp1,temp2,temp3,temp4;
deg=3.14159/180.0;
double pt_x[] = new double[7]; //java 宣告陣列 格式
double pt_y[] = new double[7];
double ptt_x[] = new double[7];
double ptt_y[] = new double[7];
int i,j;
for (i=0;i<7;i++){
pt_x[i]=x+r*Math.sin(72.*deg*i+angle*deg); //sin cos 三角函數 使用格式 Math.
pt_y[i]=y-r*Math.cos(72.*deg*i+angle*deg);
temp1=Math.cos(54.*deg-72.*deg*i-angle*deg);
temp2=Math.sin(54.*deg-72.*deg*i-angle*deg);
temp3=Math.sin(18.*deg);
temp4=Math.cos(36.*deg);
ptt_x[i]=x+r*temp3*temp1/temp4;
ptt_y[i]=y-r*temp3*temp2/temp4;
}
for (i=0;i<5;i++){
graph.drawLine((int)pt_x[i],(int)pt_y[i],(int)ptt_x[i],(int)ptt_y[i]);
//graph.drawLine 內的點必須是 int 因此把double 等變數強制轉換
j=i+1;
graph.drawLine((int)ptt_x[i],(int)ptt_y[i],(int)pt_x[j],(int)pt_y[j]);
}
}
php call java in cmsimple
<?php
function HelloWorldApp(){
$output="<applet codebase=\"plugins/test\" code=\"HelloWorldApp\" height=\"500\" width=\"500\"></applet>";
return $output;
}
?>
沒有留言:
張貼留言