imagedashedline() function in PHP


The imagedashedline() function draws a dashed line.

Syntax

imagedashedline( $image , $x1 , $y1 , $x2 , $y2 , $color )

Parameters

  • image 
    Create a blank image with imagecreatetruecolor().

  • x1 
    Upper left x-coordinate

  • y1 
    Upper left y-coordinate

  • x2 
    Bottom right x-coordinate

  • y2 
    Bottom right y-coordinate

  • color 
    The fill color.

Return

The function returns TRUE on success or FALSE on failure.

Example

The following is an example:

<?php
   $image = imagecreatetruecolor(500, 370);
   $bgcolor = imagecolorallocate($image, 70, 90, 120);
   imagefill($image, 0, 0, $bgcolor);
   $color = imagecolorallocate($image, 90, 220, 175);
   imagedashedline($image, 0, 0, 150, 50, $color);
   header("Content-type: image/png");  
imagepng($image);
?>

Output

The following is the output:

Updated on: 31-Dec-2019

34 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements