Php/docs/function.imagefilledarc
imagefilledarc
(PHP 4 >= 4.0.6, PHP 5, PHP 7)
imagefilledarc — 画一椭圆弧且填充
说明
imagefilledarc
( resource $image
, int $cx
, int $cy
, int $width
, int $height
, int $start
, int $end
, int $color
, int $style
) : bool
在指定的 image 上画一椭圆弧且填充。
参数
image由图象创建函数(例如imagecreatetruecolor())返回的图象资源。
cx中间的 x 坐标。
cy中间的 y 坐标。
width椭圆弧的宽度。
height椭圆弧的高度。
start起点角度。
end终点角度。 0° is located at the three-o'clock position, and the arc is drawn clockwise.
colorimagecolorallocate() 创建的颜色标识符。
style值可以是下列值的按位或(OR):
IMG_ARC_PIEIMG_ARC_CHORDIMG_ARC_NOFILLIMG_ARC_EDGED
IMG_ARC_PIE和IMG_ARC_CHORD是互斥的;IMG_ARC_CHORD只是用直线连接了起始和结束点,IMG_ARC_PIE则产生圆形边界。IMG_ARC_NOFILL指明弧或弦只有轮廓,不填充。IMG_ARC_EDGED指明用直线将起始和结束点与中心点相连,和IMG_ARC_NOFILL一起使用是画饼状图轮廓的好方法(而不用填充)。
返回值
成功时返回 true, 或者在失败时返回 false。
范例
Example #1 创建一 3D 效果的饼状图
<?php// 创建图像$image = imagecreatetruecolor(100, 100);// 分配一些颜色$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);// 创建 3D 效果for ($i = 60; $i > 50; $i--) { imagefilledarc($image, 50, $i, 100, 50, 0, 45, $darknavy, IMG_ARC_PIE); imagefilledarc($image, 50, $i, 100, 50, 45, 75 , $darkgray, IMG_ARC_PIE); imagefilledarc($image, 50, $i, 100, 50, 75, 360 , $darkred, IMG_ARC_PIE);}imagefilledarc($image, 50, 50, 100, 50, 0, 45, $navy, IMG_ARC_PIE);imagefilledarc($image, 50, 50, 100, 50, 45, 75 , $gray, IMG_ARC_PIE);imagefilledarc($image, 50, 50, 100, 50, 75, 360 , $red, IMG_ARC_PIE);// 输出图像header('Content-type: image/png');imagepng($image);imagedestroy($image);?>
以上例程的输出类似于: