Fork me on GitHub

line — Draw a line

Description

public Intervention\Image\Image line(string $color, integer $x1, integer $y1, integer $x2 = 10, integer $y2)

Draw a colored line from x,y point 1 to x,y point 2 on current image.

Parameters

color

The color of the line. Pass a color in one of the different color formats.

x1

X-Coordinate of the starting point.

y1

Y-Coordinate of the starting point.

x2

X-Coordinate of the end point.

y2

Y-Coordinate of the end point.

Return Values

Instance of Intervention\Image\Image

Examples

// create empty canvas with background color
$img = Image::canvas(100, 100, '#ddd');

// draw a blue line
$img->line('#0000ff', 10, 10, 100, 10);

// draw a red line
$img->line('#ff0000', 10, 10, 195, 195);

See also