{"id":16533818,"url":"https://github.com/kchapelier/fast-2d-poisson-disk-sampling","last_synced_at":"2025-09-22T01:31:30.685Z","repository":{"id":57232943,"uuid":"266502168","full_name":"kchapelier/fast-2d-poisson-disk-sampling","owner":"kchapelier","description":"Fast 2D Poisson Disk Sampling based on a modified Bridson algorithm","archived":false,"fork":false,"pushed_at":"2022-05-28T14:24:46.000Z","size":124,"stargazers_count":35,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-04T03:46:36.917Z","etag":null,"topics":["javascript","poisson","procedural-generation","sampling"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kchapelier.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-24T08:43:38.000Z","updated_at":"2024-12-22T04:39:46.000Z","dependencies_parsed_at":"2022-08-31T20:51:16.467Z","dependency_job_id":null,"html_url":"https://github.com/kchapelier/fast-2d-poisson-disk-sampling","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/kchapelier/fast-2d-poisson-disk-sampling","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kchapelier%2Ffast-2d-poisson-disk-sampling","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kchapelier%2Ffast-2d-poisson-disk-sampling/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kchapelier%2Ffast-2d-poisson-disk-sampling/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kchapelier%2Ffast-2d-poisson-disk-sampling/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kchapelier","download_url":"https://codeload.github.com/kchapelier/fast-2d-poisson-disk-sampling/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kchapelier%2Ffast-2d-poisson-disk-sampling/sbom","scorecard":{"id":552805,"data":{"date":"2025-08-11","repo":{"name":"github.com/kchapelier/fast-2d-poisson-disk-sampling","commit":"68e9d98fbff5c376a1b3eb187d48db597c7a8c1f"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":0,"reason":"Found 0/13 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Vulnerabilities","score":0,"reason":"15 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-x9w5-v3q2-3rhw","Warn: Project is vulnerable to: GHSA-434g-2637-qmqr","Warn: Project is vulnerable to: GHSA-49q7-c7j4-3p7m","Warn: Project is vulnerable to: GHSA-977x-g7h5-7qgw","Warn: Project is vulnerable to: GHSA-f7q4-pwc6-w24p","Warn: Project is vulnerable to: GHSA-fc9h-whq2-v747","Warn: Project is vulnerable to: GHSA-vjh7-7g9h-fjfh","Warn: Project is vulnerable to: GHSA-4q6p-r6v2-jvc5","Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55","Warn: Project is vulnerable to: GHSA-h7cp-r72f-jxh6","Warn: Project is vulnerable to: GHSA-v62p-rq8g-8h59","Warn: Project is vulnerable to: GHSA-76p7-773f-r4q5","Warn: Project is vulnerable to: GHSA-4wf5-vphf-c2xc"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-20T11:22:23.169Z","repository_id":57232943,"created_at":"2025-08-20T11:22:23.170Z","updated_at":"2025-08-20T11:22:23.170Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276333822,"owners_count":25624044,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-21T02:00:07.055Z","response_time":72,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","poisson","procedural-generation","sampling"],"created_at":"2024-10-11T18:15:55.250Z","updated_at":"2025-09-22T01:31:30.341Z","avatar_url":"https://github.com/kchapelier.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fast-2d-poisson-disk-sampling\n\n[![Build Status](https://travis-ci.org/kchapelier/fast-2d-poisson-disk-sampling.svg)](https://travis-ci.org/kchapelier/fast-2d-poisson-disk-sampling) [![NPM version](https://badge.fury.io/js/fast-2d-poisson-disk-sampling.svg)](http://badge.fury.io/js/fast-2d-poisson-disk-sampling)\n\nFast 2D Poisson Disk Sampling based on a modified Bridson algorithm.\n\n## Installing\n\nWith [npm](https://www.npmjs.com/) do:\n\n```\nnpm install fast-2d-poisson-disk-sampling\n```\n\nWith [yarn](https://yarnpkg.com/) do:\n\n```\nyarn add fast-2d-poisson-disk-sampling\n```\n\nA compiled version for web browsers is also available on a CDN:\n\n```html\n\u003cscript src=\"https://cdn.jsdelivr.net/gh/kchapelier/fast-2d-poisson-disk-sampling@1.0.3/build/fast-poisson-disk-sampling.min.js\"\u003e\u003c/script\u003e\n```\n\n## Features\n\n- Can be used with a custom RNG function.\n- Allow the configuration of the max number of tries.\n- Same general API as [poisson-disk-sampling](https://github.com/kchapelier/poisson-disk-sampling) and [jittered-hexagonal-grid-sampling](https://github.com/kchapelier/jittered-hexagonal-grid-sampling).\n- Speed, see [benchmark results](https://github.com/kchapelier/fast-2d-poisson-disk-sampling/blob/master/BENCHMARK.md).\n\n## Basic example\n\n```js\nvar p = new FastPoissonDiskSampling({\n    shape: [500, 200],\n    radius: 6,\n    tries: 20\n});\nvar points = p.fill();\n\nconsole.log(points); // array of sample points, themselves represented as simple arrays\n```\n\n### Result as an image\n\n\u003cimg src=\"https://github.com/kchapelier/fast-2d-poisson-disk-sampling/raw/master/img/example1.png\" style=\"image-rendering:pixelated; width:500px;\"\u003e\u003c/img\u003e\n\n## Public API\n\n### Constructor\n\n**new FastPoissonDiskSampling(options[, rng])**\n\n- *options :*\n  - *shape :* Size/dimensions of the grid to generate points in, required.\n  - *radius :* Minimum distance between each points, required.\n  - *tries :* Maximum number of tries per point, defaults to 30.\n- *rng :* A function to use as random number generator, defaults to Math.random.\n\nNote: \"minDistance\" can be used instead of \"radius\", ensuring API compatibility with [poisson-disk-sampling](https://github.com/kchapelier/poisson-disk-sampling).\n\nThe following code will allow the generation of points where both coordinates will range from *0 up to 50* (including 0, but not including 50, **0 \u003c= c \u003c 50**).\n\n```js\nvar pds = new FastPoissonDiskSampling({\n    shape: [50, 50],\n    radius: 4,\n    tries: 10\n});\n```\n\n### Method\n\n**pds.fill()**\n\nFill the grid with random points following the distance constraint.\n\nReturns the entirety of the points in the grid as an array of coordinate arrays. The points are sorted in their generation order.\n\n```js\nvar points = pds.fill();\n\nconsole.log(points[0]);\n// prints something like [30, 16]\n```\n\n**pds.getAllPoints()**\n\nGet all the points present in the grid without trying to generate any new points.\n\nReturns the entirety of the points in the grid as an array of coordinate arrays. The points are sorted in their generation order.\n\n```js\nvar points = pds.getAllPoints();\n\nconsole.log(points[0]);\n// prints something like [30, 16]\n```\n\n**pds.addRandomPoint()**\n\nAdd a completely random point to the grid. There won't be any check on the distance constraint with the other points already present in the grid.\n\nReturns the point as a coordinate array.\n\n**pds.addPoint(point)**\n\n- *point :* Point represented as a coordinate array.\n\nAdd an arbitrary point to the grid. There won't be any check on the distance constraint with the other points already present in the grid.\n\nReturns the point added to the grid.\n\nIf the given coordinate array does not have a length of 2 or doesn't fit in the grid size, null will be returned.\n\n```js\npds.addPoint([20, 30]);\n```\n\n**pds.next()**\n\nTry to generate a new point in the grid following the distance constraint.\n\nReturns a coordinate array when a point is generated, null otherwise.\n\n```js\nvar point;\n\nwhile(point = pds.next()) {\n    console.log(point); // [x, y]\n}\n```\n\n**pds.reset()**\n\nReinitialize the grid as well as the internal state.\n\nWhen doing multiple samplings in the same grid, it is preferable to reuse the same instance of PoissonDiskSampling instead of creating a new one for each sampling.\n\n## History\n\n### [1.0.3](https://github.com/kchapelier/fast-2d-poisson-disk-sampling/tree/1.0.3) (2022-05-28) :\n\n- Fix potential floating point issue when working with shape's bounds \u003e 512\n- Performance tweaks (~10% faster)\n\n### [1.0.2](https://github.com/kchapelier/fast-2d-poisson-disk-sampling/tree/1.0.2) (2022-05-21) :\n\n- Update dev dependencies, add a test to the test suite\n\n### [1.0.1](https://github.com/kchapelier/fast-2d-poisson-disk-sampling/tree/1.0.1) (2020-05-24) :\n\n- Tweaks to improve the result (higher point density)\n\n### [1.0.0](https://github.com/kchapelier/fast-2d-poisson-disk-sampling/tree/1.0.0) (2020-05-24) :\n\n- First release\n\n## Roadmap\n\nWrite a proper description of the algorithm.\n\n## How to contribute ?\n\nFor new features and other enhancements, please make sure to contact me beforehand, either on [Twitter](https://twitter.com/kchplr) or through an issue on Github.\n\n## License\n\nMIT","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkchapelier%2Ffast-2d-poisson-disk-sampling","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkchapelier%2Ffast-2d-poisson-disk-sampling","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkchapelier%2Ffast-2d-poisson-disk-sampling/lists"}