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

  1. // create empty canvas with background color
  2. $img = Image::canvas(100, 100, '#ddd');
  3. // draw a blue line
  4. $img->line('#0000ff', 10, 10, 100, 10);
  5. // draw a red line
  6. $img->line('#ff0000', 10, 10, 195, 195);

See also