Latest web development tutorials

PHP imagearc – 畫橢圓弧

PHP 圖像處理 PHP圖像處理

imagearc — 用於畫橢圓弧。

語法

bool imagearc ( resource $image , int $cx , int $cy , int $w , int $h , int $s , int $e , int $color )

imagearc() 以cx,cy(圖像左上角為0, 0)為中心在image 所代表的圖像中畫一個橢圓弧。

w 和h 分別指定了橢圓的寬度和高度,起始和結束點以s 和e 參數以角度指定。 0°位於三點鐘位置,以順時針方向繪畫。

實例

<?php
$img = imagecreatetruecolor(200, 200);// 创建一个 200*200 图片
$white  = imagecolorallocate($img,   255,   255, 255); // 颜色

// 画椭圆弧
imagearc($img, 140,  75,  50,  50,  0, 360, $white);

// 浏览器输出图片
header("Content-type: image/png");
imagepng($img);

imagedestroy($img);
?>

以上實例輸出結果的圖片如下:

PHP 圖像處理 PHP圖像處理