= 4.0.6, PHP 5, PHP 7, PHP 8)imagesetstyle — 設(shè)定畫線的風(fēng)格說(shuō)明imagesetstyle(resource $image, array $style): boolimagesetstyle() 設(shè)定所有畫線的函數(shù)">

imagesetstyle

(PHP 4 >= 4.0.6, PHP 5, PHP 7, PHP 8)

imagesetstyle設(shè)定畫線的風(fēng)格

說(shuō)明

imagesetstyle(resource $image, array $style): bool

imagesetstyle() 設(shè)定所有畫線的函數(shù)(例如 imageline()imagepolygon())在使用特殊顏色 IMG_COLOR_STYLED 或者用 IMG_COLOR_STYLEDBRUSHED 畫一行圖像時(shí)所使用的風(fēng)格。

參數(shù)

image

由圖象創(chuàng)建函數(shù)(例如imagecreatetruecolor())返回的 GdImage 對(duì)象。

style

像素組成的數(shù)組。你可以通過(guò)常量 IMG_COLOR_TRANSPARENT 來(lái)添加一個(gè)透明像素。

返回值

成功時(shí)返回 true, 或者在失敗時(shí)返回 false

范例

下面的示例腳本在畫布上從左上角到右下角畫一行虛線:

示例 #1 imagesetstyle() 例子

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

/* 畫一條虛線,5 個(gè)紅色像素,5 個(gè)白色像素 */
$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);
?>

以上例程的輸出類似于:

Output of example : imagesetstyle()

參見