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

search for in the

imagedestroy> <imagecreatetruecolor
Last updated: Fri, 05 Sep 2008

view this page in

imagedashedline

(PHP 4, PHP 5)

imagedashedlineDraw a dashed line

Описание

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

This function is deprecated. Use combination of imagesetstyle() and imageline() instead.

Список параметров

image

An image resource, returned by one of the image creation functions, such as imagecreatetruecolor().

x1

Upper left x coordinate.

y1

Upper left y coordinate 0, 0 is the top left corner of the image.

x2

Bottom right x coordinate.

y2

Bottom right y coordinate.

color

The fill color. A color identifier created with imagecolorallocate().

Возвращаемые значения

Always returns true

Примеры

Пример #1 imagedashedline() example

<?php
// Create a 100x100 image
$im imagecreatetruecolor(100100);
$white imagecolorallocate($im0xFF0xFF0xFF);

// Draw a vertical dashed line
imagedashedline($im50255075$white);

// Save the image
imagepng($im'./dashedline.png');
imagedestroy($im);
?>

Результатом выполнения данного примера будет что-то подобное:

Пример #2 Alternative to imagedashedline()

<?php
// Create a 100x100 image
$im imagecreatetruecolor(100100);
$white imagecolorallocate($im0xFF0xFF0xFF);

// Define our style: First 4 pixels is white and the 
// next 4 is transparent. This creates the dashed line effect
$style = Array(
        
$white
        
$white
        
$white
        
$white
        
IMG_COLOR_TRANSPARENT
        
IMG_COLOR_TRANSPARENT
        
IMG_COLOR_TRANSPARENT
        
IMG_COLOR_TRANSPARENT
        
);

imagesetstyle($im$style);

// Draw the dashed line
imageline($im50255075IMG_COLOR_STYLED);

// Save the image
imagepng($im'./imageline.png');
imagedestroy($im);
?>

Смотрите также



imagedestroy> <imagecreatetruecolor
Last updated: Fri, 05 Sep 2008
 
add a note add a note User Contributed Notes
imagedashedline
ProfessorNeo at gmx dot de
16-Feb-2006 12: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
13-Jul-2005 02: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 06: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, 05 Sep 2008
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites