发布于 5年前

php 画笛卡尔心

$dots=[];
for ($t=0;$t<360;$t++) {
    $y=2*cos($t)-cos(2*$t);
    $x=2*sin($t)-sin(2*$t);
    $x+=3;
    $y+=3;
    $x*=70;
    $y*=70;
    $x=round($x);
    $y=round($y);
    $str[]=$x;
    $y=$y+2*(180-$y);
    $x=$y;
    $str[]=$x;
}
$im=imagecreate(400, 400);//创建画布400*400
$black=imagecolorallocate($im, 255, 255, 255);
$red=imagecolorallocate($im, 255, 0, 0);//设置颜色
imagepolygon($im, $str, 360, $red);

imagegif($im, storage_path('app/uploads/public/heart.gif'));

imagedestroy($im);
echo '<img src="'. asset('storage/app/uploads/public/heart.gif').'"/>';
©2020 edoou.com   京ICP备16001874号-3