用代码画了个足球场

原图:

代码画出的效果图:

代码如下:

// 创建一个 200X200 的图像
$img = imagecreate(800, 500); // 分配颜色
$bg = imagecolorallocate($img, 0, 120, 0);
$white = imagecolorallocate($img, 255, 255, 255);
$black = imagecolorallocate($img, 0, 0, 0); // 填充背景色
imagefill($img, 800, 500, $bg); // 画线
// 四边
imageline($img, 25, 25, 775, 25, $white);
imageline($img, 25, 475, 775, 475, $white);
imageline($img, 25, 25, 25, 475, $white);
imageline($img, 775, 25, 775, 475, $white); // 中分线
imageline($img, 400, 25, 400, 475, $white);
// 中分点
imagesetpixel($img, 400, 250, $white);
imagesetpixel($img, 399, 250, $white);
imagesetpixel($img, 401, 250, $white);
imagearc($img, 400, 250, 4, 4, 0, 360, $white);
// 中分圆
imagearc($img, 400, 255, 150, 150, 0, 360, $white); // 左球门
imageline($img, 25, 175, 65, 175, $white);
imageline($img, 25, 325, 65, 325, $white);
imageline($img, 65, 175, 65, 325, $white);
imageline($img, 25, 105, 155, 105, $white);
imageline($img, 25, 395, 155, 395, $white);
imageline($img, 155, 105, 155, 395, $white);
imagesetpixel($img, 120, 250, $white);
imagearc($img, 120, 250, 4, 4, 0, 360, $white);
imagearc($img, 155, 250, 50, 125, 270, 450, $white); // 右球门
imageline($img, 735, 175, 775, 175, $white);
imageline($img, 735, 325, 775, 325, $white);
imageline($img, 735, 175, 735, 325, $white);
imageline($img, 775, 105, 650, 105, $white);
imageline($img, 775, 395, 650, 395, $white);
imageline($img, 650, 105, 650, 395, $white);
imagesetpixel($img, 680, 250, $white);
imagearc($img, 680, 250, 4, 4, 0, 360, $white);
imagearc($img, 650, 250, 50, 125, 90, 270, $white); // 两边小长方形
imageline($img, 25, 225, 20, 225, $white);
imageline($img, 25, 275, 20, 275, $white);
imageline($img, 20, 225, 20, 275, $white);
imageline($img, 775, 225, 780, 225, $white);
imageline($img, 775, 275, 780, 275, $white);
imageline($img, 780, 225, 780, 275, $white); // 四个角
imagearc($img, 25, 25, 23, 23, 0, 90, $white);
imagearc($img, 775, 25, 23, 23, 90, 180, $white);
imagearc($img, 25, 475, 23, 23, 270, 360, $white);
imagearc($img, 775, 475, 23, 23, 180, 270, $white); // 将图像输出到浏览器
header("Content-type: image/png");
imagepng($img);
// 释放内存
imagedestroy($img);

最新文章

  1. Android中ListView实现图文并列并且自定义分割线(完善仿微信APP)
  2. Excel 取得一定范围内最大的有值的行号
  3. impdp报错: ORA-39064: 无法写入日志文件 ORA-29285: 文件写入错误
  4. [ZZ]良好的编码习惯
  5. poj1741 bzoj2152
  6. bzoj 1787 [Ahoi2008]Meet 紧急集合(1832 [AHOI2008]聚会)
  7. 一致性hash
  8. codeforces 569A Music
  9. WPF界面设计技巧(10)-样式的继承
  10. 苹果新的编程语言 Swift 语言进阶(十二)--选项链
  11. 学习dos命令行总结
  12. Flink入门使用
  13. centos安装jenkins
  14. pta总结3
  15. java web(二): servlet的简单使用和介绍
  16. Django models中关于blank与null的补充说明
  17. 【NOIP2017D2T3】列队
  18. json序列化 & 反序列化
  19. python读取两个csv文件数据,进行查找匹配出现次数
  20. myeclipse debug模式 报错source not found

热门文章

  1. [Java代码] Java用pinyin4j根据汉语获取各种格式和需求的拼音
  2. idea的debug模式启动运行慢
  3. 简单了解weblogic配置文件
  4. centos找不到环境变量 -bash: ls: command not found
  5. Dubbo接口压测
  6. 【JavaScript 插件】图片展示插件 PhotoSwipe 初识
  7. tmunx error:invalid option: status-utf8 invalid option: utf8
  8. 【PMP】商业论证与效益管理文件
  9. 阿里云物联网平台体验(树莓派+Nodejs篇)
  10. sqlite3常用技巧