Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

infinite-poisson-disc-sampler

0.2.0 • Public • Published

Travis Badge

A poisson disc sampler implementation.

Classes

MultiSampler

A poisson sampler that is a grid of samplers (this allows infinite worlds to use this).

RandomSampler

A fast poison disc sampler. Based on https://www.jasondavies.com/poisson-disc/

PoissonDiscSampler

A fast poison disc sampler. Based on https://www.jasondavies.com/poisson-disc/

MultiSampler

A poisson sampler that is a grid of samplers (this allows infinite worlds to use this).

Kind: global class

new MultiSampler(w, h, cw, ch, r)

Create a multisampler.

Param Type Description
w Number The width of the entire sample space.
h Number The height of the entire sample space.
cw Number The width of each sub sampler.
ch Number The height of each subsampler.
r Number The minimum radius between samples.

multiSampler.getPoints() ⇒ Array

Get all points from all sub-samplers.

Kind: instance method of MultiSampler
Returns: Array - The array of points.

multiSampler.getPointsForCell(x, y) ⇒ Array

Get points for a single cell.

Kind: instance method of MultiSampler
Returns: Array - The array of points.

Param Type Description
x Number The x coord in the cell.
y Number The y coord in the cell.

multiSampler.resize(h, w)

Resize the multisampler.

Kind: instance method of MultiSampler

Param Type Description
h Number New height.
w Number New width.

multiSampler.prePopulate(points)

Prepopulates all the sub-samplers with the given points, rejecting ones outside the subsamplers.

Kind: instance method of MultiSampler

Param Type Description
points Array The points to seed subsamplers with.

RandomSampler

A fast poison disc sampler. Based on https://www.jasondavies.com/poisson-disc/

Kind: global class

new RandomSampler(width, height, x, y, radius)

constructor

Param Type Description
width Number The width of the sample space.
height Number The height of the sample space.
x Number The offset from "world" center (if you're using multiple samplers).
y Number The offset from world center.
radius Number The minimum radius between points.

randomSampler.getPoints() ⇒ Array

Get all sample points from sampler.

Kind: instance method of RandomSampler
Returns: Array - An array of points.

randomSampler.run()

Runs the sampler.

Kind: instance method of RandomSampler

randomSampler.remove(x, y)

Remove a sample from the grid. It will be replaced with new one the next time get points is called.

Kind: instance method of RandomSampler

Param Type Description
x Number The x coord.
y Number The y coord.

randomSampler.prePopulate(points)

Pre-populate the sampler with points.

Kind: instance method of RandomSampler

Param Type Description
points Array The points to add to the sampler.

PoissonDiscSampler

A fast poison disc sampler. Based on https://www.jasondavies.com/poisson-disc/

Kind: global class

new PoissonDiscSampler(width, height, x, y, radius)

constructor

Param Type Description
width Number The width of the sample space.
height Number The height of the sample space.
x Number The offset from "world" center (if you're using multiple samplers).
y Number The offset from world center.
radius Number The minimum radius between points.

poissonDiscSampler.getPoints() ⇒ Array

Get all sample points from sampler.

Kind: instance method of PoissonDiscSampler
Returns: Array - An array of points.

poissonDiscSampler.run()

Runs the sampler.

Kind: instance method of PoissonDiscSampler

poissonDiscSampler.remove(x, y)

Remove a sample from the grid. It will be replaced with new one the next time get points is called.

Kind: instance method of PoissonDiscSampler

Param Type Description
x Number The x coord.
y Number The y coord.

poissonDiscSampler.prePopulate(points)

Pre-populate the sampler with points.

Kind: instance method of PoissonDiscSampler

Param Type Description
points Array The points to add to the sampler.

Keywords

none

Install

npm i [email protected]

Version

0.2.0

License

MIT

Unpacked Size

32 kB

Total Files

14

Last publish

Collaborators

  • avatar