PHP imagefilledarc() function

Description

Draw a partial arc and fill it.

Syntax

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 )

Parameter

PHP imagefilledarc() function has the following parameters.

  • image - An image resource, returned by one of the image creation functions, such as imagecreatetruecolor().
  • cx - x-coordinate of the center.
  • cy - y-coordinate of the center.
  • width - The arc width.
  • height - The arc height.
  • start - The arc start angle, in degrees.
  • end - The arc end angle, in degrees. 0? is located at the three-o'clock position, and the arc is drawn clockwise.
  • color - A color identifier created with imagecolorallocate().
  • style - A bitwise OR of the following possibilities:

The possible values for style:

ValueMeaning
IMG_ARC_PIEdraws a filled wedge shape with a curved edge
IMG_ARC_CHORDdraws a straight line between the starting and ending angles
IMG_ARC_NOFILLdraws the outside edge line without drawing the two lines toward the center of the arc
IMG_ARC_EDGEDdraws an unfilled wedge shape with a curved edge

Return

Returns TRUE on success or FALSE on failure.

Example 1


<?php//from   w ww  . j a va  2  s  .  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);
?>

Example 2

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 // w w w. jav  a  2  s . c o  m
  $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 ); 
?> 




















Home »
  PHP Tutorial »
    Function reference »




PHP Array Functions
PHP Calendar Functions
PHP Class Functions
PHP Data Type Functions
PHP Date Functions
PHP File Functions
PHP Image Functions
PHP Math Functions
PHP MySQLi Functions
PHP SimpleXML Functions
PHP String Functions
PHP XML Functions
PHP Zip Functions