用代码画了个足球场

原图:

代码画出的效果图:

代码如下:

// 创建一个 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);

php代码画足球场的更多相关文章

  1. ReportMachine 自定义代码 画细线

    ReportMachine 自定义代码 画细线 procedure Memo3_OnBeforePrint(Sender: TObject); begin Memo3.Text := inttostr ...

  2. 程序员式优雅表白,教你用python代码画爱心

    还能用python代码画爱心?还有这种操作?这是什么原理? 不相信python代码可以画爱心?先来一张效果图来看看效果吧! 用python代码画爱心的思路是怎样的? 1.怎么画心形曲线 2.怎么填满心 ...

  3. android 用代码画虚线边框背景(转)

    1.虚线画效果,可以使用Android中的xml来做. 2.直接上代码: <RelativeLayout android:id="@+id/coupon_popup" and ...

  4. 20行以内python代码画出各种减压图

    一.太阳花 看到一个很有意思的代码,你若安好,便是晴天!太阳花向你开~ 绘画效果如下: 代码如下: from turtle import * color('red', 'yellow') begin_ ...

  5. android 用代码画虚线边框背景

                   1.虚线画效果,可以使用Android中的xml来做. 2.直接上代码: <RelativeLayout android:id="@+id/coupon_ ...

  6. Android通过用代码画虚线椭圆边框背景来学习一下shape的用法

    在Android程序开发中,我们经常会去用到Shape这个东西去定义各种各样的形状,shape可以绘制矩形环形以及椭圆,所以只需要用椭圆即可,在使用的时候将控件比如imageview或textview ...

  7. 使用canvas 代码画小猪佩奇

    最近不是小猪佩奇很火嘛!!! 前几天 在知乎 看见了别人大佬用python写的 小猪佩奇,  顿时想学 ,可是 自己 没学过python(自己就好爬爬图片,,,,几个月没用 又丢了) 然后 就想画一个 ...

  8. html5 代码画兰博基尼跑车,6不6你说的算!

    源代码下方 由于本人喜爱html5,无聊所画: 画图需要掌握; 1.画布,画笔,画圆,给画笔添加颜色.(注:掌握这几点,你就可以称霸画图界了.) 虽然没有画画天赋,但代码写的也是溜溜滴!(注:此图没有 ...

  9. PlantUml 使用代码画各种图

    资源 网址 官方github https://github.com/plantuml/plantuml 官方网站 http://plantuml.com/zh/ mac 下,webstorm 中使用 ...

随机推荐

  1. 【经典】5种IO模型 | IO多路复用

    上篇回顾:静态服务器+压测 3.2.概念篇 1.同步与异步 同步是指一个任务的完成需要依赖另外一个任务时,只有等待被依赖的任务完成后,依赖的任务才能算完成. 异步是指不需要等待被依赖的任务完成,只是通 ...

  2. mysql 正则表达式判断是否数字

    select ('123a' REGEXP '[^0-9.]'); --‘123a'中含有字符'a' 输出结果为1 mysql中常量true输出为1 false输出为0

  3. eclipse实现代码块折叠-类似于VS中的#region……#endregion

    背 景 刚才在写代码的时候,写了十几行可以说是重复的代码: 如果整个方法或类中代码多了,感觉它们太TM占地方了,给读者在阅读代码上造成很大的困难,于是想到能不能把他们“浓缩”成一行,脑子里第一个闪现出 ...

  4. GBK转UTF8

    shell 脚本自动GBK转UTF8 for i in `find . -name "*.java"`; do iconv -f gbk -t utf-8 $i > $i.n ...

  5. webpack 配置缓存

    1.输出文件的文件名 加hash 2.提取引导模板 3.模块标识符 https://webpack.docschina.org/guides/caching/#src/components/Sideb ...

  6. mysql string 列类型

    CHAR和VARCHAR CHAR和VARCHAR类型声明的长度表示你想要保存的最大字符数 char 0~255 尾部填充空格到指定长度,检索时自动去掉空格. varchar 0~65535 VARC ...

  7. python两个 list 获取交集,并集,差集的方法

    1. 获取两个list 的交集 #方法一: a=[2,3,4,5] b=[2,5,8] tmp = [val for val in a if val in b] print tmp #[2, 5] # ...

  8. 从yield 到yield from再到python协程

    yield 关键字 def fib(): a, b = 0, 1 while 1: yield b a, b = b, a+b yield 是在:PEP 255 -- Simple Generator ...

  9. Atitit 押金危机 如何防止用户挤兑

    Atitit 押金危机 如何防止用户挤兑 1.1. 用户的押金一定要及时退还,最好实时,避免用户恐慌导致挤兑.. 1 1.2. 退押金有手续费怎么办,最好和用户说明,从用户手机扣缴..不要因小失大.. ...

  10. Eclipse安装Git插件及简单操作

    0. 前言 说一件事,说起来也是好笑,工作三年半了,还没接触到团队开发,都是一个人小打小闹.因此连Git都没有使用过.感觉好Low的,这一篇,简单讲一下,Eclipse配置Git插件,并提交代码到Gi ...