source: node_modules/d3-quadtree/src/visitAfter.js@ e4c61dd

Last change on this file since e4c61dd was e4c61dd, checked in by istevanoska <ilinastevanoska@…>, 6 months ago

Prototype 1.1

  • Property mode set to 100644
File size: 776 bytes
Line 
1import Quad from "./quad.js";
2
3export default function(callback) {
4 var quads = [], next = [], q;
5 if (this._root) quads.push(new Quad(this._root, this._x0, this._y0, this._x1, this._y1));
6 while (q = quads.pop()) {
7 var node = q.node;
8 if (node.length) {
9 var child, x0 = q.x0, y0 = q.y0, x1 = q.x1, y1 = q.y1, xm = (x0 + x1) / 2, ym = (y0 + y1) / 2;
10 if (child = node[0]) quads.push(new Quad(child, x0, y0, xm, ym));
11 if (child = node[1]) quads.push(new Quad(child, xm, y0, x1, ym));
12 if (child = node[2]) quads.push(new Quad(child, x0, ym, xm, y1));
13 if (child = node[3]) quads.push(new Quad(child, xm, ym, x1, y1));
14 }
15 next.push(q);
16 }
17 while (q = next.pop()) {
18 callback(q.node, q.x0, q.y0, q.x1, q.y1);
19 }
20 return this;
21}
Note: See TracBrowser for help on using the repository browser.