Class: PoissonDisc

PoissonDisc(w, h, r, k, n)

A Poisson Disc Sampling routine - randomly but evenly place dots on the screen..

Constructor

new PoissonDisc(w, h, r, k, n)

Create a new disc sampler
Parameters:
Name Type Description
w Number Width of the display in pixels
h Number Height of the display in pixels
r Number The minimum distance between points
k Number Number of tries to make a new point before giving up
n Number n-dimensional grid
Properties:
Name Type Description
width Number Width of the display in pixels
height Number Height of the display in pixels
r Number The minimum distance between points
k Number Number of tries to make a new point before giving up
n Number n-dimensional grid
cellSize Number The size of the grid cell = r / sqrt(n)
cols Number Number of columns in the grid
rows Number Number of rows in the grid
points Array.<Object> Array of points already plotted
active Array.<Number> Array of active points indices
grid Array.<Number> Grid array of point indices
Author:
Source:

Methods

addPoint(x, y)

Add a new point to the points, grid and active arrays. Points array holds the point data and grid / active hold indices to the points array.
Parameters:
Name Type Description
x Number The pixel X position of the point
y Number The pixel Y position of the point
Source:

getRandom(min, max) → {Number}

Get a random integar between min and max
Parameters:
Name Type Description
min Number The minimum value
max Number The maximum value
Source:
Returns:
Random number from min to max
Type
Number

initialiseGrid()

Initialise the empty background grid array
Source:

reset()

Reset the algorithm and data
Source:

run()

Run the algorithm till the end
Source:

step()

Take a single or n steps through the algorithm
Source: