Observed since 20 Oct, 19:10 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
2d-density
Calulates how full a grid will be if each item is spaced out by a given amount
An algorithm than can be used to find the maximum number of cells that can fit into a grid with a predefined spacing. In other words two-dimensional density.
npm install 2d-density
const twoDDensity = require('2d-density');
const gridWidth = 100;
const gridHeight = 100;
const spacing = 3;
const result = twoDDensity.findPercentFull(gridWidth, gridHeight, spacing);
Width, height and spacing should all be whole numbers.
Spacing does not count diagonals. Thus a cell that is diagonally adjacent is really spaced 2 cells away.
{
count: 2000,
percent: 0.2
}
Say you have a grid with a width of 5 and a height of 4 and you want to fill cells that are 2 away from each other. You might end up with something like this:
| x | x | x | ||
|---|---|---|---|---|
| x | x | |||
| x | x | x | ||
| x | x |
The count would be 10 and percentage full would be 0.5. This would be pretty easy to calculate for spacing of 2 but things get more complex when using spacings with odd numbers.
For example a 5 by 5 grid with spacing of 3.
| x | x | |||
|---|---|---|---|---|
| x | ||||
| x | x | |||
The count is only 5 and the percentage would be 0.2.
Download counts and popularity will appear here as the collector receives them.
| Package / target | Requirement | Relationship |
|---|---|---|
jasmineEnvironment{
"local_name": "jasmine",
"alias": false,
"peer_metadata": null
} | ^3.0.0 | development |
Source distribution
{
"integrity": "sha512-HPSh75cZUovTeTV91oTqg4WWOBnYZGYSP6SidbVTeIdO169LkzrVJYLt3FW1PY8kjZeXQheeZicO2651OCRDyA==",
"shasum": "8cac93db0a42b57a7df12810ba8603e0cfed4b22",
"tarball": "https://registry.npmjs.org/2d-density/-/2d-density-1.0.0.tgz",
"fileCount": 7,
"unpackedSize": 13660,
"signatures": [
{
"keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
"sig": "MEUCIDvqt+nQGY3uCPzk8WBtYBYlWDfTVF7T8FckaSuCGtXAAiEAveUKOc/G7FyxkXuDt5mGW4nra2EUcP0i/Sm9ajrN8eM="
}
]
}Observed since 20 Oct, 19:10 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package_version:cfb077f38d488ef51110cfb414f37b945e3aa3dc4de313bf48f3de607f410c4c