+ 1
HTML Canvas beginPath()
Looking on the 'Draw a Line ' code of this tutorial https://www.w3schools.com/graphics/canvas_coordinates.asp It doesn't have beginPath() written before the the codes for the line. I don't fully understand what it is.. The definition written within the website above says that it 'begins a path'. Then why when it comes to fillrect(), we don't write it? In some examples regarding lines, it is both included and not. For circles, it always seems to be included within the code.
2 Réponses
+ 11
fillRect(x, y, width, height) is the same as:
beginPath();
rect(x, y, width, height);
fill();
beginPath() is used when you want to draw shapes that are not those that come by default.
+ 4
A better tutorial
https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial