close

[php]imagefilltoborder 區域填充到指定顏色的邊界為止


說明

bool imagefilltoborder ( resource $image , int $x , int $y , int $border , int $color )
imagefilltoborder() 從 x,y(圖像左上角為 0, 0)點開始用 color 顏色執行區域填充,
直到碰到顏色為 border 的邊界為止。【註:邊界內的所有顏色都會被填充。
如果指定的邊界色和該點顏色相同,則沒有填充。如果圖像中沒有該邊界色,則整幅圖像都會被填充。】


<?php
// Create the image handle, set the background to white
$im = imagecreatetruecolor(100, 100);
imagefilledrectangle($im, 0, 0, 100, 100, imagecolorallocate($im, 255, 255, 255));

// Draw an ellipse to fill with a black border
imageellipse($im, 50, 50, 50, 50, imagecolorallocate($im, 0, 0, 0));

// Set the border and fill colors
$border = imagecolorallocate($im, 0, 0, 0);
$fill = imagecolorallocate($im, 255, 0, 0);

// Fill the selection
imagefilltoborder($im, 50, 50, $border, $fill);

// Output and free memory
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
?>

arrow
arrow
    全站熱搜

    stockwfj3 發表在 痞客邦 留言(0) 人氣()