downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

imagedestroy> <imagecreatetruecolor
Last updated: Fri, 06 Nov 2009

view this page in

imagedashedline

(PHP 4, PHP 5)

imagedashedline破線を描画する

説明

bool imagedashedline ( resource $image , int $x1 , int $y1 , int $x2 , int $y2 , int $color )

これは古い関数です。代わりに imagesetstyle()imageline() の組み合せを使用してください。

パラメータ

image

imagecreatetruecolor() のような画像作成関数が返す画像リソース。

x1

左上の x 座標。

y1

左上の y 座標 0。0 は画像の左上の角です。

x2

右下の x 座標。

y2

右下の y 座標。

color

塗りつぶし色。 imagecolorallocate() で作成した色 ID。

返り値

常に true を返します。

例1 imagedashedline() の例

<?php
// 100x100 の画像を作成します
$im imagecreatetruecolor(100100);
$white imagecolorallocate($im0xFF0xFF0xFF);

// 縦の破線を描画します
imagedashedline($im50255075$white);

// 画像を保存します
imagepng($im'./dashedline.png');
imagedestroy($im);
?>

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

例2 imagedashedline() のもうひとつの使用法

<?php
// 100x100 の画像を作成します
$im imagecreatetruecolor(100100);
$white imagecolorallocate($im0xFF0xFF0xFF);

// 独自のスタイルの作成: 最初の 4 ピクセルを白色、
// 次の 4 ピクセルを透明とし、破線風の効果を作成します
$style = Array(
                
$white
                
$white
                
$white
                
$white
                
IMG_COLOR_TRANSPARENT
                
IMG_COLOR_TRANSPARENT
                
IMG_COLOR_TRANSPARENT
                
IMG_COLOR_TRANSPARENT
                
);

imagesetstyle($im$style);

// 破線を描画します
imageline($im50255075IMG_COLOR_STYLED);

// 画像を保存します
imagepng($im'./imageline.png');
imagedestroy($im);
?>

参考



imagedestroy> <imagecreatetruecolor
Last updated: Fri, 06 Nov 2009
 
add a note add a note User Contributed Notes
imagedashedline
ProfessorNeo at gmx dot de
17-Feb-2006 05:07
The bug reported by 'michi at marel dot at' also exists in PHP version 5.1.1. This functions just works with vertical lines!
alien-scripts.de
14-Jul-2005 06:17
I make my own dashedline:

<?
for($l=50;$l<=550;$l+=5)
   {
    if(
$da == 0) { $da = 1; }
    elseif(
$da == 1){
   
imageline($bild,$l,50,$l+5,50,$green);
   
$da = 0; }
   }
?>

$l is the x-value
and we have a dashed line :)
michi at marel dot at
19-Nov-2003 11:49
There's a bug till PHP 4.0.4 in this function. You can only draw vertical dashed lines. To draw other dashed lines you can set <ImageSetStyle> to a special dashed line and draw it by <ImageLine>.

Sample code:
<?php
function MDashedLine($image, $x0, $y0, $x1, $y1, $fg, $bg)
{
       
$st = array($fg, $fg, $fg, $fg, $bg, $bg, $bg, $bg);
       
ImageSetStyle($image, $st);
       
ImageLine($image, $x0, $y0, $x1, $y1, IMG_COLOR_STYLED);
}
?>

imagedestroy> <imagecreatetruecolor
Last updated: Fri, 06 Nov 2009
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites