php代码
<?php $Nationflag = ImageCreate(660, 440);
ImageColorAllocate ($Nationflag,255,0,0);
DrawPentacle($Nationflag,180,150,120,120);
DrawPentacle($Nationflag,80,30,210,50);
DrawPentacle($Nationflag,120,30,250,100);
DrawPentacle($Nationflag,180,30,250,160);
DrawPentacle($Nationflag,100,30,210,210);
Header('Content-type: image/png');
ImagePng($Nationflag);
ImageDestroy($Nationflag);
/*
函数:绘制五角星
参数
$mFlag:图像标识
$mAngle:旋转角度
$mRadius:外接圆半径
$position_X:绘制坐标X
$position_Y:绘制坐标Y
*/
function DrawPentacle($mFlag,$mAngle,$mRadius,$position_X,$position_Y){
$yellow = imagecolorallocate($mFlag, 255, 255, 0);
$PI = 3.14;
$theta=54+$mAngle;
for ($i=0;$i<5;$i++) {//五顶点坐标
$r = $mRadius*sin(18*$PI/180)/sin(54*$PI/180);
$points[$i]= array('x'=>$r*cos(($theta+$i*72)*$PI/180)+$position_X,'y'=>-$r*sin(($theta+$i*72)*$PI/180)+$position_Y);
}
for($i=0;$i2?$i-3:$i+2;
$lines[$i] = array('x1' => $points[$i]['x'], 'y1' => $points[$i]['y'], 'x2' => $points[$j]['x'], 'y2' => $points[$j]['y']);
}
for($i=0;$i3?0:$i+1;
$x12 = $lines[$i]['x1'] - $lines[$i]['x2'];
$x34 = $lines[$j]['x1'] - $lines[$j]['x2'];
$y12 = $lines[$i]['y1'] - $lines[$i]['y2'];
$y34 = $lines[$j]['y1'] - $lines[$j]['y2'];
$c = $x12 * $y34 - $y12 * $x34;
$a = $lines[$i]['x1'] * $lines[$i]['y2'] - $lines[$i]['y1'] * $lines[$i]['x2'];
$b = $lines[$j]['x1'] * $lines[$j]['y2'] - $lines[$j]['y1'] * $lines[$j]['x2'];
$x = ($a * $x34 - $b * $x12) / $c;
$y = ($a * $y34 - $b * $y12) / $c;
$intersection[$i]= array('x'=>$x,'y'=>$y);
}
for($i=0;$i
php免费学习视频:立即使用
踏上前端学习之旅,开启通往精通之路!从前端基础到项目实战,循序渐进,一步一个脚印,迈向巅峰!










