標籤:
1.建立畫布:
$img=imagescreatetruecolor(200,200);
建立顏色並填充
$red=imagecolorallocate($img,255,0,0); //建立顏色
$imagefill($img,0,10,$red); //填充顏色
2.畫圖形
矩形:
imagedrectangle($img,90,10,190,80,$green); 不填充的矩形
imagefilledrectangle($img,90,10,190,80,$green); 填充的矩形
線段:
imageline($img,0,0,200,200,$blue);
點:
imagesetpixel ($img,50,50,$red);
圓:
imageellipse ($img,100,100,100,100,$green);
image
由圖象建立函數(例如imagecreatetruecolor())返回的圖象資源。
cx
中間的 X 座標。
cy
中間的 Y 座標。
width
橢圓的寬度。
height
橢圓的高度。
color
橢圓的顏色。顏色標識符由 imagecolorallocate() 建立。
圓形:
imagefilledarc($img,50,50,-160,40,$green);
圓弧:
imagefilledarc($img,50,50,100,50-160,40,$green,IMG_ARC_RIE);
bool imagefilledarc ( resource image, int cx, int cy, int w, int h, int s, int e, int color, int style )
imagefilledarc() 在 image 所代表的映像中以 cx,cy(映像左上方為 0, 0)畫一橢圓弧。如果成功則返回 TRUE,失敗則返回 FALSE。w 和 h 分別指定了橢圓的寬和高,s 和 e 參數以角度指定了起始和結束點。style 可以是下列值按位或(OR)後的值:
寫字元到映像:
水平畫:imagechar($img,5,100,100,"ABCDEFG",$red);
垂直畫:imagecharup($img,5,100,100,"ABCDEFGHIJK",$red);
3.輸出資源
header("Content-type:image/gif");
imagegif($img);
4.釋放資源
imagedestry($img);
PHP影像處理