使用PHP输出不同的心脏模式

使用PHP输出不同的心脏模式
首先,分享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);
以上是本文的全部内容,希望能对大家有所帮助。
免责声明:本网信息来自于互联网,目的在于传递更多信息,并不代表本网赞同其观点。其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,并请自行核实相关内容。本站不承担此类作品侵权行为的直接责任及连带责任。如若本网有任何内容侵犯您的权益,请及时联系我们,本站将会在24小时内处理完毕。
相关文章
返回顶部