From cb7d31d863320db9257a619eea0422cc43bb05a4 Mon Sep 17 00:00:00 2001 From: Holden Rohrer Date: Wed, 18 Dec 2019 20:56:40 -0500 Subject: added getdims and removed bug notice on README --- README.md | 2 +- utils/getdims.js | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 utils/getdims.js diff --git a/README.md b/README.md index 158aed2..88f1cfe 100644 --- a/README.md +++ b/README.md @@ -18,4 +18,4 @@ Currently, `socket.js` provides `Socket` which has a few signals and functions ( `space.js` provides some dense spatial data management with `Space`, which is really good for specific dialogs and tests, but there may be some more work to be done to create a sparse storage device. -`examples/helloworld.js` can get you started. Everything in that should work pretty well, but the remainder of the repo is probably pretty buggy until I test it. +`examples/helloworld.js` can get you started. Everything in the core API (`utils`, `socket.js`, `space.js`) should be pretty stable, but please don't hesitate to report a bug. diff --git a/utils/getdims.js b/utils/getdims.js new file mode 100644 index 0000000..2c18964 --- /dev/null +++ b/utils/getdims.js @@ -0,0 +1,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 ext[1][0]) ext[1][0] = coord[0]; + if (coord[1] > ext[1][1]) ext[1][1] = coord[1]; + } + return ext; +} + +exports = dims -- cgit