Search code examples
javascriptcanvasstroke

Difference between lineTo & stroke


If canvas is document.querySelector("canvas"); and ctx is canvas.getContext("2d"), what's the difference between ctx.lineTo(x,y) and ctx.stroke()?


Solution

  • lets assume a cursor that moves around the canvas, it records the path you provided but it draws only after you call stroke() or fill(). hope you got it!