當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


PHP imagefilledarc()用法及代碼示例

imagefilledarc()函數是PHP中的內置函數,用於在給定圖像中繪製以指定坐標為中心的局部弧。成功時返回True或失敗時返回False

用法:

bool imagefilledarc ( $image, $cx, $cy, $width, $height, $start, 
$end, $color, $style )

參數:該函數接受上述和以下所述的九個參數:


  • $image:它由圖像創建函數之一(例如imagecreatetruecolor())返回。它用於創建圖像的大小。
  • $cx:此參數用於設置中心的x坐標。
  • $cy:此參數用於設置中心的y坐標。
  • $width:此參數用於設置圓弧寬度。
  • $height:此參數用於設置弧高。
  • $start:弧起始角,以度為單位。
  • $end:弧終止角,以度為單位。 0°位於three-o的時鍾位置,並且圓弧是順時針繪製的。
  • $color:使用imagecolorallocate()創建的顏色標識符。
  • $style:建議如何填充圖像,其值可以是下麵列出的值中的任何一個。
    • IMG_ARC_PIE
    • IMG_ARC_CHORD
    • IMG_ARC_NOFILL
    • IMG_ARC_EDGED

返回值:如果成功,此函數返回True;如果失敗,則返回False。

以下示例程序旨在說明PHP中的imagefilledarc()函數:

示例1:

<?php 
  
define("WIDTH", 300); 
define("HEIGHT", 300); 
       
// Create image. 
$img = imagecreate(WIDTH, HEIGHT); 
   
// Allocate colors. 
$bg = $white = imagecolorallocate($img, 0xFF, 0xFF, 0xFF); 
$green = imagecolorallocate($img, 0, 255, 0); 
   
// make pie arc. 
$center_x = (int)WIDTH/2; 
$center_y = (int)HEIGHT/2; 
imagerectangle($img, 0, 0, WIDTH-1, HEIGHT-1, $green); 
imagefilledarc($img, $center_x, $center_y, WIDTH/2, 
               HEIGHT/2, 0, 220, $green, IMG_ARC_PIE); 
   
// Flush image. 
header("Content-Type: image/png"); 
imagepng($img); 
?>

輸出:

示例2:

<?php 
  
// Create image 
$image = imagecreatetruecolor(100, 100); 
  
// Allocate some colors 
$red      = imagecolorallocate($image, 0xFF, 0x00, 0x00); 
$darkred  = imagecolorallocate($image, 0x90, 0x00, 0x00); 
  
// Make the 3D effect 
for ($i = 60; $i > 50; $i--) { 
   imagefilledarc($image, 50, $i, 100, 50, 75, 360, $darkred, IMG_ARC_PIE); 
} 
imagefilledarc($image, 50, 50, 100, 50, 75, 360, $red, IMG_ARC_PIE); 
  
// flush image 
header('Content-type: image/png'); 
imagepng($image); 
imagedestroy($image); 
?>

輸出:

參考: http://php.net/manual/en/function.imagefilledarc.php



相關用法


注:本文由純淨天空篩選整理自Vishal_Khoda大神的英文原創作品 PHP | imagefilledarc() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。