2.1.0 • Published 3 months ago

svg-path-bbox v2.1.0

Weekly downloads
1,333
License
BSD-3-Clause
Repository
github
Last release
3 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 | typeof import('svgpath')) ⇒ minX: number, minY: number, maxX: number, maxY: number

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

  • d (string | typeof import('svgpath')) SVG path. Can be a string or a SvgPath interface from svgpath.

Thanks to

2.1.0

3 months ago

2.0.0

6 months ago

1.2.6

8 months ago

1.2.5

8 months ago

1.2.4

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.2.0

3 years ago

1.2.1

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.2.0

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 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

5 years ago

0.0.25

5 years ago

0.0.26

5 years ago

0.0.24

5 years ago

0.0.23

5 years ago

0.0.22

5 years ago

0.0.21

5 years ago

0.0.20

5 years ago

0.0.18

5 years ago

0.0.19

5 years ago

0.0.14

5 years ago

0.0.15

5 years ago

0.0.16

5 years ago

0.0.17

5 years ago

0.0.13

5 years ago

0.0.12

5 years ago

0.0.11

5 years ago

0.0.10

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago