Members
rectPrototype
Rectangles inserted into the quadtree are extended with this object literal
- Source:
Methods
forceObjectWithinBounds(object, rect)
[forceObjectWithinBounds forces the inserted object into the quadtree bounds.
This makes the quadtree behave like pac-man when he goes into the opening on
the side of the map]
Parameters:
| Name | Type | Description |
|---|---|---|
object |
Object | [This is the parent-most quadtree] |
rect |
Object | [The inserted rectangle] |
- Source:
getBounds(r) → {Object}
[getBounds returns the bounds of a rectangle]
Parameters:
| Name | Type | Description |
|---|---|---|
r |
Object | [x, y, width, height] |
- Source:
Returns:
[left, right, top, bottom]
- Type
- Object
hasRectProps(object) → {Boolean}
[hasRectProps determines if the object has the necessary properties to be considered a rectangle]
Parameters:
| Name | Type | Description |
|---|---|---|
object |
Object | [The object questioned for rect props] |
- Source:
Returns:
[True if it is a rectangle]
- Type
- Boolean
isIntersecting(r1, r2) → {Boolean}
[isIntersecting returns true if two rectangles intersect]
Parameters:
| Name | Type | Description |
|---|---|---|
r1 |
Object | [rectangle] |
r2 |
Object | [rectangle] |
- Source:
Returns:
[True if two rectangles isIntersecting]
- Type
- Boolean
isWithinBounds(r1, r2) → {Boolean}
[isWithinBounds retuns true if rect2 is completely within rect1]
Parameters:
| Name | Type | Description |
|---|---|---|
r1 |
Object | [x, y, width, height] |
r2 |
Object | [x, y, width, height] |
- Source:
Returns:
[true if rect2 is completely within rect1]
- Type
- Boolean
remove(Item)
Removes the object and potentially collapses the quadTree
Parameters:
| Name | Type | Description |
|---|---|---|
Item |
Object | that was inserted into the quadTree |
- Source:
setQuadrant(object, quadtree)
setQuadrant sets the overlapping quadrants (quadtrees) given an object
Parameters:
| Name | Type | Description |
|---|---|---|
object |
Object | A rectangle that is inserted in the quadtree |
quadtree |
Object | A quadtree |
- Source: