imagesetstyle

(PHP 4 >= 4.0.6, PHP 5)

imagesetstyle -- 線描画用のスタイルを設定する

説明

bool imagesetstyle ( resource im, array style )

imagesetstyle() は、特別な IMG_COLOR_STYLED または色を有するイメージの線 IMG_COLOR_STYLEDBRUSHED を描画する際に (imageline()imagepolygon() のような) 全ての線描画関数で使用されるスタイルを設定します。成功した場合に TRUE を、失敗した場合に FALSE を返します。

パラメータ style はピクセルの配列です。 以下の例は、キャンバスの左上から右下隅に破線を描画するスクリプトです。

例 1. imagesetstyle() の例

<?php
header
("Content-type: image/jpeg");
$im  = imagecreatetruecolor(100, 100);
$w   = imagecolorallocate($im, 255, 255, 255);
$red = imagecolorallocate($im, 255, 0, 0);

/* 5 ピクセルの赤線と 5 ピクセルの白線の破線を描画する */
$style = array($red, $red, $red, $red, $red, $w, $w, $w, $w, $w);
imagesetstyle($im, $style);
imageline($im, 0, 0, 100, 100, IMG_COLOR_STYLED);

/* imagesetstyle を併用した imagesetbrush() を使用して happy face の線を描画する */
$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($brush, 255, 255, 255);
imagecolortransparent($brush, $w2);
imagesetbrush($im, $brush);
imageline($im, 100, 0, 0, 100, IMG_COLOR_STYLEDBRUSHED);

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

imagesetbrush(), imageline() も参照ください。

注意: この関数は、PHP 4.0.6で追加されました。