imagearc
DRAW an arc of circle centered at the given coordinates in an image.
$end_angle = 0°, is located at the three-o'clock position, and the arc is drawn clockwise.
This function returns TRUE on success or FALSE on failure.
<?php
bool imagearc ( GdImage $image,
int $center_x,
int $center_y,
int $width,
int $height,
int $start_angle,
int $end_angle,
int $color )
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 line color as returned by imagecolorallocate
?>
$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 line color, a color identifier created by imagecolorallocate.
EXERCISE
<?php
echo 'PHP VERSION: ' . PHP_VERSION . '<br><br>';
$base_img = "png/baseXx.png";
$dest_img = 'png/PNG 061 01 imagearc.png';
$id_arc1 = imagecreatefrompng($base_img);
$line_colorarc1 = imagecolorallocate($id_arc1, 255, 0, 255);
imageantialias($id_arc1, 0);
/* - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
Coordinates of the arc's curvature center
- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - */
$xc0arc1 = 200;
$yc0arc1 = 150;
/* - -- -- -- -- -- -- -- -- --
start angle
- -- -- -- -- -- -- -- -- -- */
$angle_startarc1 = 100;
/* - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
added angle to the start angle
- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- */
$angle_endarc1 = 270;
/* - -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
horizontal axle height
- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- */
$horizontal_axlearc1 = 100;
/* - -- -- -- -- -- -- -- -- -- -- -- -- -- --
vertical axle width
- -- -- -- -- -- -- -- -- -- -- -- -- -- -- */
$vertical_axlearc1 = 160;
imagearc($id_arc1,
$xc0arc1, $yc0arc1,
$horizontal_axlearc1, $vertical_axlearc1,
$angle_startarc1, $angle_endarc1,
$line_colorarc1);
imagepng($id_arc1, $dest_img);
echo $dest_img; ?>
<br><br><img src="<?php echo $dest_img; ?>"
alt="<?php echo $dest_img; ?>"><br>
RESULT PNG 061 01 imagearc.png
EXERCISE
<?php
echo 'PHP VERSION: ' . PHP_VERSION . '<br><br>';
$base_img = "png/baseXx.png";
$dest_img = 'png/PNG 061 02 imagearc.png';
$id_arc2 = imagecreatefrompng($base_img);
$line_colorarc2 = imagecolorallocate($id_arc2, 255, 0, 0);
imageantialias($id_arc2, TRUE);
/* - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
Coordinates of the arc's curvature center
- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - */
$xc0arc2 = 200;
$yc0arc2 = 150;
/* - -- -- -- -- -- -- -- -- --
start angle
- -- -- -- -- -- -- -- -- -- */
$angle_startarc2 = 0;
/* - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
added angle to the start angle
- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- */
$angle_endarc2 = 0;
/* - -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
horizontal axle height
- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- */
$horizontal_axlearc2 = 200;
/* - -- -- -- -- -- -- -- -- -- -- -- -- -- --
vertical axle width
- -- -- -- -- -- -- -- -- -- -- -- -- -- -- */
$vertical_axlearc2 = 100;
imagearc($id_arc2, $xc0arc2,
$yc0arc2,
$horizontal_axlearc2, $vertical_axlearc2,
$angle_startarc2, $angle_endarc2,
$line_colorarc2);
imagepng($id_arc2, $dest_img);
echo $dest_img; ?>
<br><br><img src="<?php echo $dest_img; ?>"
alt="<?php echo $dest_img; ?>"><br>
RESULT PNG 061 02 imagearc.png
EXERCISE
<?php
echo 'PHP VERSION: ' . PHP_VERSION . '<br><br>';
$base_img = "png/baseXx.png";
$dest_img = 'png/PNG 061 03 imagearc.png';
$id_arc3 = imagecreatefrompng($base_img);
$red = imagecolorallocate($id_arc3, 238, 0, 0);
$black = imagecolorallocate($id_arc3, 0, 0, 0);
$blue = imagecolorallocate($id_arc3, 0, 0, 238);
$xc0arc3 = 200;
$yc0arc3 = 150;
$angle_startarc3 = 0;
$angle_endarc3 = 360;
$horizontal_axlearc3 = 200;
$vertical_axlearc3 = 200;
imagearc($id_arc3, $xc0arc3, $yc0arc3,
$horizontal_axlearc3, $vertical_axlearc3,
$angle_startarc3, $angle_endarc3, $red);
$xc0arc3 = 200;
$yc0arc3 = 150;
$angle_startarc3 = 0;
$angle_endarc3 = 360;
$horizontal_axlearc3 = 50;
$vertical_axlearc3 = 200;
imagearc($id_arc3, $xc0arc3, $yc0arc3,
$horizontal_axlearc3, $vertical_axlearc3,
$angle_startarc3, $angle_endarc3, $black);
$xc0arc3 = 200;
$yc0arc3 = 150;
$angle_startarc3 = 0;
$angle_endarc3 = 360;
$horizontal_axlearc3 = 200;
$vertical_axlearc3 = 50;
imagearc($id_arc3, $xc0arc3, $yc0arc3,
$horizontal_axlearc3, $vertical_axlearc3,
$angle_startarc3, $angle_endarc3, $blue);
imagepng($id_arc3, $dest_img );
echo $dest_img; ?>
<br><br><img src="<?php echo
$dest_img; ?>" alt="<?php echo $dest_img; ?>"><br>
RESULT PNG 061 03 imagearc.png
EXERCISE
<?php
echo 'PHP VERSION: ' . PHP_VERSION . '<br><br>';
define('P2P', 'png/');
$base_img = P2P . "baseXx.png";
$dest_img = P2P . 'PNG 061 04 imagearc.png';
$id_arc4 = imagecreatefrompng($base_img);
$red = imagecolorallocate($id_arc4, 238, 0, 0);
$black = imagecolorallocate($id_arc4, 0, 0, 0);
$blue = imagecolorallocate($id_arc4, 0, 0, 238);
$xc0arc4 = 200;
$yc0arc4 = 150;
$angle_startarc4 = 0;
$angle_endarc4 = 360;
$horizontal_axlearc4 = 200;
$vertical_axlearc4 = 200;
imagearc($id_arc4, $xc0arc4, $yc0arc4,
$horizontal_axlearc4, $vertical_axlearc4,
$angle_startarc4, $angle_endarc4, $red);
$xc0arc4 = 200;
$yc0arc4 = 150;
$angle_startarc4 = 0;
$angle_endarc4 = 360;
$horizontal_axlearc4 = 50;
$vertical_axlearc4 = 200;
imagearc($id_arc4, $xc0arc4, $yc0arc4,
$horizontal_axlearc4, $vertical_axlearc4,
$angle_startarc4, $angle_endarc4, $black);
$xc0arc4 = 200;
$yc0arc4 = 150;
$angle_startarc4 = 0;
$angle_endarc4 = 360;
$horizontal_axlearc4 = 200;
$vertical_axlearc4 = 50;
imagearc($id_arc4, $xc0arc4, $yc0arc4,
$horizontal_axlearc4, $vertical_axlearc4,
$angle_startarc4, $angle_endarc4, $blue);
imagepng($id_arc4, $dest_img );
echo $dest_img; ?>
<br><br><img src="<?php echo
$dest_img; ?>" alt="<?php echo $dest_img; ?>"><br>