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').'"/>';

输出: