首先,
分享PHP输出的心脏曲线代码,代码如下
< PHP
为($ = 0;$ t 360;$ + +)
{
$ y = 2 * COS($ T)- COS(2×T);
$ x = 2 **($)-罪(2 * t);
$ x=3;
$ y=3;
$ x=70;
$ y=70;
x =圆(x);
$ =圆(y);
$ x = $ x;
$ y = $ y + 2 *(180 - $ y); /图像。
$ x = y;
$ x = $ x;
}
$我=画面欣赏(400400); / /
创建一个画布400×400
黑imagecolorallocate美元($ IM,0,0,0);
红色= imagecolorallocate美元(合我,255,0,0); / /颜色
设置 imagepolyn($ IM,$str,美元360,红色);
imagestring($ 5190190美元,我,爱,红色); / /输出字符串
头('content-type:图像/ GIF); / /通知
浏览器输出GIF
图片 imagegif(为我); / /输出。
销毁一图像($ IM); / /破坏
>
结果如下:
使用PHP输出Descartes的心脏
模式,代码如下所示
Copy the code as follows: $width = 600; $height = 650; header (Content-type: image/gif); $img = imagecreate ($width, $height); / / create a picture of $bg color = imagecolorallocate ($img, 0,0,0); $red = imagecolorallocate ($img, 255,0,0); for ($i=0; $i<=100; $i++) {for ($j=0; $j<=100; $j++) {$r M = PI/50 * $i (1-sin (M_PI/50 $j) 40); $x = $r cos (M PI/50 $j) sin (M PI/50 $i) +$width/2; $y = -$r sin (M_PI/50*$j) +$height/6; imagesetpixel ($img, $x, $y, $red (imagegif);}} $img imagedestroy ($img));
$width = 600; $height = 650; header (Content-type: image/gif); $img = imagecreate ($width, $height); / / create a picture of $bg_color = imagecolorallocate ($img, 0,0,0); $red = imagecolorallocate ($img, 255,0,0); for ($i=0; $i<= 100; $i++) {for ($j=0; $j<=100; $j++ * (M_PI/50*$i) {$r = 1-sin (M_PI/50*$j)) *40; $x = $r *cos (M_PI/50*$j) *sin (M_PI/50*$i) +$width/2; $y = -$r*sin (M_PI/50*$j) +$height/6; imagesetpixel ($img, $x, $y, $red);}}imagegif ($IMG); imagedestroy ($img);
以上是本文的全部内容,希望能对大家有所帮助。