Skip to content

Commit 41357ab

Browse files
authored
adding the tiniest bit of documentation (#36)
1 parent 200153d commit 41357ab

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

README.md

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,27 @@
1-
A QuadTree example for JavaScript with [p5.js](http://p5js.org).
1+
A QuadTree example (and almost sort of a JavaScript library) with [p5.js](http://p5js.org).
22

3-
# QuadTree
3+
## QuadTree
44
* [QuadTree on wikipedia](https://en.wikipedia.org/wiki/Quadtree)
55
* [QuadTree pseudo-code](https://en.wikipedia.org/wiki/Quadtree#Pseudo_code)
66
* [QuadTree video tutorial part 1](https://youtu.be/OJxEcs0w_kE)
77
* [QuadTree video tutorial part 2](https://youtu.be/QQx_NmCIuCY)
88

9-
# QuadTree Code and Example
10-
* [QuadTree Repo](https://github.com/CodingTrain/QuadTree)
11-
* [QuadTree code](https://github.com/CodingTrain/QuadTree/blob/master/quadtree.js)
12-
* Visualize the QuadTree: [code](https://github.com/CodingTrain/QuadTree/tree/master/examples/visualize_qtree), [demo](https://codingtrain.github.io/QuadTree/examples/visualize_qtree/)
13-
* Collision Detection with QuadTree: [code](https://github.com/CodingTrain/QuadTree/tree/master/examples/intersection_qtree), [demo](https://codingtrain.github.io/QuadTree/examples/intersection_qtree/)
9+
## How to use
10+
* You can download and include `quadtree.js` in your p5 sketch or refer to it via this CDN link:
1411

15-
# Testing
12+
```html
13+
<script src="https://cdn.jsdelivr.net/gh/CodingTrain/QuadTree/quadtree.js"></script>
14+
```
15+
16+
Once you've include the library you can create a `QuadTree` object a `Rectangle` boundary and maximum capacity:
17+
18+
```javascript
19+
const r = new Rectangle(0, 0, width, height);
20+
const capacity = 4;
21+
const quadtree = new QuadTree(r, capacity);
22+
```
23+
24+
## Testing
1625
To run tests use one of the following commands
1726

1827
For continuous testing
@@ -26,10 +35,11 @@ npm run test
2635
```
2736
This will output to the `coverage` folder where you can few test coverage by opening index.html
2837

29-
# Other QuadTree libraries in JS
38+
## Other QuadTree libraries in JS
3039
* [quadtree-js](https://github.com/timohausmann/quadtree-js)
3140
* [d3-quadtree](https://github.com/d3/d3-quadtree)
3241

33-
# Other Versions
34-
## Ports to other languages
42+
## Other Versions
43+
44+
### Ports to other languages
3545
* Carla de Beer (Processing port) - [GitHub](https://github.com/Carla-de-Beer/Processing/tree/master/QuadTree)

0 commit comments

Comments
 (0)