imagefilledarc DRAW a partial arc centered at the specified coordinate in the given image.
IMG_ARC_PIE and IMG_ARC_CHORD are mutually exclusive; IMG_ARC_CHORD just connects the starting and ending angles with a straight line, while IMG_ARC_PIE produces a rounded edge.
IMG_ARC_NOFILL indicates that the arc or chord should be outlined, not filled.
IMG_ARC_EDGED, used together with IMG_ARC_NOFILL, indicates that the beginning and ending angles should be connected to the center - this is a good way to outline, (rather than fill), a 'pie slice'.
This function returns TRUE on success or FALSE on failure.
<?php
bool imagefilledarc ( GdImage $image,
int $center_x, int $center_y,
int $width, int $height,
int $start_angle, int $end_angle,
int $color, int $style )
where,
$image = The image identifier
$center_x = The x-coordinate - the center point
$center_y = The y-coordinate - the center point
$width = The width of the arc
$height = The height of the arc
$start_angle = The arc start angle, in degrees
$end_angle = The arc end angle, in degrees
$color = The color as returned by imagecolorallocate
$style = The style to be used
( SEE the below TABLE )
?>
$image
The image identifier.
$center_x
The x-coordinate - the center point.
$center_y
The y-coordinate - the center point.
$width
The width of the arc.
$height
The height of the arc.
$start_angle
The arc start angle, in degrees.
$end_angle
The arc end angle, in degrees.
$color
The color identifier created by imagecolorallocate.
$style
A bitwise OR of the following possibilities:
IMAGE STYLE ARC CONSTANTS |
CONSTANT |
VALUE |
MEANING |
IMG_ARC_PIE |
0 |
Rounded edges. |
IMG_ARC_CHORD |
1 |
Start and end phase connected by line segment. |
IMG_ARC_NOFILL |
2 |
No padding, delineation only. |
IMG_ARC_EDGED |
4 |
Rounded outline. |
ed48 |
EXERCISE
<?php
echo 'PHP VERSION: ' . PHP_VERSION . '<br><br>';
$img_file_base = "png/baseXx.png";
$dest_file_img = "png/PNG 062 01 imagefilledarc.png";
$id_filarc01 = imagecreatefrompng($img_file_base);
$blue = imagecolorallocate($id_filarc01, 0, 0, 255);
$black = imagecolorallocate($id_filarc01, 0, 0, 0);
$red = imagecolorallocate($id_filarc01, 255, 0, 0);
$cx = 100;
$cy = 150;
$horz_axle = 100;
$vert_axle = 200;
$angle_s = 30;
$angle_e = 350;
imagefilledarc($id_filarc01, $cx, $cy, $horz_axle, $vert_axle,
$angle_s, $angle_e, $blue, IMG_ARC_EDGED|IMG_ARC_NOFILL);
$tit = 'IMG_ARC_EDGED|IMG_ARC_NOFILL';
$start_a = 'angle_s = ' . $angle_s;
$end_a = 'angle_e = ' . $angle_e;
$center = 'C = ( ' . $cx . ', ' . $cy . ' )';
$h_axle = 'horz_axle = ' . $horz_axle . ' px';
$v_axle = 'vert_axle = ' . $vert_axle . ' px';
imagestring ($id_filarc01, 5, 50, 255, $tit, $red);
imagestring ($id_filarc01, 3, 200, 160, $start_a, $blue);
imagestring ($id_filarc01, 3, 200, 180, $end_a, $blue);
imagestring ($id_filarc01, 3, 200, 50, $center, $black);
imagestring ($id_filarc01, 3, 200, 100, $h_axle, $blue);
imagestring ($id_filarc01, 3, 200, 120, $v_axle, $blue);
imagepng($id_filarc01, $dest_file_img);
echo $dest_file_img; ?>
<br><br><img src="<?php echo
$dest_file_img; ?>" alt="<?php echo $dest_file_img; ?>"><br>
RESULT PNG 062 01 imagefilledarc.png
EXERCISE
<?php
echo 'PHP VERSION: ' . PHP_VERSION . '<br><br>';
$img_file_base = "png/baseXx.png";
$dest_file_img = "png/PNG 062 02 imagefilledarc.png";
$id_filarc02 = imagecreatefrompng($img_file_base);
$blue = imagecolorallocate($id_filarc02, 0, 0, 255);
$black = imagecolorallocate($id_filarc02, 0, 0, 0);
$red = imagecolorallocate($id_filarc02, 255, 0, 0);
$cx = 100;
$cy = 150;
$horz_axle = 100;
$vert_axle = 200;
$angle_s = 30;
$angle_e = 350;
imagefilledarc($id_filarc02, $cx, $cy,
$horz_axle, $vert_axle,
$angle_s, $angle_e, $blue, IMG_ARC_PIE);
$tit = 'IMG_ARC_PIE';
$start_a = 'angle_s = ' . $angle_s;
$end_a = 'angle_e = ' . $angle_e;
$center = 'C = ( ' . $cx . ', ' . $cy . ' )';
$h_axle = 'horz_axle = ' . $horz_axle . ' px';
$v_axle = 'vert_axle = ' . $vert_axle . ' px';
imagestring ($id_filarc02, 5, 50, 255, $tit, $red);
imagestring ($id_filarc02, 3, 200, 160, $start_a, $blue);
imagestring ($id_filarc02, 3, 200, 180, $end_a, $blue);
imagestring ($id_filarc02, 3, 200, 50, $center, $black);
imagestring ($id_filarc02, 3, 200, 100, $h_axle, $blue);
imagestring ($id_filarc02, 3, 200, 120, $v_axle, $blue);
imagepng($id_filarc02, $dest_file_img);
echo $dest_file_img; ?>
<br><br><img src="<?php echo
$dest_file_img; ?>" alt="<?php echo $dest_file_img; ?>"><br>
RESULT PNG 062 02 imagefilledarc.png
EXERCISE
<?php
echo 'PHP VERSION: ' . PHP_VERSION . '<br><br>';
$img_file_base = "png/baseXx.png";
$dest_file_img = "png/PNG 062 03 imagefilledarc.png";
$id_filarc03 = imagecreatefrompng($img_file_base);
$blue = imagecolorallocate($id_filarc03, 0, 0, 255);
$black = imagecolorallocate($id_filarc03, 0, 0, 0);
$red = imagecolorallocate($id_filarc03, 255, 0, 0);
$cx = 100;
$cy = 150;
$horz_axle = 100;
$vert_axle = 200;
$angle_s = 30;
$angle_e = 350;
imagefilledarc($id_filarc03, $cx, $cy,
$horz_axle, $vert_axle,
$angle_s, $angle_e, $blue, IMG_ARC_CHORD);
$tit = 'IMG_ARC_CHORD';
$start_a = 'angle_s = ' . $angle_s;
$end_a = 'angle_e = ' . $angle_e;
$center = 'C = ( ' . $cx . ', ' . $cy . ' )';
$h_axle = 'horz_axle = ' . $horz_axle . ' px';
$v_axle = 'vert_axle = ' . $vert_axle . ' px';
imagestring ($id_filarc03, 5, 50, 255, $tit, $red);
imagestring ($id_filarc03, 3, 200, 160, $start_a, $blue);
imagestring ($id_filarc03, 3, 200, 180, $end_a, $blue);
imagestring ($id_filarc03, 3, 200, 50, $center, $black);
imagestring ($id_filarc03, 3, 200, 100, $h_axle, $blue);
imagestring ($id_filarc03, 3, 200, 120, $v_axle, $blue);
imagepng($id_filarc03, $dest_file_img);
echo $dest_file_img; ?>
<br><br><img src="<?php echo
$dest_file_img; ?>" alt="<?php echo $dest_file_img; ?>"><br>
RESULT PNG 062 03 imagefilledarc.png
EXERCISE
<?php
echo 'PHP VERSION: ' . PHP_VERSION . '<br><br>';
$img_file_base = "png/baseXx.png";
$dest_file_img = "png/PNG 062 04 imagefilledarc.png";
$id_filarc04 = imagecreatefrompng($img_file_base);
$blue = imagecolorallocate($id_filarc04, 0, 0, 255);
$black = imagecolorallocate($id_filarc04, 0, 0, 0);
$red = imagecolorallocate($id_filarc04, 255, 0, 0);
$cx = 100;
$cy = 150;
$horz_axle = 100;
$vert_axle = 200;
$angle_s = 30;
$angle_e = 350;
imagefilledarc($id_filarc04, $cx, $cy,
$horz_axle, $vert_axle,
$angle_s, $angle_e, $blue, IMG_ARC_EDGED);
$tit = 'IMG_ARC_EDGED';
$start_a = 'angle_s = ' . $angle_s;
$end_a = 'angle_e = ' . $angle_e;
$center = 'C = ( ' . $cx . ', ' . $cy . ' )';
$h_axle = 'horz_axle = ' . $horz_axle . ' px';
$v_axle = 'vert_axle = ' . $vert_axle . ' px';
imagestring ($id_filarc04, 5, 50, 255, $tit, $red);
imagestring ($id_filarc04, 3, 200, 160, $start_a, $blue);
imagestring ($id_filarc04, 3, 200, 180, $end_a, $blue);
imagestring ($id_filarc04, 3, 200, 50, $center, $black);
imagestring ($id_filarc04, 3, 200, 100, $h_axle, $blue);
imagestring ($id_filarc04, 3, 200, 120, $v_axle, $blue);
imagepng($id_filarc04, $dest_file_img);
echo $dest_file_img; ?>
<br><br><img src="<?php echo
$dest_file_img; ?>" alt="<?php echo $dest_file_img; ?>"><br>
RESULT PNG 062 04 imagefilledarc.png
EXERCISE
<?php
echo 'PHP VERSION: ' . PHP_VERSION . '<br><br>';
$img_file_base = "png/baseXx.png";
$dest_file_img = "png/PNG 062 05 imagefilledarc.png";
$id_filarc05 = imagecreatefrompng($img_file_base);
$blue = imagecolorallocate($id_filarc05, 0, 0, 255);
$black = imagecolorallocate($id_filarc05, 0, 0, 0);
$red = imagecolorallocate($id_filarc05, 255, 0, 0);
$cx = 100;
$cy = 150;
$horz_axle = 100;
$vert_axle = 200;
$angle_s = 30;
$angle_e = 350;
imagefilledarc($id_filarc05, $cx, $cy,
$horz_axle, $vert_axle,
$angle_s, $angle_e, $blue, IMG_ARC_NOFILL);
$tit = 'IMG_ARC_NOFILL';
$start_a = 'angle_s = ' . $angle_s;
$end_a = 'angle_e = ' . $angle_e;
$center = 'C = ( ' . $cx . ', ' . $cy . ' )';
$h_axle = 'horz_axle = ' . $horz_axle . ' px';
$v_axle = 'vert_axle = ' . $vert_axle . ' px';
imagestring ($id_filarc05, 5, 50, 255, $tit, $red);
imagestring ($id_filarc05, 3, 200, 160, $start_a, $blue);
imagestring ($id_filarc05, 3, 200, 180, $end_a, $blue);
imagestring ($id_filarc05, 3, 200, 50, $center, $black);
imagestring ($id_filarc05, 3, 200, 100, $h_axle, $blue);
imagestring ($id_filarc05, 3, 200, 120, $v_axle, $blue);
imagepng($id_filarc05, $dest_file_img);
echo $dest_file_img; ?>
<br><br><img src="<?php echo
$dest_file_img; ?>" alt="<?php echo $dest_file_img; ?>"><br>
RESULT PNG 062 05 imagefilledarc.png
EXERCISE
<?php
echo 'PHP VERSION: ' . PHP_VERSION . '<br><br>';
$img_file_base = "png/baseXx.png";
$dest_file_img = "jpeg/JPEG 028 06 imagefilledarc.jpg";
$id_filarc06 = imagecreatefrompng( $img_file_base);
$blue = imagecolorallocate($id_filarc06, 0, 0, 255);
$black = imagecolorallocate($id_filarc06, 0, 0, 0);
$red = imagecolorallocate($id_filarc06, 255, 0, 0);
$cx = 100;
$cy = 150;
$horz_axle = 100;
$vert_axle = 200;
$angle_s = 30;
$angle_e = 350;
imagefilledarc($id_filarc06, $cx, $cy,
$horz_axle, $vert_axle,
$angle_s, $angle_e, $blue,
IMG_ARC_PIE|IMG_ARC_CHORD|IMG_ARC_NOFILL);
$tit = 'IMG_ARC_PIE|IMG_ARC_CHORD|IMG_ARC_NOFILL';
$start_a = 'angle_s = ' . $angle_s;
$end_a = 'angle_e = ' . $angle_e;
$center = 'C = ( ' . $cx . ', ' . $cy . ' )';
$h_axle = 'horz_axle = ' . $horz_axle . ' px';
$v_axle = 'vert_axle = ' . $vert_axle . ' px';
imagestring ($id_filarc06, 5, 12, 255, $tit, $red);
imagestring ($id_filarc06, 3, 200, 160, $start_a, $blue);
imagestring ($id_filarc06, 3, 200, 180, $end_a, $blue);
imagestring ($id_filarc06, 3, 200, 50, $center, $black);
imagestring ($id_filarc06, 3, 200, 100, $h_axle, $blue);
imagestring ($id_filarc06, 3, 200, 120, $v_axle, $blue);
imagejpeg($id_filarc06, $dest_file_img);
echo basename($dest_file_img); ?>
<br><br><img src="<?php echo $dest_file_img; ?>"
alt="<?php echo $dest_file_img; ?>"><br>
RESULT JPEG 028 06 imagefilledarc.jpg