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.
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);
?>Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Laravel Tech Community
Specializing in Laravel development, we continuously publish fresh content and grow alongside the elegant, stable Laravel framework.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
