+ 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.

28th Apr 2019, 6:13 PM
J3fro C
J3fro C - avatar
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.
28th Apr 2019, 6:42 PM
InvBoy [ :: FEDE :: ]
InvBoy [ :: FEDE :: ] - avatar
29th Apr 2019, 12:03 AM
Gordon
Gordon - avatar