## Stats

StarsIssuesVersionUpdatedCreatedSize
311.5.06 years ago6 years ago

A map-styled quadtree. Also supports multi-variables (uses collections/fast-map)

## Usage

``````var QuadMap = require("QuadMap");
``````

To insert a node

``````var QuadMap = require("QuadMap");

var node = {
position: {x:10,y: 20},
name: "hello",
color: {R:0,G:0,B:0}
node.id: id
}
``````

To get a node

``````quadMap.get(id)
``````

To get the nodes in the nodes quad

``````var quad = quadMap.getQuadById(id);
``````

To get the nodes in a box

``````var box = {
top: 20,
bottom: 0,
left: -1,
right: 10,
}
// Note that it is wise to set the recursive option to true, because if the box is too big for a bottom quad, then it will return a quad it fits.
``````

To change the position variable

``````var QuadMap = require("QuadMap");

var node = {
pos: {x:10,y: 20}, // Note the var is now "pos" not "position". "position" is default
name: "hello",
color: {R:0,G:0,B:0}
node.id: id
}
``````

To change the max amount of levels

``````quadMap.setMaxLevel(number);
``````

`quadMap.addVar("something")`

To add a object to a variable

``````quadMap.something.set(id,obj); // Note this also adds it to the MASTER nodes list
``````

To get a list of objects in a var inside a quad

``````var nodes = quad.something.getNodes(recursive,keep);
``````

## Documentation

Insert an item

returns the item based on its id.

deleted the node based apon its id

gets the quad based apon the pos

gets the quad the box fits into

Gets the nodes in a quad. If recursive is true, then any nodes in quads under the quad will also be included. if include is true, then it will return an onject like below.

{ node: node, QTree: quad, compiled: true, stored: true, }

The original node can be found in the .node variable, and the QTree is the quad it resides in. Compiled and stored are system variables.