1.2.6 • Published 2 months ago

svg-path-bbox v1.2.6

Weekly downloads
1,333
License
BSD-3-Clause
Repository
github
Last release
2 months ago

📦 svg-path-bbox

NPM version License NodeJS versions

SVG paths bounding box calculator.

Status

Tests Coverage status

Install

npm install svg-path-bbox

Documentation

Usage

> import svgPathBbox from "svg-path-bbox";
> svgPathBbox("M5 10l2 3z")
[ 5, 10, 7, 13 ]
> svgPathBbox("M5 10c3 0 3 3 0 3z")
[ 5, 10, 7.25, 13 ]

Returned bounding box is an array made up like viewBox SVG attributes [x0, y0, x1, y1] of unrounded values:

Command line

$ svg-path-bbox "M5 10c3 0 3 3 0 3z"
5 10 7.25 13

$ svg-path-bbox "M5 10c3 0 3 3 0 3z" "M2 8m5 5z"
5 10 7.25 13
2 8 7 13

Typescript usage

import svgPathBbox from "svg-path-bbox";
import type { BBox } from "svg-path-bbox";

const cases: [string, BBox][] = [["M0 0H3V6Z", [0, 0, 3, 6]]];
console.log(svgPathBbox(cases[0]));

Reference

# svgPathBbox(d : string) ⇒ minX: number, minY: number, maxX: number, maxY: number

Computes the bounding box of SVG path following the SVG 1.1 specification.

  • d (string) SVG path.

Thanks to

1.2.6

2 months ago

1.2.5

2 months ago

1.2.4

1 year ago

1.2.3

1 year ago

1.2.2

2 years ago

1.2.0

2 years ago

1.2.1

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.2

2 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.2.0

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago

0.0.48

4 years ago

0.0.49

4 years ago

0.0.45

4 years ago

0.0.46

4 years ago

0.0.42

4 years ago

0.0.43

4 years ago

0.0.37

4 years ago

0.0.39

4 years ago

0.0.36

4 years ago

0.0.32

4 years ago

0.0.33

4 years ago

0.0.34

4 years ago

0.0.35

4 years ago

0.0.30

4 years ago

0.0.31

4 years ago

0.0.29

4 years ago

0.0.28

4 years ago

0.0.27

4 years ago

0.0.25

4 years ago

0.0.26

4 years ago

0.0.24

4 years ago

0.0.23

4 years ago

0.0.22

4 years ago

0.0.21

4 years ago

0.0.20

4 years ago

0.0.18

4 years ago

0.0.19

4 years ago

0.0.14

4 years ago

0.0.15

4 years ago

0.0.16

4 years ago

0.0.17

4 years ago

0.0.13

4 years ago

0.0.12

4 years ago

0.0.11

4 years ago

0.0.10

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago