JSPM

getboundingbox

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 10
  • Score
    100M100P100Q43308F
  • License MIT

This is a utility function to calculate the bounding box of series of 2D points

Package Exports

  • getboundingbox

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (getboundingbox) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

getboundingbox

stable

This is a utility function to calculate the bounding box of series of 2D points

var getBounds = require('getboundingbox')

var path = [ [-100, 12], [-52, 25], [6, 13] ]
var box = getBounds(path)

The result will be:

{ 
    maxX: 6,
    maxY: 25, 
    minX: -100, 
    minY: 12 
}

Usage

NPM

bounds(path[, out])

Computes the min and max [x, y] points for the given path. If path is an empty array, the bounds will be empty (all zero).

You can specify out to re-use an object rather than creating a new one.

This is safe to with Array.map/filter/etc, e.g.

if (paths.map(bounds).some(intersect)) {
    ...
}

License

MIT, see LICENSE.md for details.