PHP制作3D扇形统计图以及对图片进行缩放操作实例,
1、利用php gd库的函数绘制3D扇形统计图
header("content-type","text/html;charset=utf-8");<br>/*扇形统计图*/<br>$image = imagecreatetruecolor(100, 100); /*创建画布*/<br>/*设置画布需要的颜色*/<br>$white = imagecolorallocate($image,0xff,0xff,0xff);<br>$gray = imagecolorallocate($image, 0xc0, 0xc0, 0xc0);<br>$darkgray = imagecolorallocate($image, 0x90, 0x90, 0x90);<br>$navy = imagecolorallocate($image, 0x00, 0x00, 0x80);<br>$darknavy = imagecolorallocate($image, 0x00, 0x00, 0x50);<br>$red = imagecolorallocate($image, 0xff, 0x00, 0x00);<br>$darkred = imagecolorallocate($image, 0x90, 0x00, 0x00);<br>/*填充背景色*/<br>imagefill($image, 0, 0, $white);<br>/*3D制作*/<br>for($i = 60; $i > 50; $i--)<br>{<br>imagefilledarc($image, 50, $i, 100, 50, -160, 40, $darknavy, IMG_ARC_PIE);<br>imagefilledarc($image, 50, $i, 100, 50, 40, 75, $darkgray, IMG_ARC_PIE);<br>imagefilledarc($image, 50, $i, 100, 50, 75, 200, $darkred, IMG_ARC_PIE);<br>}<br>/*画椭圆弧并填充*/<br>imagefilledarc($image, 50, 50, 100, 50, -160, 40, $darknavy, IMG_ARC_PIE);<br>imagefilledarc($image, 50, 50, 100, 50, 40, 75, $darkgray, IMG_ARC_PIE);<br>imagefilledarc($image, 50, 50, 100, 50, 75, 200, $darkred, IMG_ARC_PIE);<br>/*画字符串*/<br>imagestring($image, 3, 15, 55, "30%", $white);<br>imagestring($image, 3, 45, 35, "60%", $white);<br>imagestring($image, 3, 60, 60, "10%", $white);<br>/*输出图像*/<br>header("content-type:image/png");<br>imagepng($image);<br>/*释放资源*/<br>imagedestroy($image);<br>?>
效果:
2、对图片进行缩放
<div> <br><h4 id="原图大小">原图大小</h4> <br><img src="/static/imghwm/default1.png" data-src="1.png" class="lazy" alt="PHP制作3D扇形统计图以及对图片进行缩放操作实例," ><br> </div><br>header("content-type","text/html;charset=utf-8");<br>/*<br>*图片缩放<br>*@param string $filename 图片的url<br>*@param int $width 设置图片缩放的最大宽度<br>*@param int $height 设置图片缩放的最大高度<br>*/<br>function thumb($filename,$width=130,$height=130)<br>{<br>/*获取原图的大小*/<br>list($width_orig,$height_orig) = getimagesize($filename);<br>/*根据参数$width和$height,换算出等比例的高度和宽度*/<br>if($width && ($width_orig {<br>$width = ($height / $height_orig) * $width_orig;<br>}<br>else<br>{<br>$height = ($width / $width_orig) * $height_orig;<br>}<br>/*以新的大小创建画布*/<br>$image_p = imagecreatetruecolor($width, $height);<br>/*获取图像资源*/<br>$image = imagecreatefrompng($filename);<br>/*使用imagecopyresampled缩放*/<br>imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);<br>/*保存缩放后的图片和命名*/<br>imagepng($image_p,'test.png');<br>/*释放资源*/<br>imagedestroy($image_p);<br>imagedestroy($image);<br>}<br>/*调用函数*/<br>thumb('1.png');<br>?><br><div> <br><h4 id="缩放后的大小">缩放后的大小</h4> <br><img src="/static/imghwm/default1.png" data-src="test.png" class="lazy" alt="PHP制作3D扇形统计图以及对图片进行缩放操作实例," ><br> </div>
效果:

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Linux new version
SublimeText3 Linux latest version
