Canvas Beginpath
π
2026-06-18 | π HTML
## HTML Canvas `beginPath()` Method
The `beginPath()` method of the Canvas 2D API starts a new path by emptying the list of sub-paths. Call this method when you want to create a brand-new path, ensuring that subsequent drawing commands are not appended to previous ones.
---
## Definition and Usage
The `beginPath()` method resets the current path.
When you draw on a canvas, the 2D context maintains a "current path". If you do not call `beginPath()` before drawing a new shape, any new lines or shapes you define will be added to the existing path. When you eventually call `stroke()` or `fill()`, the browser will redraw the entire accumulated path, which can lead to unexpected styling issues (such as previous lines changing color or thickness).
* **To define paths, use:** `moveTo()`, `lineTo()`, `quadricCurveTo()`, `bezierCurveTo()`, `arcTo()`, and `arc()`.
* **To render the path on the canvas, use:** `stroke()` (for outlines) or `fill()` (for solid shapes).
---
## Syntax
```javascript
context.beginPath();
```
### Parameters
This method does not accept any parameters.
### Return Value
This method does not return any value (`undefined`).
---
## Browser Support
The `beginPath()` method is widely supported across all modern web browsers:
* Google Chrome
* Mozilla Firefox
* Microsoft Edge / Internet Explorer 9+
* Safari
* Opera
*Note: Internet Explorer 8 and earlier versions do not support the `