Home  >  Article  >  Backend Development  >  利用php输出不同的心形图案,php心形图案_PHP教程

利用php输出不同的心形图案,php心形图案_PHP教程

WBOY
WBOYOriginal
2016-07-12 08:53:511778browse

利用php输出不同的心形图案,php心形图案

首先为大家分享php输出心形曲线的代码,代码如下

<&#63;php
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,0,0,0);
 $red=imagecolorallocate($im,255,0,0);//设置颜色
 imagepolygon($im,$str,360,$red);
 imagestring($im,5,190,190,"love",$red);//输出字符串
 header('Content-type:image/gif');//通知浏览器输出的是gif图片
 imagegif($im);//输出图片
 imagedestroy($im);//销毁
&#63;>

效果如下:

利用php输出笛卡尔心形图案,代码如下

复制代码 代码如下:$width = 600; $height = 650; header("Content-type: image/gif"); $img = imagecreate($width,$height);//创建一张图片 $bg color = imagecolorallocate($img,0,0,0); $red = imagecolorallocate($img,255,0,0); for($i=0;$i

$width = 600;$height = 650;header("Content-type: image/gif");$img = imagecreate($width,$height);//创建一张图片$bg_color = imagecolorallocate($img,0,0,0);$red = imagecolorallocate($img,255,0,0);for($i=0;$i

以上就是本文的全部内容,希望对大家的学习有所帮助。

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1122890.htmlTechArticle利用php输出不同的心形图案,php心形图案 首先为大家分享 php输出心形曲线 的代码,代码如下 phpfor($t=0;$t360;$t++){ $y=2*cos($t)-cos(2*$t); //笛卡尔...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn