PHP imagearc() Function: Drawing an Elliptical Arc

The PHP imagearc() function draws an elliptical arc on a GD image resource using specified center coordinates, width, height, start and end angles, and color, returning the transformed image on success or FALSE on failure, with a full example demonstrating its usage.

Laravel Tech Community
Laravel Tech Community
Laravel Tech Community
PHP imagearc() Function: Drawing an Elliptical Arc

The imagearc() function in PHP's GD library draws an elliptical arc on an image resource. It takes the image resource, center coordinates ( $cx, $cy), width ( $w), height ( $h), start angle ( $s), end angle ( $e), and color ( $color) as parameters.

The start angle is measured clockwise from the 3 o'clock position. The function returns the transformed image on success, or FALSE on failure.

Example usage:

<?php
// Create a 200x200 image
$img = imagecreatetruecolor(200, 200);
// Allocate colors
$white = imagecolorallocate($img, 255, 255, 255);
$black = imagecolorallocate($img, 0, 0, 0);
// Draw a black ellipse arc
imagearc($img, 100, 100, 150, 150, 0, 360, $black);
// Output the image
header("Content-type: image/png");
imagepng($img);
imagedestroy($img);
?>
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.

BackendGraphicsImage ProcessingPHPGDimagearc
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.