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, 14 Aug 2009

view this page in

imagedashedline

(PHP 4, PHP 5)

imagedashedlineDessine une ligne pointillée

Description

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

imagedashedline() est obsolète. Utilisez plutôt une combinaison des fonctions imagesetstyle() et imageline().

Liste de paramètres

image

Une ressource d'image, retourné par une des fonctions de création d'images, comme imagecreatetruecolor().

x1

Coordonnée en X : En haut, à gauche.

y1

Coordonnée en Y : En haut, à gauche. 0 est le coin en haut à gauche de l'image.

x2

Coordonnée en X : En bas, à droite.

y2

Coordonnée en Y : En bas, à droite.

color

La couleur de remplissage. Un identifiant de couleur retourné par la fonction imagecolorallocate().

Valeurs de retour

Retourne toujours TRUE.

Exemples

Exemple #1 Exemple avec imagedashedline()

<?php
// Crée une image de 100x100 pixels
$im imagecreatetruecolor(100100);
$white imagecolorallocate($im0xFF0xFF0xFF);

// Dessine une ligne verticale en pointillé
imagedashedline($im50255075$white);

// Sauvegarde l'image
imagepng($im'./dashedline.png');
imagedestroy($im);
?>

L'exemple ci-dessus va afficher quelque chose de similaire à :

Exemple #2 Alternative à la fonction imagedashedline()

<?php
// Crée une image de 100x100 pixels
$im imagecreatetruecolor(100100);
$white imagecolorallocate($im0xFF0xFF0xFF);

// Définit le style : Les 4 premiers pixels sont blancs et les 4 suivants
// sont transparents. Ceci va créer l'effet de pointillé
$style = Array(
                
$white,
                
$white,
                
$white,
                
$white,
                
IMG_COLOR_TRANSPARENT,
                
IMG_COLOR_TRANSPARENT,
                
IMG_COLOR_TRANSPARENT,
                
IMG_COLOR_TRANSPARENT
                
);

imagesetstyle($im$style);

// Dessine la ligne pointillée
imageline($im50255075IMG_COLOR_STYLED);

// Sauvegarde de l'image
imagepng($im'./imageline.png');
imagedestroy($im);
?>

Voir aussi



imagedestroy> <imagecreatetruecolor
Last updated: Fri, 14 Aug 2009
 
add a note add a note User Contributed Notes
imagedashedline
ProfessorNeo at gmx dot de
16-Feb-2006 08: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 09: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 02: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, 14 Aug 2009
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites