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•2mo 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
FakerOP•2mo 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•2mo 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
FakerOP•2mo ago
yeah I see, how can we think of the word "path" like our current drawing session ?
MarkBoots
MarkBoots•2mo ago
its like a shape you draw without lifting your pen
glutonium
glutonium•2mo 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
FakerOP•2mo ago
yeah I see
MarkBoots
MarkBoots•2mo ago
allthoug there is also the .moveTo method in a path, so it's not exactly that. but almost
glutonium
glutonium•2mo ago
oh ya that's true
Faker
FakerOP•2mo 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