PHP画矩形,椭圆,圆,画椭圆弧 ,饼状图
1:画矩形:
$image , int $x1 , int $y1 , int $x2 , int $y2 , int $col )imagerectangle() 用 col 颜色在 image 图像中画一个矩形,其左上角坐标为 x1, y1,右下角坐标为 x2, y2。图像的左上角坐标为 0, 0。
2:画椭圆:
imageellipse ( resource $image , int $cx , int $cy , int $width , int $height , int $color )
cx中间的 X 坐标。cy中间的 Y 坐标。width椭圆的宽度。height椭圆的高度。color椭圆的颜色。
3:画椭圆弧:
$image , int $cx , int $cy , int $w , int $h , int $s , int $e , int $color )(即在椭圆中截取一定的弧度)imagearc() 以 cx,cy(图像左上角为 0, 0)为中心在 image 所代表的图像中画一个椭圆弧。w 和 h 分别指定了椭圆的宽度和高度,起始和结束点以 s 和 e 参数以角度指定。0°位于三点钟位置,以顺时针方向绘画。
4:画饼状图:先循环画多个圆心在一条直线上的椭圆并填充
for($i=100;$i>50;$i--){
imagefilledarc($image, 150, $i, 150, 100, 0, 270, $gray,IMG_ARC_EDGED );
}
imagefilledarc ( resource $image , int $cx , int $cy , int $width , int $height , int $start , int $end , int $color , int $style )
cx:中间的 x 坐标。cy:中间的 y 坐标。width:椭圆弧的宽度。height:椭圆弧的高度。start:起点角度。end:终点角度。 0°color:颜色标识符。
style:
IMG_ARC_PIE :则产生圆形边界并填充IMG_ARC_CHORD :只是用直线连接了起始和结束点并填充IMG_ARC_NOFILL:则产生圆形边界不填充IMG_ARC_EDGED:指明用直线将起始和结束点与中心点相连
简单事例:
前台代码:
<div style="width:300px;height:400px;border:1px solid gray;margin:auto;">
<h2 style="text-align:center">全校学生分布统计</h2>
<center>
<form action="11Pro.php" method="post">
安徽:<input type="text" name="anhui"><br/>
浙江:<input type="text" name="zhejiang"><br/>
吉林:<input type="text" name="jilin"><br/>
北京:<input type="text" name="beijing"><br/><br/>
<input style="width:160px;" type="submit" value="生成饼状图"><br/>
<input style="width:160px;" type="reset" value="重置">
</form>
</center>
</div>
前台界面:

后台PHP代码:
<?php //创建画布
$image=imagecreatetruecolor(200,200); //定义颜色
$red=imagecolorallocate($image, 255, 0, 0);
$darkred=imagecolorallocate($image, 102, 0, 0); $blue=imagecolorallocate($image, 0, 0, 255);
$darkblue=imagecolorallocate($image, 0, 51, 102);; $green=imagecolorallocate($image, 0, 255, 0);
$darkgreen=imagecolorallocate($image, 51, 102, 51); $gray=imagecolorallocate($image, 125, 125, 125);
$darkgray=imagecolorallocate($image, 102, 102, 102); $anhui=$_POST['anhui'];
$jilin=$_POST['jilin'];
$beijing=$_POST['beijing'];
$zhejiang=$_POST['zhejiang']; $count=$anhui+$beijing+$jilin+$zhejiang; //循环画饼状图
for($i=100;$i>85;$i--){
imagefilledarc($image, 100, $i, 150, 100, 0, ($anhui/$count)*360, $darkgray, IMG_ARC_PIE);
imagefilledarc($image, 100, $i, 150, 100, ($anhui/$count)*360, (($anhui+$jilin)/$count)*360, $darkblue, IMG_ARC_PIE);
imagefilledarc($image, 100, $i, 150, 100, (($anhui+$jilin)/$count)*360, (($anhui+$jilin+$beijing)/$count)*360, $darkgreen, IMG_ARC_PIE);
imagefilledarc($image, 100, $i, 150, 100, (($anhui+$jilin+$beijing)/$count)*360, 360, $darkred, IMG_ARC_PIE);
}
imagefilledarc($image, 100, 85, 150, 100, 0, ($anhui/$count)*360, $gray, IMG_ARC_PIE);
imagefilledarc($image, 100, 85, 150, 100, ($anhui/$count)*360, (($anhui+$jilin)/$count)*360, $blue, IMG_ARC_PIE);
imagefilledarc($image, 100, 85, 150, 100, (($anhui+$jilin)/$count)*360, (($anhui+$jilin+$beijing)/$count)*360, $green, IMG_ARC_PIE);
imagefilledarc($image, 100, 85, 150, 100, (($anhui+$jilin+$beijing)/$count)*360, 360, $red, IMG_ARC_PIE); header("Content-type: image/png"); imagepng($image); imagedestroy($image); ?>
后台处理结果:

PHP画矩形,椭圆,圆,画椭圆弧 ,饼状图的更多相关文章
- PHP imagearc - 画椭圆弧
imagearc — 用于画椭圆弧.高佣联盟 www.cgewang.com 语法 bool imagearc ( resource $image , int $cx , int $cy , int ...
- canvas+js画饼状图
效果: 源码: <!DOCTYPE html> <html lang="en"> <head> <meta charset="U ...
- 利用Tkinter和matplotlib两种方式画饼状图
当我们学习python的时候,总会用到一些常用的模块,接下来我就详细讲解下利用两种不同的方式画饼状图.首先利用[Tkinter]中的canvas画布来画饼状图: from tkinter import ...
- vue中使用echarts画饼状图
echarts的中文文档地址:https://echarts.baidu.com/tutorial.html#5%20%E5%88%86%E9%92%9F%E4%B8%8A%E6%89%8B%20EC ...
- PHP实现动态生成饼状图 (转载)
<?php //变量定义,画椭圆弧时的角度大小 define("ANGLELENGTH", 10); /** * 绘制图片 * @param $title 3D图的标题 * ...
- 自定义View饼状图的绘制
package com.loaderman.customviewdemo; import android.content.Context; import android.graphics.Canvas ...
- canvas图表详解系列(3):动态饼状图(原生Js仿echarts饼状图)
本章建议学习时间4小时 学习方式:详细阅读,并手动实现相关代码(如果没有canvas基础,需要先学习前面的canvas基础笔记) 学习目标:此教程将教会大家如何使用canvas绘制各种图表,详细分解步 ...
- iOS:使用贝塞尔曲线绘制图表(折线图、柱状图、饼状图)
1.介绍: UIBezierPath :画贝塞尔曲线的path类 UIBezierPath定义 : 贝赛尔曲线的每一个顶点都有两个控制点,用于控制在该顶点两侧的曲线的弧度. 曲线的定义有四个点:起始点 ...
- WPF 饼状图,柱形图,折线图 (3 饼状图)
网址:https://www.cnblogs.com/CSSZBB/p/12746214.html 饼状图相对来说复杂一些.因为需要计算很多坐标,线来看下这个列子. 圆首先想到Ellipse.但是El ...
随机推荐
- 利用python的requests发送http请求
>>> from requests import put, get >>> put('http://localhost:5000/todo1', data={'da ...
- spring proxy-target-class
<tx:annotation-driven transaction-manager="transactionManager" ...
- 小强学渲染之OpenGL渲染管线详析
什么是OpenGL? OpenGL是一套图形硬件的软件API接口库,它直接和GPU交互,将3D场景渲染绘制到2D屏幕上.总结说,OpenGL的功能是将程序中定义的各种2D或3D模型绘制到帧缓存中,或者 ...
- PCIe 驱动流程(LTSSM)
本次的工作是完成刚流片的FPGA中PCIe IP核的bring up,也就是芯片的中PCIe的第一个使用者,将PCIe IP核正常使用起来,并配合公司的EDA团队,完成PCIe IP核到用户的呈现. ...
- tab页
图片: 代码: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <t ...
- 698. Partition to K Equal Sum Subsets 数组分成和相同的k组
[抄题]: Given an array of integers nums and a positive integer k, find whether it's possible to divide ...
- Percentage&Last zero&Convert from char to float
Percentage g_rate = wg_header-rate. condense g_rate. SHIFT g_rate RIGHT DELETING TRAILING '0'. REPLA ...
- SD
Offer(Tcode:VA23;Table: vbak and vbap) billing(Tcode:VF03;Table:vbrk and vbrp) Offer(quotation)-> ...
- Java 后台验证的工具类
Java 后台验证的工具类 public class ValidationUtil { //手机号 public static String mobile = "^( ...
- 49-Python 安装pythoncom库和pyHook
这个直接用pip不行,所以借鉴了别人的方法: YTouchCoder 1. https://sourceforge.net/projects/pywin32/files/pywin32/ 这里面下载p ...