php 7 imagefill,PHP imagefilledarc()用法及代码示例

imagefilledarc()函数是PHP中的内置函数,用于在给定图像中绘制以指定坐标为中心的局部弧。成功时返回True或失败时返回False

用法:

bool imagefilledarc ( $image, $cx, $cy, $width, $height, $start,

$end, $color, $style )

参数:该函数接受上述和以下所述的九个参数:

$image:它由图像创建功能之一(例如imagecreatetruecolor())返回。它用于创建图像的大小。

$cx:此参数用于设置中心的x坐标。

$cy:此参数用于设置中心的y坐标。

$width:此参数用于设置圆弧宽度。

$height:此参数用于设置弧高。

$start:弧起始角,以度为单位。

$end:弧终止角,以度为单位。 0°位于three-o的时钟位置,并且圆弧是顺时针绘制的。

$color:使用imagecolorallocate()创建的颜色标识符。

$style:建议如何填充图像,其值可以是下面列出的值中的任何一个。IMG_ARC_PIE

IMG_ARC_CHORD

IMG_ARC_NOFILL

IMG_ARC_EDGED

返回值:如果成功,此函数返回True;如果失败,则返回False。

以下示例程序旨在说明PHP中的imagefilledarc()函数:

示例1:

define("WIDTH", 300);

define("HEIGHT", 300);

// Create image.

$img = imagecreate(WIDTH, HEIGHT);

// Allocate colors.

$bg = $white = imagecolorallocate($img, 0xFF, 0xFF, 0xFF);

$green = imagecolorallocate($img, 0, 255, 0);

// make pie arc.

$center_x = (int)WIDTH/2;

$center_y = (int)HEIGHT/2;

imagerectangle($img, 0, 0, WIDTH-1, HEIGHT-1, $green);

imagefilledarc($img, $center_x, $center_y, WIDTH/2,

HEIGHT/2, 0, 220, $green, IMG_ARC_PIE);

// Flush image.

header("Content-Type: image/png");

imagepng($img);

?>

输出:

18f08185d39b9c7ba6174c46d26528ca.png

示例2:

// Create image

$image = imagecreatetruecolor(100, 100);

// Allocate some colors

$red      = imagecolorallocate($image, 0xFF, 0x00, 0x00);

$darkred  = imagecolorallocate($image, 0x90, 0x00, 0x00);

// Make the 3D effect

for ($i = 60; $i > 50; $i--) {

imagefilledarc($image, 50, $i, 100, 50, 75, 360, $darkred, IMG_ARC_PIE);

}

imagefilledarc($image, 50, 50, 100, 50, 75, 360, $red, IMG_ARC_PIE);

// flush image

header('Content-type: image/png');

imagepng($image);

imagedestroy($image);

?>

输出:

fdb41f9dfabbf55e968d19faea2e7673.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值