用代码画了个足球场

原图:

代码画出的效果图:

代码如下:

// 创建一个 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. SpringBoot无废话入门04:MyBatis整合

    1.Parent引入及pom配置 首先,如果要支持mybatis,那么我们就应该引入mybatis的starter.同时,由于连接本身还需要用jdbc的connetor和连接池,所以一并需要引入这些依 ...

  2. leetcode 566. 重塑矩阵 c++ 实现

    1.问题描述: 在MATLAB中,有一个非常有用的函数 reshape,它可以将一个矩阵重塑为另一个大小不同的新矩阵,但保留其原始数据. 给出一个由二维数组表示的矩阵,以及两个正整数r和c,分别表示想 ...

  3. 分布式环境中,模块数据交互协议分析 (百度brpc)

    1. 背景 之前听到同事说,要为自己的模块考虑写个数据协议.今天有空想了一下.写出来,方便后续使用. 开源代码brpc中可以支持多种协议,nshead.redis.mongo等20多种协议. 2. 什 ...

  4. 如何确定Isilon cluster的网卡类型是40GbE的还是10GbE的

    可以使用isi upgrade cluster firmware devices命令. 从命令行输出可以看到,当前的cluster使用的是40G的前端网卡. 如果是10G网卡,输出结果应当是如下的样子 ...

  5. ECharts JS应用:图表页面实现

    因为要统计数据进行图表展示,所以就简单学习了 ECharts JS 的应用.它是一个纯Javascript图库,它依赖于一个轻量级的Canvas库 ZRender,并提供直观.生动.交互式和高度可定制 ...

  6. Redis】Java中使用Jedis操作Redis(Maven导入包)、创建Redis连接池

    如果我们使用Java操作Redis, 需要确保已经安装了 redis 服务及 Java redis 驱动. Maven项目可以直接在pom.xml中加入jedis包驱动: <!-- https: ...

  7. CentOS 7.4nginx配置SSL

    一.在/etc/nginx/conf.d目录下创建虚拟主机配置文件 server { listen 80; server_name www.xx.com xx.com; return 301 http ...

  8. Android中的指纹识别

    转载请注明出处:http://blog.csdn.net/wl9739/article/details/52444671 评论中非常多朋友反映,依据我给出的方案,拿不到指纹信息这个问题,在这里统一说明 ...

  9. ComputeShader中Consume与AppendStructuredBuffer的使用

    上个月写了一篇使用像素shader返回累加信息的Trick:https://www.cnblogs.com/hont/p/9977401.html 后来无意中发现DX11/Compute shader ...

  10. Git秘钥生成以及Gitlab配置(附以下问题解决方法:Key is invalid Fingerprint cannot be generated)

    在进行Git密钥配置时,总是提示: “The form contains the following errors:Key is invalidFingerprint cannot be genera ...