PHP: <?php ########################## #一些极限方程函数的图像 # #PHP_Function_Draw v1.0 by echo"沙加" # # 2006-05-19 # # Nothing special. Just for Fun. # #math_function_1()#三叶玫瑰线 # #math_function_2()#阿基米德螺线 # #math_function_3()#心形线 # #math_function_4()#伯努利双曲线 # #math_function_5()#星形线 # # Nothing special. Just for Fun. # ########################## math_function_1(); function math_function_1()#三叶玫瑰线 { #设置参数 $n = 3; #设置叶片数 $m = 100; #控制大小 $height = 400; $width = 400; $im = imagecreatetruecolor($height,$width); $blue = imagecolorallocate ($im,0,0,64); $white = imagecolorallocate ($im,255,255,255); imagefill($im,0,0,$blue); #背景 for ($a=0;$a<=360;$a=$a+0.01) #循环一周 若累加数增大,将产生虚线效果 { $p = $m * sin($n*$a); #计算极坐标 $x = $p * cos($a) + $height/2; #转换为平面直角坐标,并平移至中心位置 $y = $p * sin($a)+ $width/2; imageline($im,$x,$y,$x,$y,$white); } #输出图像 header('content-type:image/png'); imagepng($im); #清理 inagedestory($im); } function math_function_2()#阿基米德螺线 { #设置参数 $m = 5; #控制大小 $height = 400; $width = 400; $im = imagecreatetruecolor($height,$width); $blue = imagecolorallocate ($im,0,0,64); $white = imagecolorallocate ($im,255,255,255); imagefill($im,0,0,$blue); #背景 for ($a=0;$a<=360;$a=$a+0.01) #循环一周 若累加数增大,将产生虚线效果 { $p = $m * $a; #计算极坐标 $x = $p * cos($a) + $height/2; #转换为平面直角坐标,并平移至中心位置 $y = $p * sin($a)+ $width/2; imageline($im,$x,$y,$x,$y,$white); } #输出图像 header('content-type:image/png'); imagepng($im); #清理 inagedestory($im); } function math_function_3()#心形线 { #设置参数 $m = 50; #控制大小 $height = 400; $width = 400; $im = imagecreatetruecolor($height,$width); $blue = imagecolorallocate ($im,0,0,64); $white = imagecolorallocate ($im,255,255,255); imagefill($im,0,0,$blue); #背景 for ($a=0;$a<=360;$a=$a+0.01) #循环一周 若累加数增大,将产生虚线效果 { $p = $m * (1-cos($a)); #计算极坐标 $x = $p * cos($a) + $height/2; #转换为平面直角坐标,并平移至中心位置 $y = $p * sin($a)+ $width/2; imageline($im,$x,$y,$x,$y,$white); } #输出图像 header('content-type:image/png'); imagepng($im); #清理 inagedestory($im); } function math_function_4()#伯努利双曲线 { #设置参数 $m = 10; #控制大小 $height = 400; $width = 400; $im = imagecreatetruecolor($height,$width); $blue = imagecolorallocate ($im,0,0,64); $white = imagecolorallocate ($im,255,255,255); imagefill($im,0,0,$blue); #背景 for ($a=0;$a<=360;$a=$a+0.01) #循环一周 若累加数增大,将产生虚线效果 { $p = sqrt ($a*$a * sin(2*$a) ); #计算极坐标 $x = $p * cos($a) + $height/2; #转换为平面直角坐标,并平移至中心位置 $y = $p * sin($a)+ $width/2; imageline($im,$x,$y,$x,$y,$white); } #输出图像 header('content-type:image/png'); imagepng($im); #清理 inagedestory($im); } function math_function_5()#星形线 { #设置参数 $m = 100; #控制大小 $height = 400; $width = 400; $im = imagecreatetruecolor($height,$width); $blue = imagecolorallocate ($im,0,0,64); $white = imagecolorallocate ($im,255,255,255); imagefill($im,0,0,$blue); #背景 for ($a=0;$a<=360;$a=$a+0.01) #循环一周 若累加数增大,将产生虚线效果 { //$p = $m / $a; #计算极坐标 $x = $m * cos($a)*cos($a)*cos($a) + $height/2; #转换为平面直角坐标,并平移至中心位置 $y = $m * sin($a)*sin($a)*sin($a)+ $width/2; imageline($im,$x,$y,$x,$y,$white); } #输出图像 header('content-type:image/png'); imagepng($im); #清理 inagedestory($im); } ?>