imagesetstyle

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

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

説明

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

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

パラメータ

image

imagecreatetruecolor()のような画像作成関数が返す GdImage オブジェクト。

style

はピクセルの配列です。定数 IMG_COLOR_TRANSPARENT を使用すると、透明なピクセルを追加できます。 style は空の配列にしてはいけません。

戻り値

成功した場合に true を、失敗した場合に false を返します。

以下の例は、キャンバスの左上から右下隅に破線を描画するスクリプトです。

例1 imagesetstyle() の例

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


$style = array($red, $red, $red, $red, $red, $w, $w, $w, $w, $w);
imagesetstyle($im, $style);
imageline($im, 0, 0, 100, 100, IMG_COLOR_STYLED);


$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);
?>

上の例の出力は、 たとえば以下のようになります。

出力例 : imagesetstyle()

参考

To Top