aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorHolden Rohrer <holden.rohrer@gmail.com>2020-01-08 17:45:54 -0500
committerHolden Rohrer <holden.rohrer@gmail.com>2020-01-08 17:46:06 -0500
commit233b118dd60495e8ba012ec96903441af05e4b15 (patch)
treedd3217aea8e7f31ebb816a2fd6f7ad16ee7115c9 /tools
parent0974dbfa029acc8dcf2635c2cc43a3471848fb1c (diff)
added search.update, integrating rasterization
Diffstat (limited to 'tools')
-rw-r--r--tools/search.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/tools/search.js b/tools/search.js
index fc9817a..38a1124 100644
--- a/tools/search.js
+++ b/tools/search.js
@@ -6,6 +6,7 @@ const bs = require('binary-search');
const Space = require('../space');
const comb = require('../utils/comb')
const vec = require('../utils/vec');
+const raster = require('../utils/raster');
function getComp(index){
return (element,needle) => (element[index] - needle[index] || element[1-index] - needle[1-index])
@@ -75,6 +76,14 @@ function Search(searchBlock){ // searchBlock should be a Space object.
// bs returns negative if not found.
else return true;
}
+
+ this.update = function(space){ // Must be a space w/ valid loc; allows overlay of some arbitrary text (in the space) mostly for recording updates from the server without directly cataloguing them
+ let tiles = raster(space); // Returns a this.tiles-style binding: {'2,-3':Space object}
+ for (tile in tiles){
+ if (this.tiles[tile]) this.tiles[tile].comb(tiles[tile], comb.flip(comb.add));
+ else this.add(tile, tiles[tile]);
+ }
+ }
}
module.exports = Search;