npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

infinite-poisson-disc-sampler

v0.15.0

Published

![Travis Badge](https://travis-ci.org/vantreeseba/poisson-sampler.svg?branch=master)

Downloads

2

Readme

Travis Badge

A poisson disc sampler implementation.

Example Codepen

Classes

MultiSampler

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

Kind: global class

new MultiSampler(config)

Create a multisampler.

| Param | Type | Default | Description | | --- | --- | --- | --- | | config | Object | | The config for the sampler. | | [config.w] | Number | 64 | The width of the entire sample space. | | [config.h] | Number | 64 | The height of the entire sample space. | | [config.cw] | Number | 32 | The width of each sub sampler. | | [config.ch] | Number | 32 | The height of each subsampler. | | [config.r] | Number | 10 | 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.getNewPoints() ⇒ Array

Get new sample points from sampler.

Kind: instance method of MultiSampler
Returns: Array - An 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. |

multiSampler.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 MultiSampler

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

RandomSampler

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

Kind: global class

new RandomSampler(config)

constructor

| Param | Type | Default | Description | | --- | --- | --- | --- | | config | Object | | The config for the sampler. | | [config.w] | Number | 64 | The width of the sample space. | | [config.h] | Number | 64 | The height of the sample space. | | [config.x] | Number | 0 | The offset from "world" center (used by multisampler). | | [config.y] | Number | 0 | The offset from world center. | | [config.r] | Number | 10 | 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.getNewPoints(The) ⇒ Array

Get new sample points from sampler.

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

| Param | Type | Description | | --- | --- | --- | | The | Number | number of new points desired. |

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(config)

constructor

| Param | Type | Default | Description | | --- | --- | --- | --- | | config | Object | | The config for the sampler. | | [config.w] | Number | 64 | The width of the sample space. | | [config.h] | Number | 64 | The height of the sample space. | | [config.x] | Number | 0 | The offset from "world" center (used by multisampler). | | [config.y] | Number | 0 | The offset from world center. | | [config.r] | Number | 10 | 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.getNewPoints(The) ⇒ Array

Get new sample points from sampler.

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

| Param | Type | Description | | --- | --- | --- | | The | Number | number of new points desired. |

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. |