https://github.com/dy/svg-path-bounds
Get boundary box of svg path data
https://github.com/dy/svg-path-bounds
Last synced: 8 months ago
JSON representation
Get boundary box of svg path data
- Host: GitHub
- URL: https://github.com/dy/svg-path-bounds
- Owner: dy
- Created: 2017-07-22T14:31:52.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2025-01-20T02:49:15.000Z (over 1 year ago)
- Last Synced: 2025-07-13T20:49:08.636Z (11 months ago)
- Language: JavaScript
- Size: 34.2 KB
- Stars: 69
- Watchers: 4
- Forks: 7
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# svg-path-bounds [](https://github.com/dy/svg-path-bounds/actions/workflows/test.yml)
Retrieve bounding box from svg path data.
[](https://npmjs.org/package/svg-path-bounds/)
```js
const getBounds = require('svg-path-bounds')
let [left, top, right, bottom] = getBounds('M0 0L10 10 20 0Z') // [0, 0, 20, 10]
```
### bounds = getBounds(path|segments)
Calculate bounding box for [svg path data](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d) string or [parsed path segments](https://www.npmjs.com/package/parse-svg-path) array. The box is detected by controlling points, not the real path.
## Related
* [parse-svg-path](https://npmjs.org/parse-svg-path) - return svg path data segments
* [abs-svg-path](https://npmjs.org/abs-svg-path) - convert svg path to absolute values
* [rel-svg-path](https://npmjs.org/abs-svg-path) - convert svg path to relative values
* [normalize-svg-path](https://npmjs.org/normalize-svg-path) - make path consist of only bezier curve segments
* [draw-svg-path](https://npmjs.org/draw-svg-path) - create canvas shape based on svg path data
* [normalize-svg-coords](https://npmjs.org/normalize-svg-coords) - bring svg path coordinates to any linear range
## Similar
* [svg-boundings](https://www.npmjs.com/package/svg-boundings)
* [svg-path-bounding-box](https://github.com/icons8/svg-path-bounding-box)
## License
MIT © Dmitry Iv.