Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hughsk/continuous-observer
Automatically manage chunks in a continuous ndarray, given a set of "observable" positions.
https://github.com/hughsk/continuous-observer
Last synced: 12 days ago
JSON representation
Automatically manage chunks in a continuous ndarray, given a set of "observable" positions.
- Host: GitHub
- URL: https://github.com/hughsk/continuous-observer
- Owner: hughsk
- License: other
- Created: 2013-07-13T06:21:36.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-10-10T04:29:06.000Z (about 11 years ago)
- Last Synced: 2024-10-17T16:41:25.441Z (22 days ago)
- Language: JavaScript
- Size: 118 KB
- Stars: 4
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# continuous-observer #
Take a [continuous ndarray](http://github.com/hughsk/ndarray-continuous) and, given a
set of "observable" positions, automatically add and remove chunks as required.Use this for painless chunk management with one or more visible perspectives.
## Installation ##
``` bash
npm install continuous-observer
```## Usage ##
### `observe = require('continuous-observer')(field[, range[, linger]])` ###
Returns a function that can be used to update the chunks in use, given a
continuous ndarray (`field`). Optionally:* `range` is the amount of surrounding chunks to include. Defaults to 1.
* `linger` is the amount of surrounding chunks to not remove when cleaning up.
Defaults to `range`, and cannot be set to below `range`.### `observe(points)` ###
`points` is an array of arrays, with each array representing an observer's
position. Can also handle a single array as well, if you're only using one
observer.``` javascript
// Create a continuous ndarray with 32x32 chunks
var field = require('ndarray-continuous')({ shape: [32, 32] })
// Create the observer
var moveTo = require('continuous-observer')(field, 1, 2)// "Move" the observer to the origin
moveTo([0, 0])// Ahead one chunk
moveTo([32, 32])// Ahead another chunk - this will remove
// some of the older chunks.
moveTo([32, 32])// Including another observer just involves
// adding another position to the array.
moveTo([[32, 32], [0, 0]])
```