日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > php >内容正文

php

php imagefill,PHP 图像填充 imagefill、imagefilledarc 与 imagefilledrectangle() 函数

發(fā)布時(shí)間:2025/3/21 php 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 php imagefill,PHP 图像填充 imagefill、imagefilledarc 与 imagefilledrectangle() 函数 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

imagefill() 函數(shù)用于區(qū)域填充。

語法:

bool imagefill( resource image, int x, int y, int color )

x,y 分別為填充的起始 x 坐標(biāo)和 y 坐標(biāo),與 x, y 點(diǎn)顏色相同且相鄰的點(diǎn)都會(huì)被填充。

例子:

header("Content-type: image/png");

$im = @imagecreatetruecolor(200, 200);

$red = imagecolorallocate($im, 255, 0, 0);

//用 $red 顏色填充圖像

imagefill( $im, 0, 0, $red );

imagepng($im);

imagedestroy($im);

?>

imagefilledarc() 函數(shù)畫一橢圓弧并填充。

語法:

bool imagefilledarc( resource image, int cx, int cy, int w, int h, int s, int e, int color, int style )

該函數(shù)參數(shù)用法可參考繪制橢圓弧函數(shù) imagearc() ,只是本函數(shù)增加 style 參數(shù)表示填充方式。

style 填充方式說明:

填充方式

說明

IMG_ARC_PIE

普通填充,產(chǎn)生圓形邊界

IMG_ARC_CHORD

只是用直線連接了起始和結(jié)束點(diǎn),與 IMG_ARC_PIE 方式互斥

IMG_ARC_NOFILL

指明弧或弦只有輪廓,不填充

IMG_ARC_EDGED

指明用直線將起始和結(jié)束點(diǎn)與中心點(diǎn)相連

例子:

header('Content-type: image/png');

$im = imagecreatetruecolor(100, 100);

$red = imagecolorallocate($im, 255, 0, 0);

imagefilledarc($im, 50, 50, 100, 50, 0, 360 , $red, IMG_ARC_PIE);

imagepng($im);

imagedestroy($im);

?>

該函數(shù)典型應(yīng)用之一是畫餅狀統(tǒng)計(jì)圖。

imagefilledrectangle() 函數(shù)畫一矩形并填充。

語法:

bool imagefilledrectangle( resource image, int x1, int y1, int x2, int y2, int color )

x1,y1為左上角左邊,x2,y2為右下角坐標(biāo)。

例子:

header('Content-type: image/png');

$im = imagecreatetruecolor(200, 200);

$yellow = imagecolorallocate($im, 255, 255, 0);

imagefilledrectangle($im, 20, 150, 40, 200, $yellow);

imagefilledrectangle($im, 50, 80, 70, 200, $yellow);

imagepng($im);

imagedestroy($im);

?>

該函數(shù)典型應(yīng)用之一是柱狀統(tǒng)計(jì)圖。

imagefilledpolygon() 函數(shù)畫一多邊形并填充。

語法:

bool imagefilledpolygon( resource image, array points, int num_points, int color )

參數(shù)說明:

參數(shù)

說明

image

圖像資源,欲繪制多邊形的圖像

points

按順序包含有多邊形各頂點(diǎn)的 x 和 y 坐標(biāo)的數(shù)組

num_points

頂點(diǎn)的總數(shù),必須大于 3

color

圖像的顏色

繪制一個(gè)用紅色填充的六邊形例子:

header('Content-type: image/png');

$points = array(

50, 50,// Point 1 (x, y)

100, 50, // Point 2 (x, y)

150, 100, // Point 3 (x, y)

150, 150,// Point 4 (x, y)

100, 150, // Point 5 (x, y)

50, 100// Point 6 (x, y)

);

$im = imagecreatetruecolor(200, 200);

$red = imagecolorallocate($im, 255, 0, 0);

imagefilledpolygon($im, $points, 6, $red);

imagepng($im);

imagedestroy($im);

?>

總結(jié)

以上是生活随笔為你收集整理的php imagefill,PHP 图像填充 imagefill、imagefilledarc 与 imagefilledrectangle() 函数的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。