HTML Canvas .beginPath method

Hello guys, sorry to disturb you; I'm learning about HTML canvas and their is something which is confusing me. When drawing some elements, like using the .filleRect() method, we need to use the beginPath() method while when using the .Rect() method, we don't need to actually do that. Why and what is the purpose of the beginPath please
10 Replies
MarkBoots
MarkBoots•3w ago
because it actually is mend to use as a part of a path. It's not a shape on itself https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/rect
No description
Faker
Faker•3w ago
what do we mean by current path please... I'm confused about the word "path" I saw that but I didn't understand 😭
MarkBoots
MarkBoots•3w ago
current path is everything that comes between begin- and end-path. you can draw lines, arcs, rects, etc in a single path to create a combined shape.
Faker
Faker•3w ago
yeah I see, how can we think of the word "path" like our current drawing session ?
MarkBoots
MarkBoots•3w ago
its like a shape you draw without lifting your pen
glutonium
glutonium•3w ago
like imagine u took a pen, u put it on paper, and u start drawing up until u lift the pen the route that you took, and moved your pen around is the "path"
Faker
Faker•3w ago
yeah I see
MarkBoots
MarkBoots•3w ago
allthoug there is also the .moveTo method in a path, so it's not exactly that. but almost
glutonium
glutonium•3w ago
oh ya that's true
Faker
Faker•3w ago
yeah but I now have a clearer view of what is meant by "path"... thanks guys really appreciate
Want results from more Discord servers?
Add your server