Image::line
Draw a line to the current image
2.9M Downloads / Month
Open Source MIT License
2.9M Downloads / Month
Open Source MIT License
public Intervention\Image\Image line(int $x1, int $y1, int $x2, int $y2, [Closure $callback])
Draw a line from x,y point 1 to x,y point 2 on current image. Define color and/or width of line in an optional Closure callback.
X-Coordinate of the starting point.
Y-Coordinate of the starting point.
X-Coordinate of the end point.
Y-Coordinate of the end point.
Define appearance of line. See examples below. Use the following methods to pass details.
public Intervention\Image\AbstractShape color(string $color)
Set color of the line in one of the available color formats. Default: #000000
public Intervention\Image\AbstractShape width(integer $width)
Set the width of the line in pixels. Option is not available with GD driver Default: 1
Instance of Intervention\Image\Image
// create empty canvas with background color
$img = Image::canvas(100, 100, '#ddd');
// draw a blue line
$img->line(10, 10, 100, 10, function ($draw) {
$draw->color('#0000ff');
});
// draw a red line with 5 pixel width
$img->line(10, 10, 195, 195, function ($draw) {
$draw->color('#f00');
$draw->width(5);
});