Heim >Backend-Entwicklung >PHP-Tutorial >趣味编程-php输出笛卡尔心形图案

趣味编程-php输出笛卡尔心形图案

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-20 12:39:201114Durchsuche

代码:

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<=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);

效果如下:

代码转自 博客

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn