用PHP的GD库画的两个几何图
Jun 23, 2016 pm 01:25 PM
//code6.php 没有函数化
<?php header("Content-type:image/png");$img=imagecreatetruecolor(400, 400);$black=imagecolorallocate($img, 0, 0, 0);$red=imagecolorallocate($img, 255, 0, 0);$green=imagecolorallocate($img, 0, 255, 0);$blue=imagecolorallocate($img, 0, 0, 255);imagefill($img, 0, 0, $black);imageline($img, 0, 0, 400, 400, $green);imageline($img, 40, 0, 400, 400, $green);imageline($img, 80, 0, 400, 400, $green);imageline($img, 120, 0, 400, 400, $green);imageline($img, 160, 0, 400, 400, $green);imageline($img, 200, 0, 400, 400, $green);imageline($img, 240, 0, 400, 400, $green);imageline($img, 280, 0, 400, 400, $green);imageline($img, 320, 0, 400, 400, $green);imageline($img, 360, 0, 400, 400, $green);imageline($img, 390, 0, 400, 400, $green);imageline($img, 0, 40, 400, 400, $green);imageline($img, 0, 80, 400, 400, $green);imageline($img, 0, 120, 400, 400, $green);imageline($img, 0, 160, 400, 400, $green);imageline($img, 0, 200, 400, 400, $green);imageline($img, 0, 240, 400, 400, $green);imageline($img, 0, 280, 400, 400, $green);imageline($img, 0, 320, 400, 400, $green);imageline($img, 0, 360, 400, 400, $green);imageline($img, 0, 390, 400, 400, $green);imageline($img, 0, 400, 400, 0, $green);imageline($img, 0, 400, 400, 40, $green);imageline($img, 0, 400, 400, 80, $green);imageline($img, 0, 400, 400, 120, $green);imageline($img, 0, 400, 400, 160, $green);imageline($img, 0, 400, 400, 200, $green);imageline($img, 0, 400, 400, 240, $green);imageline($img, 0, 400, 400, 280, $green);imageline($img, 0, 400, 400, 320, $green);imageline($img, 0, 400, 400, 360, $green);imageline($img, 0, 400, 400, 390, $green);imageline($img, 0, 400, 360, 0, $green);imageline($img, 0, 400, 320, 0, $green);imageline($img, 0, 400, 280, 0, $green);imageline($img, 0, 400, 240, 0, $green);imageline($img, 0, 400, 200, 0, $green);imageline($img, 0, 400, 160, 0, $green);imageline($img, 0, 400, 120, 0, $green);imageline($img, 0, 400, 80, 0, $green);imageline($img, 0, 400, 40, 0, $green);imageline($img, 0, 400, 10, 0, $green);imagepng($img);?>
登录后复制
//code7.php 函数化处理
<?php header("Content-type:image/png");$img=imagecreatetruecolor(400, 400);$black=imagecolorallocate($img, 0, 0, 0);$red=imagecolorallocate($img, 255, 2550, 0);$green=imagecolorallocate($img, 0, 255, 0);$blue=imagecolorallocate($img, 0, 0, 255);imagefill($img, 0, 0, $black);for($i=0;$i<=400;$i+=10){imageline($img, 0, $i, 200, 200, $red);}for($j=0;$j<=400;$j+=20){imageline($img, $j, 0, 200, 200, $red);}for($x=0;$x<=400;$x+=10){imageline($img, 200, 200, 400, $x, $red);}for($y=0;$y<=400;$y+=20){imageline($img, 200, 200, $y, 400, $red);}imagepng($img);?>
登录后复制
//code6.png
//code7.png
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热门文章
仓库:如何复兴队友
3 周前
By 尊渡假赌尊渡假赌尊渡假赌
击败分裂小说需要多长时间?
3 周前
By DDD
R.E.P.O.能量晶体解释及其做什么(黄色晶体)
1 周前
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island冒险:如何获得巨型种子
3 周前
By 尊渡假赌尊渡假赌尊渡假赌
公众号网页更新缓存难题:如何避免版本更新后旧缓存影响用户体验?
3 周前
By 王林

热门文章
仓库:如何复兴队友
3 周前
By 尊渡假赌尊渡假赌尊渡假赌
击败分裂小说需要多长时间?
3 周前
By DDD
R.E.P.O.能量晶体解释及其做什么(黄色晶体)
1 周前
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island冒险:如何获得巨型种子
3 周前
By 尊渡假赌尊渡假赌尊渡假赌
公众号网页更新缓存难题:如何避免版本更新后旧缓存影响用户体验?
3 周前
By 王林

热门文章标签

记事本++7.3.1
好用且免费的代码编辑器

SublimeText3汉化版
中文版,非常好用

禅工作室 13.0.1
功能强大的PHP集成开发环境

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)