{"_id":"2d-density","_rev":"3-3672dba2b4f10d7425ebeba1a23ed004","name":"2d-density","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"2d-density","version":"1.0.0","description":"Calulates how full a grid will be if each item is spaced out by a given amount","main":"index.js","scripts":{"test":"jasmine"},"keywords":["math","density","algorithm","grid","spacing"],"repository":{"type":"git","url":"git+https://github.com/nilestanner/2d-density.git"},"author":{"name":"Niles Tanner"},"license":"ISC","devDependencies":{"jasmine":"^3.0.0"},"gitHead":"225f08e62f8406b170da80faffc4c062e09ed167","bugs":{"url":"https://github.com/nilestanner/2d-density/issues"},"homepage":"https://github.com/nilestanner/2d-density#readme","_id":"2d-density@1.0.0","_npmVersion":"5.5.1","_nodeVersion":"9.3.0","_npmUser":{"name":"nilestanner","email":"niles.tanner@gmail.com"},"dist":{"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="}]},"maintainers":[{"name":"nilestanner","email":"niles.tanner@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/2d-density_1.0.0_1520822241384_0.805425007653414"},"_hasShrinkwrap":false},"1.0.1":{"name":"2d-density","version":"1.0.1","description":"Calulates how full a grid will be if each item is spaced out by a given amount","main":"index.js","scripts":{"test":"jasmine"},"keywords":["math","density","algorithm","grid","spacing"],"repository":{"type":"git","url":"git+https://github.com/nilestanner/2d-density.git"},"author":{"name":"Niles Tanner"},"license":"ISC","devDependencies":{"jasmine":"^3.0.0"},"gitHead":"3886758b2238c4780cebb68e6d7002c8ee9c061f","bugs":{"url":"https://github.com/nilestanner/2d-density/issues"},"homepage":"https://github.com/nilestanner/2d-density#readme","_id":"2d-density@1.0.1","_npmVersion":"5.5.1","_nodeVersion":"9.3.0","_npmUser":{"name":"nilestanner","email":"niles.tanner@gmail.com"},"dist":{"integrity":"sha512-CLYtkJNsek7h97Pi6SGgfJiJbpJm7gI7DmdyBoeNiaCLy7hHMDluAw31WZ7lodn9DK9lGPzERNB1m9e6TrxpPw==","shasum":"7cd08f47231b21498661404c702289ff4046225b","tarball":"https://registry.npmjs.org/2d-density/-/2d-density-1.0.1.tgz","fileCount":7,"unpackedSize":14878,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDsBQV+ZmrXtqp26BDtVhU2UaDN2LpNeJDZjS7945VXZgIhALqvrAZ9/HRr1lqdXag8CXuW6W5sObKcWKyKwWWu815h"}]},"maintainers":[{"name":"nilestanner","email":"niles.tanner@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/2d-density_1.0.1_1520825775612_0.8455008418405643"},"_hasShrinkwrap":false}},"time":{"created":"2018-03-12T02:37:21.383Z","1.0.0":"2018-03-12T02:37:21.439Z","modified":"2022-04-04T10:18:53.510Z","1.0.1":"2018-03-12T03:36:15.712Z"},"maintainers":[{"name":"nilestanner","email":"niles.tanner@gmail.com"}],"description":"Calulates how full a grid will be if each item is spaced out by a given amount","homepage":"https://github.com/nilestanner/2d-density#readme","keywords":["math","density","algorithm","grid","spacing"],"repository":{"type":"git","url":"git+https://github.com/nilestanner/2d-density.git"},"author":{"name":"Niles Tanner"},"bugs":{"url":"https://github.com/nilestanner/2d-density/issues"},"license":"ISC","readme":"# 2d density\n\nAn 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.\n\n## Build Status\n[![CircleCI](https://circleci.com/gh/nilestanner/2d-density/tree/master.svg?style=svg)](https://circleci.com/gh/nilestanner/2d-density/tree/master)\n\n## Install\n\n```\nnpm install 2d-density\n```\n\n## Usage\n\n```\nconst twoDDensity = require('2d-density');\n\nconst gridWidth = 100;\nconst gridHeight = 100;\nconst spacing = 3;\n\nconst result = twoDDensity.findPercentFull(gridWidth, gridHeight, spacing);\n```\n\nWidth, height and spacing should all be whole numbers.\n\nSpacing does not count diagonals. Thus a cell that is diagonally adjacent is really spaced 2 cells away.  \n\n## Sample output\n\n```\n{\n  count: 2000,\n  percent: 0.2\n}\n```\n\n## Visual example\n\nSay 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:\n\n| x |   | x |   | x |\n|---|---|---|---|---|\n|   | x |   | x |   |\n| x |   | x |   | x |\n|   | x |   | x |   |\n\nThe 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.\n\nFor example a 5 by 5 grid with spacing of 3.\n\n| x |   |   |   | x |\n|---|---|---|---|---|\n|   |   | x |   |   |\n|   |   |   |   |   |\n|   | x |   |   | x |\n|   |   |   |   |   |\n\nThe count is only 5 and the percentage would be 0.2.\n","readmeFilename":"readme.md"}