PHP imagefilledarc Function: Drawing and Filling Elliptical Arcs

This article explains the PHP GD library function imagefilledarc, detailing its parameters, return values, and providing a complete example that creates a PNG image with filled elliptical arcs and a simple 3‑D effect.

Laravel Tech Community
Laravel Tech Community
Laravel Tech Community
PHP imagefilledarc Function: Drawing and Filling Elliptical Arcs

imagefilledarc is a PHP GD library function that draws a filled elliptical arc on a given image resource.

Parameters resource $image – image resource created by functions such as imagecreatetruecolor(). int $cx – x-coordinate of the center. int $cy – y-coordinate of the center. int $width – width of the ellipse. int $height – height of the ellipse. int $start – start angle in degrees. int $end – end angle; 0° is at three‑o’clock and the arc is drawn clockwise. int $color – color identifier allocated with imagecolorallocate(). int $style – bitwise OR of IMG_ARC_PIE, IMG_ARC_CHORD, IMG_ARC_NOFILL, IMG_ARC_EDGED.

Return value

Returns the image resource on success, or FALSE on failure.

Example

<?php
// Create image
$image = imagecreatetruecolor(100, 100);
// Allocate colors
$white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF);
$gray = imagecolorallocate($image, 0xC0, 0xC0, 0xC0);
$darkgray = imagecolorallocate($image, 0x90, 0x90, 0x90);
$navy = imagecolorallocate($image, 0x00, 0x00, 0x80);
$darknavy = imagecolorallocate($image, 0x00, 0x00, 0x50);
$red = imagecolorallocate($image, 0xFF, 0x00, 0x00);
$darkred = imagecolorallocate($image, 0x90, 0x00, 0x00);
// 3D effect
for ($i = 60; $i > 50; $i--) {
    imagefilledarc($image, 50, $i, 100, 50, 0, 45, $darknavy, IMG_ARC_PIE);
    imagefilledarc($image, 50, $i, 100, 50, 0, 45, $darkgray, IMG_ARC_PIE);
    imagefilledarc($image, 50, $i, 100, 50, 0, 45, 360, $darkred, IMG_ARC_PIE);
}
imagefilledarc($image, 50, 50, 100, 50, 0, 45, $navy, IMG_ARC_PIE);
imagefilledarc($image, 50, 50, 100, 50, 0, 45, $gray, IMG_ARC_PIE);
imagefilledarc($image, 50, 50, 100, 50, 0, 45, $red, IMG_ARC_PIE);
// Output image
header('Content-type: image/png');
imagepng($image);
imagedestroy($image);
?>

The script outputs a PNG image showing several filled arcs that create a simple 3‑D effect.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Backendimage-processingdrawinggd-library
Laravel Tech Community
Written by

Laravel Tech Community

Specializing in Laravel development, we continuously publish fresh content and grow alongside the elegant, stable Laravel framework.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.