tapspace
Version:
A zoomable user interface lib for web apps
38 lines (32 loc) • 841 B
JavaScript
const fine = require('affineplane')
const box3 = fine.box3
module.exports = (Box) => {
return function (basis, boxes) {
// @Box:fromBoxes(basis, boxes)
//
// Find the bounding box for the given set of boxes.
// The bounding box has the orientation of the given basis.
// Empty array will return zero-size box at origin.
//
// Parameters:
// basis
// a Component for the box
// boxes
// array of Box
//
// Return:
// a Box
//
if (boxes.length === 0) {
return new Box(basis, box3.ZERO)
}
// Transit the boxes onto the basis
const bs = []
for (let i = 0; i < boxes.length; i += 1) {
const b = boxes[i]
bs.push(b.transitRaw(basis))
}
const boundingBox = box3.getBounds(bs)
return new Box(basis, boundingBox)
}
}