久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      PHP中怎樣繪制多邊形、弧形和橢圓?(圖文詳解)

      在之前的文章中給大家?guī)砹恕对敿毞治鯬HP中怎樣定義顏色、繪制點、線和矩形?》,其中講到了PHP中繪制點、線和矩形的相關(guān)知識,本篇文章我們來看一看,應該怎樣去繪制其他的圖形。希望對大家有幫助!

      PHP中怎樣繪制多邊形、弧形和橢圓?(圖文詳解)

      經(jīng)過之前的文章講述,PHP繪制基本的圖形已經(jīng)了解了,其中就有怎樣去繪制矩形,既然矩形能繪制的話,那三角形、五邊形又應該怎樣去繪制呢?那么接下來我們來了解一下,PHP中應該怎樣去繪制多邊形。

      繪制多邊形

      跟繪制矩形時有些相似,繪制多邊形也有兩個函數(shù)可以完成,就是 imagepolygon() 函數(shù)和 imagefilledpolygon()函數(shù),它們的語法格式如下:

      imagepolygon(resource $image, array $points, int $num_points, int $color) imagefilledpolygon(resource $image, array $points, int $num_points, int $color)

      之所以說和矩形的兩個函數(shù)相似是因為,imagepolygon()函數(shù)后面的顏色是繪制多邊形邊線的顏色,imagefilledpolygon()函數(shù)后面的顏色是繪制多邊形內(nèi)部填充的顏色。

      在語法中,$image表示的是畫布 ;$points 是一個數(shù)組;第三個參數(shù) $num_points 用來設(shè)置多邊形的頂點數(shù),必須大于 3。

      示例如下:

      <?php     $img = imagecreate(300, 150);     imagecolorallocate($img, 255, 255, 255);     $green = imagecolorallocate($img, 0, 255, 0);     $blue = imagecolorallocate($img, 0, 0, 255);     $points1 = array(         255,35,         250,15,         295,56,         233,115,         185,77     );     $points2 = array(         10,5,         100,15,         140,66,         70,135,         25,77     );     imagepolygon($img, $points1, rand(3, 5), $blue);     imagefilledpolygon($img, $points2, rand(3, 5), $green);     header('Content-type:image/jpeg');     imagejpeg($img);     imagedestroy($img); ?>

      輸出結(jié)果:

      PHP中怎樣繪制多邊形、弧形和橢圓?(圖文詳解)

      繪制橢圓

      在PHP中可以通過imageellipse() 函數(shù)來繪制一個橢圓,與繪制多邊形類似也可以通過imagefilledellipse() 函數(shù)來繪制橢圓并且進行填充.它們的語法格式如下:

      imageellipse(resource $image, int $x, int $y, int $width, int $height, int $color) imagefilledellipse(resource $image, int $x, int $y, int $width, int $height, int $color)

      其中,其中 $x 和 $y 分別代表橢圓圓心的橫縱坐標;$width 和 $height 分別代表橢圓的寬度和高度,后面的$colorb分別代表了橢圓的邊線顏色和橢圓的填充顏色。

      示例如下:

      <?php     $img = imagecreate(300, 150);     imagecolorallocate($img, 255, 255, 255);     $green = imagecolorallocate($img, 0, 255, 0);     $blue = imagecolorallocate($img, 0, 0, 255);     imagefilledellipse($img, 75, 75, 120, 80,  $green);     imageellipse($img, 225, 75, 90, 120,$blue);     header('Content-type:image/jpeg');     imagejpeg($img);     imagedestroy($img); ?>

      輸出結(jié)果:

      PHP中怎樣繪制多邊形、弧形和橢圓?(圖文詳解)

      繪制弧線

      在PHP中可以通過 imagearc() 函數(shù)和 imagefilledarc() 函數(shù)來進行繪制一條弧線或者圓形,其中不同的是,imagearc() 函數(shù)繪制弧線的顏色是邊線顏色,imagefilledarc() 函數(shù)繪制弧線會填充。它們的語法格式如下:

      imagearc(resource $image, int $x, int $y, int $width, int $height, int $start, int $end, int $color) imagefilledarc(resource $image, int $x, int $y, int $width, int $height, int $start, int $end, int $color, int $style)

      其中 $x 和 $y 分別表示為圓弧中心點的橫縱坐標;$width 和 $height 分別表示為圓弧的寬度和高度;$start 和 $end 分別代表圓弧的起點角度和終點角度。

      其中還有我們需要注意的是,imagefilledarc() 函數(shù)比 imagearc() 函數(shù)多了一個 $style 參數(shù),這個參數(shù)是用來設(shè)置顏色的填充類型的。它有以下幾種:

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

      • IMG_ARC_CHORD:只使用直線連接起點和終點,需要注意的是它與 IMG_ARC_PIE 互斥;

      • IMG_ARC_NOFILL:指明弧或弦只有輪廓,不填充;

      • IMG_ARC_EDGED:用直線將起始和結(jié)束點與中心點相連。

      示例如下:

      <?php     $img = imagecreate(300, 100);     imagecolorallocate($img, 255, 255, 255);     $blue = imagecolorallocate($img, 0, 0, 255);         imagearc($img, 100, 50, 50, 80, 0, 270, $blue);       imagefilledarc($img, 200, 55, 80, 30, 130, 100, $blue, IMG_ARC_EDGED|IMG_ARC_NOFILL);     header('Content-type:image/jpeg');     imagejpeg($img);     imagedestroy($img); ?>

      輸出結(jié)果:

      PHP中怎樣繪制多邊形、弧形和橢圓?(圖文詳解)

      推薦學習:《PHP視頻教程》

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號