# wbroberts-quadtree-outline

> A Quadtree data structure written in Typescript.

Latest version **0.0.1** (published 2019-08-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install wbroberts-quadtree-outline
pnpm add wbroberts-quadtree-outline
yarn add wbroberts-quadtree-outline
bun add wbroberts-quadtree-outline
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2019-08-23 |
| First published | 2019-08-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 7.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | William Roberts |
| Maintainers | wbroberts |
| Keywords | data-structure, typescript |

## Links

- npm: https://www.npmjs.com/package/wbroberts-quadtree-outline
- Repository: https://github.com/wbroberts/quadtree
- Homepage: https://github.com/wbroberts/quadtree#readme
- Issues: https://github.com/wbroberts/quadtree/issues
- npm.io page: https://npm.io/package/wbroberts-quadtree-outline

## Dependencies (2)

- [typescript](https://npm.io/package/typescript.md) ^3.5.3
- [@types/node](https://npm.io/package/@types/node.md) ^12.7.2

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 0.0.1 (latest) — 2019-08-23

## README

# Quadtree

Check out a live [demo](https://www.quadtree.williambarronroberts.com) of this quadtree being in action with a canvas element.

`npm install wbroberts-quadtree`

```javascript
import { QuadTree, AreaBoundary } from 'wbroberts-quadtree';

const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
canvas.width = 500;
canvas.height = 500;

const qTree = new QuadTree(
  { x: 0, y: 0, width: canvas.width, height: canvas.height },
  ctx,
  4
);
const point = { x: 10, y: 10, radius: 10, data: null };

qTree.insert(point); // Inserts it into the quadtree. If the quadtree has more than 4 points, it divides into four more quadtrees.

const area = new AreaBoundary({
  x: 0,
  y: 0,
  width: 20,
  height: 20,
});
const query = qTree.query(area);

console.log(query); // [{ x: 10, y: 10, radius: 10, data: null }]

const area2 = new AreaBoundary({
  x: 20,
  y: 20,
  width: 20,
  height: 20,
});
const query2 = qTree.query(area2);

console.log(query2); // []
```

This project was to learn about quadtree data structures. My goal was to successfully create one that I would be able to use in 2d canvas games for the web (primarily mine).

---
_Source: https://npm.io/package/wbroberts-quadtree-outline · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
