Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> PHP

ฟังก์ชัน imagearc() ใน PHP


ฟังก์ชัน imagearc() วาดเส้นโค้ง (Arc) บนภาพ

ไวยากรณ์

imagearc($img, $cx, $cy, $width, $height, $start, $end, $color)

พารามิเตอร์

  • $img: ภาพจาก imagecreatetruecolor()
  • $cx: X ของจุดศูนย์กลาง
  • $cy: Y ของจุดศูนย์กลาง
  • $width: ความกว้างของ arc
  • $height: ความสูงของ arc
  • $start: มุมเริ่มต้น (องศา)
  • $end: มุมสิ้นสุด (องศา)
  • $color: สีของเส้น

คืนค่า

TRUE สำเร็จ FALSE ล้มเหลว

ตัวอย่าง

<?php 
$img = imagecreatetruecolor(200, 200); 
$one = imagecolorallocate($img, 100, 50, 255); 
$two = imagecolorallocate($img, 30, 255, 150); 
imagearc($img, 100, 100, 200, 200, 0, 360, $one); 
imagearc($img, 130, 50, 100, 150, 25, 155, $two); 
header("Content-type: image/png"); 
imagepng($img); 
imagedestroy($img); 
?>

ผลลัพธ์

ฟังก์ชัน imagearc() ใน PHP

ตัวอย่างที่ 2

<?php 
$img = imagecreatetruecolor(250, 250); 
$one = imagecolorallocate($img, 100, 90, 255); 
$two = imagecolorallocate($img, 100, 255, 190); 
imagearc($img, 130, 100, 200, 200, 0, 360, $one); 
imagearc($img, 140, 50, 140, 150, 95, 155, $two); 
header("Content-type: image/png"); 
imagepng($img); 
imagedestroy($img); 
?>

ผลลัพธ์

ฟังก์ชัน imagearc() ใน PHP