Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

imagedashedline

Description

The imagedashedline of Image for PHP draw a dashed line.

Syntax

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

Parameters

image

A GdImage object, 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().

Return

Returns true on success or false on failure.

Examples

1 · return

<?

$width = 100;
$height = 100;
$image = imagecreate($width, $height);

$red = 255;
$green = 255;
$blue = 255;
$color = imagecolorallocate($image, $red, $green, $blue);

$x1 = 25;
$y1 = 25;
$x2 = 75;
$y2 = 75;

$return = imagedashedline($image, $x1, $y1, $x2, $y2, $color);
    
var_export($return);

?>
true

2 · base64

<?

$width = 100;
$height = 100;
$image = imagecreatetruecolor($width, $height);

$red = 255;
$green = 255;
$blue = 255;
$color = imagecolorallocate($image, $red, $green, $blue);

$x1 = 0;
$y1 = 0;
$x2 = 100;
$y2 = 100;
imagedashedline($image, $x1, $y1, $x2, $y2, $color);

ob_start();

    imagepng($image);

$output = ob_get_clean();

echo '<!doctype html>
<html>
<body>
    <img src="data:image/png;base64,' . base64_encode($output) . '">
</body>
</html>';

?>
<!doctype html>
<html>
<body>
    <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAIAAAD/gAIDAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAlklEQVR4nO3UMQHAQAzEsOdPOqVQzydB8OB3d4//9Gr0Atjg941ejV6NXgAb/L7Rq9Gr0Qtgg983ejV6NXoBbPD7Rq9Gr0YvgA1+3+jV6NXoBbDB7xu9Gr0avQA2+H2jV6NXoxfABr9v9Gr0avQC2OD3jV6NXo1eABv8vtGr0avRC2CD3zd6NXo1egFs8PtGr0avRq/sA2zrmGiDdVj/AAAAAElFTkSuQmCC">
</body>
</html>
HomeMenu