aboutsummaryrefslogtreecommitdiff
path: root/utils/measurespace.js
blob: 1cd1fcc042688184f7e208600d1703393620d9fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// 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;
  if (min.length === 0) min = [0,0];
  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)];
}