创建画布并画一个圆

来源:互联网 发布:网络兼职打字录入员 编辑:程序博客网 时间:2024/06/10 05:02
<?php$image = imagecreatetruecolor(1000, 1000);//创建画布的大小1000x1000/** * 设置图像中所需要的颜色,相当于在画画时准备的染料 * @var Ambiguous $white */$white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF);        //白色$gray = imagecolorallocate($image, 0xC0, 0xC0, 0xC0);         //灰色$darkgray = imagecolorallocate($image, 0x90, 0x90, 0x90);     //暗灰色$navy = imagecolorallocate($image, 0x00, 0x00, 0x80);         //深蓝色$darknavy = imagecolorallocate($image, 0x00, 0x00, 0x50);     //暗蓝色$red = imagecolorallocate($image, 0xFF, 0x00, 0x00);          //红色$darkred = imagecolorallocate($image, 0x90, 0x00, 0x00);      //暗红色imagefill($image,0,0,$white);//为画布填充背景颜色for($i = 600;$i>500;$i--){    /**     * 画三个椭圆弧     */    imagefilledarc($image, 500, $i, 1000, 500, -160, 40, $darknavy, IMG_ARC_PIE);    imagefilledarc($image, 500, $i, 1000, 500, 40, 75, $darkgray, IMG_ARC_PIE);    imagefilledarc($image, 500, $i, 1000, 500, 75, 200, $darkred, IMG_ARC_PIE);}imagefilledarc($image, 500, 500, 1000, 500, -160, 40, $navy, IMG_ARC_PIE);imagefilledarc($image, 500, 500, 1000, 500, 40, 75, $gray, IMG_ARC_PIE);imagefilledarc($image, 500, 500, 1000, 500, 75, 200, $red, IMG_ARC_PIE);/** * 画三行字符 */imagestring($image, 10, 150, 550, '34.7%', $white);imagestring($image, 10, 450, 350, '55.5%', $white);imagestring($image, 10, 650, 650, '9.8%', $white);/** * 向浏览器输出一个png格式的图片 */header('Content-type:image/png');imagepng($image);imagedestroy($image);  //销毁图像释放资源

下面是效果:
这里写图片描述

0 0
原创粉丝点击