blob: db0dced157127cc833fa3b0f45c965357190a5ad (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
// Takes a list of coordinate pairs (like the keys from a fetch block) and returns a dimension
function dims(coords){
ext = [[Infinity, Infinity], [-Infinity, -Infinity]]
for (let i=0; i<coords.length; i++){
let coord = coords[i];
if (coord[0] < ext[0][0]) ext[0][0] = coord[0];
if (coord[1] < ext[0][1]) ext[0][1] = coord[1];
if (coord[0] > ext[1][0]) ext[1][0] = coord[0];
if (coord[1] > ext[1][1]) ext[1][1] = coord[1];
}
return ext;
}
module.exports = dims
|