Begin a path, move to position 0,0. Create a line to position 300,150:
JavaScript:
Internet Explorer 9, Firefox, Opera, Chrome, and Safari support the lineTo() method.
Note: Internet Explorer 8 and earlier versions, do not support the <canvas> element.
The lineTo() method adds a new point and creates a line from that point to the last specified point in the canvas (this method does not draw the line).
Tip: Use the stroke() method to actually draw the path on the canvas.
JavaScript syntax: | context.lineTo(x,y); |
---|
Parameter | Description | Play it |
---|---|---|
x | The x-coordinate of where to create the line to | Play it » |
y | The y-coordinate of where to create the line to | Play it » |
Draw a path, shaped as the letter L:
JavaScript: