blob: 2c189640625032c9f0cf472ebbfe4d4172b8786a (
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;
}
exports = dims
|