手机版

利用服务器端编程语言(专业超文本预处理器的缩写)输出不同的心形图案

时间:2021-11-03 来源:互联网 编辑:宝哥软件园 浏览:

首先为大家分享服务器端编程语言(专业超文本预处理器的缩写)输出心形曲线的代码,代码如下

?PHP for($ t=0;$ t360 $ t){ $ y=2 * cos($ t)-cos(2 * $ t);//笛卡尔心形曲线函数$ x=2 * sin($ t)-sin(2 * $ t);$ x=3;$ y=3;$ x *=70$ y *=70$ x=圆形($ x);$ y=圆形($ y);$ str[]=$ x;$ y=$ y 2 *(180-$ y);//图像上下翻转$ x=$ y;$ str[]=$ x;} $im=imagecreate(400,400);//创建画布400 * 400 $ black=image color allocate($ im,0,0,0);$red=imagecolorallocate($im,255,0,0);//设置颜色imagepolygon($im,$str,360,$ red);imagestring($im,5,190,190,' love ',$ red);//输出字符串标题(“内容类型:图像/gif”);//通知浏览器输出的是可交换的图像格式图片imagegif($ im);//输出图片图像销毁($ im);//销毁?效果如下:

利用服务器端编程语言(专业超文本预处理器的缩写)输出笛卡尔心形图案,代码如下

复制代码代码如下:美元宽度=600;$高度=650标题(“内容类型:图像/gif”);$img=imagecreate($width,$ height);//创建一张图片$ BG color=image color allocate($ img,0,0,0);$red=imagecolorallocate($img,255,0,0);对于($ 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);图像销毁($ img);

$宽度=600$高度=650标题(“内容类型:图像/gif”);$img=imagecreate($width,$ height);//创建一张图片$ BG _ color=image color allocate($ img,0,0,0);$red=imagecolorallocate($img,255,0,0);对于($ 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);图像销毁($ img);

以上就是本文的全部内容,希望对大家的学习有所帮助。

版权声明:利用服务器端编程语言(专业超文本预处理器的缩写)输出不同的心形图案是由宝哥软件园云端程序自动收集整理而来。如果本文侵犯了你的权益,请联系本站底部QQ或者邮箱删除。