1 <?php
2 for($t=0;$t<360;$t++)
3 {
4 $y=2*cos($t)-cos(2*$t); //笛卡尔心形曲线函数
5 $x=2*sin($t)-sin(2*$t);
6 $x+=3;
7 $y+=3;
8 $x*=70;
9 $y*=70;
10 $x=round($x);
11 $y=round($y);
12 $str[]=$x;
13 $y=$y+2*(180-$y);//图像上下翻转
14 $x=$y;
15 $str[]=$x;
16 }
17 $im=imagecreate(400,400);//创建画布400*400
18 $black=imagecolorallocate($im,0,0,0);
19 $red=imagecolorallocate($im,255,0,0);//设置颜色
20 imagepolygon($im,$str,360,$red);
21 imagestring($im,5,190,190,"love",$red);//输出字符串
22 header('Content-type:image/gif');//通知浏览器输出的是gif图片
23 imagegif($im);//输出图片
24 imagedestroy($im);//销毁
25 ?>
输出效果: