Draw a partial arc and fill it.
PHP imagefilledarc() function has the following syntax.
bool imagefilledarc ( resource $image , int $cx , int $cy , int $width , int $height , int $start , int $end , int $color , int $style )
PHP imagefilledarc() function has the following parameters.
The possible values for style:
Value | Meaning |
---|---|
IMG_ARC_PIE | draws a filled wedge shape with a curved edge |
IMG_ARC_CHORD | draws a straight line between the starting and ending angles |
IMG_ARC_NOFILL | draws the outside edge line without drawing the two lines toward the center of the arc |
IMG_ARC_EDGED | draws an unfilled wedge shape with a curved edge |
Returns TRUE on success or FALSE on failure.
<?php//from ww w .j av a 2s.c o m
// create image
$image = imagecreatetruecolor(100, 100);
// allocate some colors
$gray = imagecolorallocate($image, 0xC0, 0xC0, 0xC0);
$navy = imagecolorallocate($image, 0x00, 0x00, 0x80);
$red = imagecolorallocate($image, 0xFF, 0x00, 0x00);
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);
// flush image
header('Content-type: image/png');
imagepng($image);
imagedestroy($image);
?>
You can combine these four style together.
IMG_ARC_CHORD and IMG_ARC_PIE cannot be combined together.
imagefilledarc($image, 200, 150, 200, 200, 345, 15, $green,IMG_ARC_CHORD | IMG_ARC_NOFILL); imagefilledarc($image, 200, 150, 200, 200, 345, 15, $green,IMG_ARC_EDGED | IMG_ARC_NOFILL);
Example:
<?php
$myImage = imagecreate( 500, 500 );
$myGray = imagecolorallocate( $myImage, 204, 204, 204 );
$myBlack = imagecolorallocate( $myImage, 0, 0, 0 );
imagefilledarc($image, 200, 150, 200, 200, 345, 15, $green,IMG_ARC_CHORD | IMG_ARC_NOFILL);
header( "Content-type: image/png" );
imagepng( $myImage );
imagedestroy( $myImage );
?>