aboutsummaryrefslogtreecommitdiff
path: root/utils/measurespace.js
blob: 4020926f1e6102462d7b2efe9e28c4767d7411b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
// Provides a utility which takes a Space, and returns its minimum and maximum x/y coordinates, based on .loc and .data

const vec = require('./vec');

module.exports = function(space){
  let min = space.loc;
  let data = space.data;
  let disp = [data.length, 0];
  for (let i = 0; i < data.length; i++){
    disp[1] = Math.max(disp[1], data[i].length);
  }
  return [min, vec.add(min, disp)];
}