imagesetstyle

(PHP 4 >= 4.0.6, PHP 5)

imagesetstyle -- 設定畫線的風格

說明

bool imagesetstyle ( resource image, array style )

imagesetstyle() 設定所有畫線的函數(例如 imageline()imagepolygon())在使用特殊彩色 IMG_COLOR_STYLED 或是用 IMG_COLOR_STYLEDBRUSHED 畫一行圖像時所使用的風格。若果成功則返回 TRUE,失敗則返回 FALSE

style 參數是像素組成的陣列。下面的示例腳本在畫布上從左上角到右下角畫一行虛線:

例子 1. imagesetstyle() 例子

<?php
header
("Content-type: image/jpeg");
$im  imagecreatetruecolor(100100);
$w   imagecolorallocate($im255255255);
$red imagecolorallocate($im25500);

/* 畫一條虛線,5 個紅色像素,5 個白色像素 */
$style = array($red$red$red$red$red$w$w$w$w$w);
imagesetstyle($im$style);
imageline($im00100100IMG_COLOR_STYLED);

/* 用 imagesetbrush() 和 imagesetstyle 畫一行笑臉 */
$style = array($w$w$w$w$w$w$w$w$w$w$w$w$red);
imagesetstyle($im$style);

$brush imagecreatefrompng("http://www.libpng.org/pub/png/images/smile.happy.png");
$w2 imagecolorallocate($brush255255255);
imagecolortransparent($brush$w2);
imagesetbrush($im$brush);
imageline($im10000100IMG_COLOR_STYLEDBRUSHED);

imagejpeg($im);
imagedestroy($im);
?>

參見 imagesetbrush()imageline()

注: 本函數是 PHP 4.0.6 增加的。