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

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-20 12:39:20
Original
1098 people have browsed it

代码:

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);
Copy after login

效果如下:

代码转自 博客

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template