用代码画了个足球场

原图:

代码画出的效果图:

代码如下:

// 创建一个 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. 微信小程序中遮罩层的滚动穿透问题

    如果弹出层没有滚动事件: <view wx:if="{{alert}}" catchtouchmove="myCatchTouch"> <te ...

  2. [原创]AndroBugs_Framework Android漏洞扫描器介绍

    [原创]AndroBugs_Framework Android漏洞扫描器介绍 1 AndroBugs_Framework Android 漏洞扫描器简介 一款高效的Android漏洞扫描器,可以帮助开 ...

  3. C#隐藏手机号中间四位为*

    使用正则:Regex.Replace(手机号, "(\\d{3})\\d{4}(\\d{4})", "$1****$2"); 效果:

  4. mssql f_Split

    mssql可以如下CREATE FUNCTION [dbo].[f_Split] ( @val varchar(max),@Splits varchar(100))RETURNS @Table TAB ...

  5. OpenSceneGraphic 着色器中数组的应用【转】

    https://blog.csdn.net/zsq306650083/article/details/50533480 //osg的写法osg::ref_ptr<osg::StateSet> ...

  6. Javascript正则表达入参是null

    今天群友问了一个问题,如下的执行结果是什么? var reg = /^[a-z0-9\u4e00-\u9fa5]{0,15}$/; console.log(reg.test(null)); // tr ...

  7. Django根据现有数据库建立/更新model

    Django引入外部数据库还是比较方便的,步骤如下: 创建一个项目,修改seting文件,在setting里面设置你要连接的数据库类型和连接名称,地址之类,和创建新项目的时候一致 运行下面代码可以自动 ...

  8. 实时查看docker容器日志

    实时查看docker容器日志 $ sudo docker logs -f -t --tail 行数 容器名 例:实时查看docker容器名为s12的最后10行日志 $ sudo docker logs ...

  9. edis更新的正确方法

    Redis更新的正确方法 https://www.cnblogs.com/westboy/p/8696607.html redis做缓存,怎么更新里面的数据 https://blog.csdn.net ...

  10. Docker中部署Mysql5.7和DbAdmin的docker-compose.yml

    一.简述 本文讲Docker通过docker-compose.yml部署Mysql5.7和dbAdmin的方法. 二.文件 1.docker-compose.yml内容如下: version: ' s ...