php gd库画线,[PHP] GD库(十)绘制线段与圆弧 imageline、imagesetstyle 与 imagearc 函数...
[PHP] GD庫(十)繪制線段與圓弧 imageline、imagesetstyle 與 imagearc 函數
imageline() 函數用于繪制一條線段。
imagearc() 函數用于繪制橢圓弧(包括圓弧)。
imagesetstyle() 函數用于設定畫線風格。
imageline()
imageline() 函數用于繪制一條線段。
語法:
bool imageline( resource image, int x1, int y1, int x2, int y2, int color )
用 color 顏色在圖像 image 中從坐標 x1,y1 到 x2,y2(圖像左上角坐標為 0,0)畫一條線段。
例子:
瀏覽器輸出圖像如下:
PHP 繪制線段示例
參考閱讀
- imagecreate():創建一幅空白圖像。
- imagecolorallocate():為圖像分配顏色。
imagesetstyle()
imagesetstyle() 設定所有畫線的函數(例如 imageline() 和 imagepolygon())在使用特殊顏色 IMG_COLOR_STYLED 或者用 IMG_COLOR_STYLEDBRUSHED 畫一行圖像時所使用的風格。如果成功則返回 TRUE ,失敗則返回 FALSE 。
語法:
bool imagesetstyle( resource image, array style )
style 參數是像素組成的數組。
imageline() 函數配合 imagesetstyle() 可以畫一條虛線段:
瀏覽器輸出圖像如下:
imagearc()
imagearc() 函數用于繪制橢圓弧(包括圓弧)。
語法:
bool imagearc(resource image, int cx, int cy, int w, int h, int s, int e, int color )
參數說明:
參數
說明
image
圖像資源,欲繪制橢圓弧的圖像
cx
橢圓中心 x 坐標
cy
橢圓中心 y 坐標
w
橢圓寬度
h
橢圓高度
s
起始點,0 表示 3 點鐘方向
e
角度,360 表示完全封閉
color
圖像顏色
例子:
該例子繪制一個圓圈,瀏覽器輸出如下:
PHP 繪制橢圓弧示例
總結
以上是生活随笔為你收集整理的php gd库画线,[PHP] GD库(十)绘制线段与圆弧 imageline、imagesetstyle 与 imagearc 函数...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 用什么写php最好用,php用什么开发工
- 下一篇: php jira,php – 为Jira