canvas - Assigning the canvas element to a variable.
ctx - Assigning the 2d rendering context to another variable by calling the getContext('2d') method.
beginPath() - Use beginPath() canvas method to start a new path by emptying the list of sub-paths.
moveTo() - Use moveTo() canvas method to begin a new sub-path at the point specified by the given (x, y) coordinates.
lineTo() - Use lineTo() canvas method to add a straight line to the current sub-path by connecting the sub-path's last point to the specified (x, y) coordinates.
stroke() - Use stroke() canvas method to stroke (outline) the current or given path with the current strokeStyle. The default strokeStyle is 'black'.
HTML Online Editor
Your browser does not support the canvas element.
ctx.beginPath(); // Start a new pathctx.moveTo(0, 0); // Move the pen to (0, 0)ctx.lineTo(150, 100); // Draw a line to (150, 100)ctx.stroke();