Nascent Prototype Metaverse
    Wondering what’s next for npm?Check out our public roadmap! »

    svg-path-bbox
    DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/svg-path-bbox package

    0.2.0 • Public • Published

    📦 svg-path-bbox

    NPM version License NodeJS versions

    SVG paths bounding box calculator.

    Status

    Tests Coverage status

    Installation

    npm install svg-path-bbox
    

    Documentation

    Usage

    > const { svgPathBbox } = require("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

    Reference

    # svgPathBbox(d) ⇒ Array

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

    • d (string) SVG path.

    Thanks to

    Keywords

    Install

    npm i svg-path-bbox

    DownloadsWeekly Downloads

    836

    Version

    0.2.0

    License

    GPL-3.0

    Unpacked Size

    18.2 kB

    Total Files

    7

    Last publish

    Collaborators

    • avatar