
Security News
OpenGrep Restores Fingerprinting in JSON and SARIF Outputs
OpenGrep has restored fingerprint and metavariable support in JSON and SARIF outputs, making static analysis more effective for CI/CD security automation.
A javascript implementation of the Bridson algorithm for generating Poisson-disc distributions
v0.0.3
A simple Bridson algorithm for generating Poisson-disc distributions This is a very simple, rushed implementation; I'm sure it could be lot more performant and concise. Nevertheless, have fun!
For more detailed info about the algorithm, check Donald Norman's article 'Visualizing Algorithms'.
This module exports a function, wich accepts a single options object and returns an array of points, represented as two-element arrays, e.g.: [[x1, y1], [x2, y2], ...]
.
Basically, you provide a bounding box or custom shape and a minimum distance between points and a random, even distribution is generated.
Check below for available options.
Note: the point
type stand for a two-element array containing the x and y coordinates of a point, respectively.
The origin, or base corner of the bounding box. An array of two coordinates, i.e. [x, y]
. Default: [0, 0]
.
The corner opposite origin
in the bounding box. An array of two coordinates. Optional, if you pass width
and height
.
The width of the bounding box. Optional, if you pass max
.
The height of the bounding box. Optional, if you pass max
.
The minimum radius between points. This will define the density of the points.
Optionally add some padding to the box. Points at the edge of the bounding box may be very close to the edge; if you try to draw them, with a certain radius, part of them will be drawn outside the box. Set contain to the appropriate value to make sure this doesn't happen. By default, the whole bounding box is filled.
array
: values for the left, top, bottom and right padding (in that order)number
: one value for all the edgestrue
: use r
as paddingInclude the number of iterations the algorithm performed with the result. By default, this is not done.
true
: the returned array will have a iterations
propertystring
: the returned array will have a property named after the value of iterations
The amount of candidates to generate and check for each iteration. Default: 15.
This module has some easy to use options for working with rectangles. If you work with any other shape, however, include a function in the isInside
property of the options object. This function gets x and y coordinates of candidate points and should return true
if the point is inside your shape, or false
otherwise. If the point is not inside the custom shape, it will be rejected; thus, the result won't include any points outside your shape. By default, a bounding box is used.
The starting point(s) for the algorithm.
array(point)
: will be used as the pool of active points. A random point out of this stack will bes used as the starting pointpoint
: will be used as the starting pointIf you're using the bounding box method, this option is optional: a random point within the bounding box will be used to start. If you're using a custom shape, however, automatically generating a starting point is tricky.
You can use an isInside
function and a bounding box, causing isInside
to be used to check if points are valid, and the starting point to be generated inside the bounding box. If you specify a bounding box that is completely inside your shape, this could work (you couldn't call it a 'bounding box' anymore though).
A better option is just specifying a starting point yourself. Make sure it's inside your shape, though!
FAQs
A javascript implementation of the Bridson algorithm for generating Poisson-disc distributions
We found that bridson demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
OpenGrep has restored fingerprint and metavariable support in JSON and SARIF outputs, making static analysis more effective for CI/CD security automation.
Security News
Security experts warn that recent classification changes obscure the true scope of the NVD backlog as CVE volume hits all-time highs.
Security Fundamentals
Attackers use obfuscation to hide malware in open source packages. Learn how to spot these techniques across npm, PyPI, Maven, and more.