{"_id":"d3-cloud","_rev":"1721694","name":"d3-cloud","description":"Generate word clouds in JavaScript.","dist-tags":{"latest":"2.0.0"},"maintainers":[{"name":"jasondavies","email":"jason@jasondavies.com"}],"time":{"modified":"2026-11-10T21:40:10.000Z","created":"2015-09-23T16:08:14.954Z","2.0.0":"2026-10-30T17:03:59.688Z","2.0.0-rc.0":"2026-10-30T15:21:45.158Z","1.2.9":"2026-03-03T21:57:53.400Z","1.2.8":"2025-12-02T16:12:58.275Z","1.2.7":"2023-08-07T23:45:39.196Z","1.2.6":"2023-08-07T23:24:08.349Z","1.2.5":"2018-02-03T10:20:06.101Z","1.2.4":"2017-01-12T15:54:31.425Z","1.2.3":"2017-01-12T15:38:58.827Z","1.2.1":"2015-10-15T10:30:20.773Z","1.2.0":"2015-09-24T21:47:43.986Z","1.1.2":"2015-09-23T16:08:14.954Z"},"users":{"zakuni":true,"quickskape":true},"author":{"url":"https://www.jasondavies.com/","name":"Jason Davies"},"repository":{"url":"git+https://github.com/jasondavies/d3-cloud.git","type":"git"},"versions":{"2.0.0":{"_id":"d3-cloud@2.0.0","bugs":{"url":"https://github.com/jasondavies/d3-cloud/issues"},"dist":{"shasum":"2e74fb5276a7038df27fa3dc6fed4ea93509cc5e","tarball":"http://registry-npm.ywwl.com/d3-cloud/download/d3-cloud-2.0.0.tgz","fileCount":11,"integrity":"sha512-zIHF7jUkviSOyC0IhrTK3hsiK+sscRYs5JDeQ+SQyeuXs4UZj7gFThBwzJpGmZBElFEQ6jLGeHPNlubvhTY1xw==","signatures":[{"sig":"MEYCIQCEzrSXFQtvWX9TedKnvB8VPO3Z2FzJlAQghJwQx2qvjQIhALnfMjfcVedsHh7hlf6efqwYOeFKi2yO0ySCqfFqnbJM","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCVgHUNMGhqu8fqShMMpwxWe7Vw7+Pb7dU5zz8KzKBL7gIgPTOI+ZMwrk/mW+CYUP15VX0/k4OaaJLcUCsCU65LSO0="}],"unpackedSize":129398,"size":34655,"noattachment":false,"key":"/d3-cloud/-/d3-cloud-2.0.0.tgz"},"main":"src/index.js","name":"d3-cloud","type":"module","types":"./index.d.ts","unpkg":"build/d3-cloud.js","author":{"url":"https://www.jasondavies.com/","name":"Jason Davies"},"engines":{"node":">=20"},"exports":{".":{"types":"./index.d.ts","import":"./src/index.js"},"./build/d3-cloud.js":{"types":"./index.d.ts","default":"./build/d3-cloud.js"}},"gitHead":"5a7696bdcc3330aed91828b36e1651c4f8433a90","license":"BSD-3-Clause","scripts":{"test":"node --test && npm run check:types","build":"esbuild src/index.js --bundle --format=esm --platform=browser --target=es2015 --outfile=build/d3-cloud.js","pretest":"npm run build","check:types":"tsc --noEmit --strict --module NodeNext --moduleResolution NodeNext type-tests/sprite-datum.ts type-tests/canvas-factory.ts type-tests/image-sources.ts","check:package":"npm test && npm run check:examples && npm pack --dry-run --cache .npm-cache","check:examples":"node --check examples/shared.js && node --check examples/index.js && node --check examples/frequencies.js && node --check examples/live-update.js && node --check examples/image-sprites.js && node --check examples/mask.js && node --check examples/node.js && node --check examples/font-loading.js && node --check examples/worker.js && node --check examples/worker-layout.js && node --check benchmark.js"},"version":"2.0.0","_npmUser":{"name":"jasondavies","email":"jason@jasondavies.com"},"homepage":"https://www.jasondavies.com/wordcloud/","jsdelivr":"build/d3-cloud.js","keywords":["word","cloud","tag","visualization","canvas"],"repository":{"url":"git+https://github.com/jasondavies/d3-cloud.git","type":"git"},"_npmVersion":"11.19.1","description":"Generate word clouds in JavaScript.","directories":{},"maintainers":[{"name":"jasondavies","email":"jason@jasondavies.com"}],"sideEffects":false,"_nodeVersion":"24.22.1","_hasShrinkwrap":false,"devDependencies":{"canvas":"^3.2.3","esbuild":"^0.25.0","typescript":"^5.9.3","@types/node":"^20.19.43","d3-cloud-v1":"npm:d3-cloud@1.2.9"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/d3-cloud_2.0.0_1793379839599_0.6793736754251796"},"publish_time":1793379839688,"_cnpm_publish_time":1793379839688},"2.0.0-rc.0":{"name":"d3-cloud","version":"2.0.0-rc.0","keywords":["word","cloud","tag","visualization","canvas"],"author":{"url":"https://www.jasondavies.com/","name":"Jason Davies"},"license":"BSD-3-Clause","_id":"d3-cloud@2.0.0-rc.0","maintainers":[{"name":"jasondavies","email":"jason@jasondavies.com"}],"homepage":"https://www.jasondavies.com/wordcloud/","bugs":{"url":"https://github.com/jasondavies/d3-cloud/issues"},"dist":{"shasum":"437aab1cd56fdc3268957c417e4ac069ead748a8","tarball":"http://registry-npm.ywwl.com/d3-cloud/download/d3-cloud-2.0.0-rc.0.tgz","fileCount":11,"integrity":"sha512-JVuY4mB6CdmbAJNgqb90i9hyrLtHM4J8hx/lGDe+9LVsTn0cebB9Vd06IzFk+GLZkdFIrx1/C8TigZourYU3TA==","signatures":[{"sig":"MEUCIQDxrX7MFpPACsoRmMf2B0M8PPcT+bmERwHp3I2TGRAmMwIgZRYc+0P2SSX0BhDQRYPxQ2HMPyFc+8qEUQPlEMutZM4=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEQCIBxe8ohAZ3zvpCw7EeRTwlhzVNKqoZgKyLXCAY2V0wUJAiAP+ZFFYLu1B08dioRe2rNky0dBGyA0surqCPVw/GuQhw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":128102,"size":34274,"noattachment":false,"key":"/d3-cloud/-/d3-cloud-2.0.0-rc.0.tgz"},"main":"src/index.js","type":"module","types":"./index.d.ts","unpkg":"build/d3-cloud.js","engines":{"node":">=20"},"exports":{".":{"types":"./index.d.ts","import":"./src/index.js"},"./build/d3-cloud.js":{"types":"./index.d.ts","default":"./build/d3-cloud.js"}},"gitHead":"3e660edb1fb4b1a7b5462bc44241bd16b49d5bb7","scripts":{"test":"node --test && npm run check:types","build":"esbuild src/index.js --bundle --format=esm --platform=browser --target=es2015 --outfile=build/d3-cloud.js","pretest":"npm run build","check:types":"tsc --noEmit --strict --module NodeNext --moduleResolution NodeNext type-tests/sprite-datum.ts type-tests/canvas-factory.ts type-tests/image-sources.ts","check:package":"npm test && npm run check:examples && npm pack --dry-run --cache .npm-cache","check:examples":"node --check examples/shared.js && node --check examples/index.js && node --check examples/frequencies.js && node --check examples/live-update.js && node --check examples/image-sprites.js && node --check examples/mask.js && node --check examples/node.js && node --check examples/font-loading.js && node --check examples/worker.js && node --check examples/worker-layout.js && node --check benchmark.js"},"_npmUser":{"name":"jasondavies","email":"jason@jasondavies.com"},"jsdelivr":"build/d3-cloud.js","repository":{"url":"git+https://github.com/jasondavies/d3-cloud.git","type":"git"},"_npmVersion":"11.19.1","description":"Generate word clouds in JavaScript.","directories":{},"sideEffects":false,"_nodeVersion":"24.22.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"canvas":"^3.2.3","esbuild":"^0.25.0","typescript":"^5.9.3","@types/node":"^20.19.43","d3-cloud-v1":"npm:d3-cloud@1.2.9"},"_npmOperationalInternal":{"tmp":"tmp/d3-cloud_2.0.0-rc.0_1793373705059_0.08001028245633035","host":"s3://npm-registry-packages-npm-production"},"publish_time":1793373705158,"_cnpm_publish_time":1793373705158},"1.2.9":{"name":"d3-cloud","version":"1.2.9","description":"Generate word clouds in JavaScript.","keywords":["word","cloud","tag","visualization","canvas"],"homepage":"https://www.jasondavies.com/wordcloud/","license":"BSD-3-Clause","author":{"name":"Jason Davies","url":"https://www.jasondavies.com/"},"main":"build/d3.layout.cloud.js","module":"index","jsnext:main":"index","repository":{"type":"git","url":"git+https://github.com/jasondavies/d3-cloud.git"},"scripts":{"build":"mkdir -p build && browserify --standalone d3.layout.cloud index.js > build/d3.layout.cloud.js"},"dependencies":{"d3-dispatch":"^1.0.3"},"devDependencies":{"browserify":"^17.0.0"},"_id":"d3-cloud@1.2.9","gitHead":"7b55ae6678f1c1259a18f58a94817c41a5e124c6","bugs":{"url":"https://github.com/jasondavies/d3-cloud/issues"},"_nodeVersion":"22.14.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-leL1GLneC9ZQtnV+6TGWrNlGfI1WX7S2arcTv2vae12DaXo5wjm6GBCkskXbrDlyOymd/A75Pyj1H37MW4BZ/Q==","shasum":"3fa02e428afc5bfb6cc17c0d3ee904cd09822aaf","tarball":"http://registry-npm.ywwl.com/d3-cloud/download/d3-cloud-1.2.9.tgz","fileCount":7,"unpackedSize":35619,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCTP0I9vfiehgQK484DETosY7snZmLCFthGAVOe6i1xIAIhAIKIrDk3nL4UrAQTJd4IqXV0S96uGcwrFvEuc/lwodLE"}],"size":8777,"noattachment":false,"key":"/d3-cloud/-/d3-cloud-1.2.9.tgz"},"_npmUser":{"name":"jasondavies","email":"jason@jasondavies.com"},"directories":{},"maintainers":[{"name":"jasondavies","email":"jason@jasondavies.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/d3-cloud_1.2.9_1772575073238_0.5811968052298166"},"_hasShrinkwrap":false,"publish_time":1772575073400,"_cnpm_publish_time":1772575073400},"1.2.8":{"name":"d3-cloud","version":"1.2.8","keywords":["word","cloud","tag","visualization","canvas"],"author":{"url":"https://www.jasondavies.com/","name":"Jason Davies"},"license":"BSD-3-Clause","_id":"d3-cloud@1.2.8","maintainers":[{"name":"jasondavies","email":"jason@jasondavies.com"}],"homepage":"https://www.jasondavies.com/wordcloud/","bugs":{"url":"https://github.com/jasondavies/d3-cloud/issues"},"dist":{"shasum":"a4fbc8af39504cb82eacacdcf7af1dc0c1f7f8a9","tarball":"http://registry-npm.ywwl.com/d3-cloud/download/d3-cloud-1.2.8.tgz","fileCount":9,"integrity":"sha512-K0qBFkgystNlgFW/ufdwIES5kDiC8cGJxMw4ULzN9UU511v89A6HXs1X8vUPxqurehzqJZS5KzZI4c8McT+4UA==","signatures":[{"sig":"MEQCIEy6SY4Po4UR7pmk/tEPB3bk05wEIhsvKQbNZQbbuz3UAiAKVxjlbnvgNl/pVWxbann1qSc3qnUseURRvknM5JlPwQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":36073,"size":9022,"noattachment":false,"key":"/d3-cloud/-/d3-cloud-1.2.8.tgz"},"main":"build/d3.layout.cloud.js","module":"index","gitHead":"9d0aa2c2afb4e763c8bd7fd741fc7d8a8c6facd8","scripts":{"build":"mkdir -p build && browserify --standalone d3.layout.cloud index.js > build/d3.layout.cloud.js"},"_npmUser":{"name":"jasondavies","email":"jason@jasondavies.com"},"repository":{"url":"git+https://github.com/jasondavies/d3-cloud.git","type":"git"},"_npmVersion":"10.9.2","description":"Generate word clouds in JavaScript.","directories":{},"jsnext:main":"index","_nodeVersion":"22.14.0","dependencies":{"d3-dispatch":"^1.0.3"},"_hasShrinkwrap":false,"devDependencies":{"browserify":"^17.0.0"},"_npmOperationalInternal":{"tmp":"tmp/d3-cloud_1.2.8_1764691978090_0.9814053832682788","host":"s3://npm-registry-packages-npm-production"},"publish_time":1764691978275,"_cnpm_publish_time":1764691978275},"1.2.7":{"name":"d3-cloud","version":"1.2.7","description":"Generate word clouds in JavaScript.","keywords":["word","cloud","tag","visualization","canvas"],"homepage":"https://www.jasondavies.com/wordcloud/","license":"BSD-3-Clause","author":{"name":"Jason Davies","url":"https://www.jasondavies.com/"},"main":"build/d3.layout.cloud.js","module":"index","jsnext:main":"index","repository":{"type":"git","url":"git+https://github.com/jasondavies/d3-cloud.git"},"scripts":{"build":"mkdir -p build && browserify --standalone d3.layout.cloud index.js > build/d3.layout.cloud.js"},"dependencies":{"d3-dispatch":"^1.0.3"},"devDependencies":{"browserify":"^17.0.0"},"gitHead":"deea7d7165a4304d8eb123bd6b0e07aaae77ebea","bugs":{"url":"https://github.com/jasondavies/d3-cloud/issues"},"_id":"d3-cloud@1.2.7","_nodeVersion":"18.16.0","_npmVersion":"9.5.1","dist":{"integrity":"sha512-8TrgcgwRIpoZYQp7s3fGB7tATWfhckRb8KcVd1bOgqkNdkJRDGWfdSf4HkHHzZxSczwQJdSxvfPudwir5IAJ3w==","shasum":"5a733c4bae43238cbb4760bb8f2d15912a8ad7a5","tarball":"http://registry-npm.ywwl.com/d3-cloud/download/d3-cloud-1.2.7.tgz","fileCount":8,"unpackedSize":36014,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGecnozdgVBe7fLf04jaUk5CHH0D9ocxDrvr7uuRBaX1AiEAk8laP6sSOKgi5tgXfdony4ph154x2YDrQ2xxfadHE2Y="}],"size":8824,"noattachment":false,"key":"/d3-cloud/-/d3-cloud-1.2.7.tgz"},"_npmUser":{"name":"jasondavies","email":"jason@jasondavies.com"},"directories":{},"maintainers":[{"name":"jasondavies","email":"jason@jasondavies.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/d3-cloud_1.2.7_1691451938973_0.8246321125246729"},"_hasShrinkwrap":false,"publish_time":1691451939196,"_cnpm_publish_time":1691451939196},"1.2.6":{"name":"d3-cloud","version":"1.2.6","description":"Generate word clouds in JavaScript.","keywords":["word","cloud","tag","visualization","canvas"],"homepage":"https://www.jasondavies.com/wordcloud/","license":"BSD-3-Clause","author":{"name":"Jason Davies","url":"https://www.jasondavies.com/"},"main":"build/d3.layout.cloud.js","module":"index","jsnext:main":"index","repository":{"type":"git","url":"git+https://github.com/jasondavies/d3-cloud.git"},"scripts":{"build":"mkdir -p build && browserify --standalone d3.layout.cloud index.js > build/d3.layout.cloud.js"},"dependencies":{"d3-dispatch":"^1.0.3"},"devDependencies":{"browserify":"^17.0.0"},"gitHead":"5e16861464e13b56413b27d860d3c6f234cb63e2","bugs":{"url":"https://github.com/jasondavies/d3-cloud/issues"},"_id":"d3-cloud@1.2.6","_nodeVersion":"18.16.0","_npmVersion":"9.5.1","dist":{"integrity":"sha512-cJSBbI/L2OOEYSdLzyQX7ZWUBOS0HowxEZzKy2HWwmBjrMa1ir/6Hb9d+RbpKdiPJ4HTv2oaKgiGl6RHk3Tvzg==","shasum":"0ab6658f1973ce5a49dd7761c420bc963a9339cd","tarball":"http://registry-npm.ywwl.com/d3-cloud/download/d3-cloud-1.2.6.tgz","fileCount":8,"unpackedSize":36020,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC07qKNhkPm+b5XLNN3wtha5YjtYz+BuVUdez0iUa2dtgIhAK3CIPepWowjbEXXAxzCmpqBstsMUTGyu9axW9moeaTQ"}],"size":8824,"noattachment":false,"key":"/d3-cloud/-/d3-cloud-1.2.6.tgz"},"_npmUser":{"name":"jasondavies","email":"jason@jasondavies.com"},"directories":{},"maintainers":[{"name":"jasondavies","email":"jason@jasondavies.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/d3-cloud_1.2.6_1691450648151_0.9178054262108428"},"_hasShrinkwrap":false,"publish_time":1691450648349,"_cnpm_publish_time":1691450648349},"1.2.5":{"name":"d3-cloud","version":"1.2.5","description":"Generate word clouds in JavaScript.","keywords":["word","cloud","tag","visualization","canvas"],"homepage":"https://www.jasondavies.com/wordcloud/","license":"BSD-3-Clause","author":{"name":"Jason Davies","url":"https://www.jasondavies.com/"},"main":"build/d3.layout.cloud.js","module":"index","jsnext:main":"index","repository":{"type":"git","url":"git+https://github.com/jasondavies/d3-cloud.git"},"scripts":{"build":"mkdir -p build && browserify --standalone d3.layout.cloud index.js > build/d3.layout.cloud.js"},"dependencies":{"d3-dispatch":"^1.0.3"},"devDependencies":{"browserify":"^11.2.0"},"gitHead":"1b91cada382e6f26cabf95db753bb6a41e95040b","bugs":{"url":"https://github.com/jasondavies/d3-cloud/issues"},"_id":"d3-cloud@1.2.5","_npmVersion":"5.5.1","_nodeVersion":"9.3.0","_npmUser":{"name":"jasondavies","email":"jason@jasondavies.com"},"maintainers":[{"name":"jasondavies","email":"jason@jasondavies.com"}],"dist":{"integrity":"sha512-4s2hXZgvs0CoUIw31oBAGrHt9Kt/7P9Ik5HIVzISFiWkD0Ga2VLAuO/emO/z1tYIpE7KG2smB4PhMPfFMJpahw==","shasum":"3e91564f2d27fba47fcc7d812eb5081ea24c603d","tarball":"http://registry-npm.ywwl.com/d3-cloud/download/d3-cloud-1.2.5.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCQ+G41xjo2ZoVLuIsAPzxq5HUKmlGvkVAiRYdK4beTTAIhANgB+bDWZsaFvR0+lmvZNCZLDOl+3tqa5tg14pnJNNP6"}],"size":8761,"noattachment":false,"key":"/d3-cloud/-/d3-cloud-1.2.5.tgz"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/d3-cloud-1.2.5.tgz_1517653205073_0.2645122546236962"},"directories":{},"publish_time":1517653206101,"_cnpm_publish_time":1517653206101},"1.2.4":{"name":"d3-cloud","version":"1.2.4","description":"Generate word clouds in JavaScript.","keywords":["word","cloud","tag","visualization","canvas"],"homepage":"http://www.jasondavies.com/wordcloud/","author":{"name":"Jason Davies","url":"http://www.jasondavies.com/"},"license":"BSD-3-Clause","repository":{"type":"git","url":"git+ssh://git@github.com/jasondavies/d3-cloud.git"},"main":"index.js","scripts":{"build":"mkdir -p build && browserify --standalone d3.layout.cloud index.js > build/d3.layout.cloud.js"},"dependencies":{"d3-dispatch":"1"},"devDependencies":{"browserify":"^11.2.0"},"gitHead":"f00a511341fb4c9d9fce2faacea212687d653915","bugs":{"url":"https://github.com/jasondavies/d3-cloud/issues"},"_id":"d3-cloud@1.2.4","_shasum":"3e169403adab74fdb0c867638d7f0bb8e6ae71ff","_from":".","_npmVersion":"4.0.5","_nodeVersion":"7.4.0","_npmUser":{"name":"jasondavies","email":"jason@jasondavies.com"},"maintainers":[{"name":"jasondavies","email":"jason@jasondavies.com"}],"dist":{"shasum":"3e169403adab74fdb0c867638d7f0bb8e6ae71ff","tarball":"http://registry-npm.ywwl.com/d3-cloud/download/d3-cloud-1.2.4.tgz","integrity":"sha512-eTZX6d2pXEBqeBpiFaQC3gwTZatkSqWV0nTfTzDkme1ckw9xeglvWIMaN/6L0sIEhxkapSMHQbSPpv+ReMERHA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC47iSylU/XITZu5s0QqUbxHtX3wMCJRjGneRUfineDlAIhAOjNXFGwKN4tF2qDWiYmTxgE7DyiGZiCcUbrxkPoGTK5"}],"size":8798,"noattachment":false,"key":"/d3-cloud/-/d3-cloud-1.2.4.tgz"},"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/d3-cloud-1.2.4.tgz_1484236469339_0.5239274648483843"},"directories":{},"publish_time":1484236471425,"_cnpm_publish_time":1484236471425},"1.2.3":{"name":"d3-cloud","version":"1.2.3","description":"Generate word clouds in JavaScript.","keywords":["word","cloud","tag","visualization","canvas"],"homepage":"http://www.jasondavies.com/wordcloud/","author":{"name":"Jason Davies","url":"http://www.jasondavies.com/"},"license":"BSD-3-Clause","repository":{"type":"git","url":"git+ssh://git@github.com/jasondavies/d3-cloud.git"},"main":"index.js","scripts":{"build":"mkdir -p build && browserify --standalone d3.layout.cloud index.js > build/d3.layout.cloud.js"},"dependencies":{"d3-dispatch":"1"},"devDependencies":{"browserify":"^11.2.0"},"gitHead":"1912f4b457744b53e87f526dd493ccb4bf3594c4","bugs":{"url":"https://github.com/jasondavies/d3-cloud/issues"},"_id":"d3-cloud@1.2.3","_shasum":"19d6df75b940f14d981451245e6991aa20477f92","_from":".","_npmVersion":"4.0.5","_nodeVersion":"7.4.0","_npmUser":{"name":"jasondavies","email":"jason@jasondavies.com"},"maintainers":[{"name":"jasondavies","email":"jason@jasondavies.com"}],"dist":{"shasum":"19d6df75b940f14d981451245e6991aa20477f92","tarball":"http://registry-npm.ywwl.com/d3-cloud/download/d3-cloud-1.2.3.tgz","integrity":"sha512-r91TGQigf2IoX147n8YhsHnP594rC4/F6DthPzv72HBOrVjeNfGaQOF0FTg9gKpBgLS3bkzGoq7mZqeU/idPiA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFTQDfuS8FKlpBzumNPFTfjfZDRDypWTh8JTLJqzOU7hAiAXCHFTaRUfOube6hz8IaO8KNG799xpC5ZDkQ+FsqGtTg=="}],"size":8713,"noattachment":false,"key":"/d3-cloud/-/d3-cloud-1.2.3.tgz"},"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/d3-cloud-1.2.3.tgz_1484235538178_0.7767083484213799"},"directories":{},"publish_time":1484235538827,"_cnpm_publish_time":1484235538827},"1.2.1":{"name":"d3-cloud","version":"1.2.1","description":"Generate word clouds in JavaScript.","keywords":["word","cloud","tag","visualization","canvas"],"homepage":"http://www.jasondavies.com/wordcloud/","author":{"name":"Jason Davies","url":"http://www.jasondavies.com/"},"license":"BSD-3-Clause","repository":{"type":"git","url":"git+ssh://git@github.com/jasondavies/d3-cloud.git"},"main":"index.js","scripts":{"build":"mkdir -p build && browserify --standalone d3.layout.cloud index.js > build/d3.layout.cloud.js"},"dependencies":{"d3-dispatch":"0.2.x"},"devDependencies":{"browserify":"^11.2.0"},"gitHead":"7d6fabeb7ad461cdac8f836896a7b93d2202002d","bugs":{"url":"https://github.com/jasondavies/d3-cloud/issues"},"_id":"d3-cloud@1.2.1","_shasum":"a9cfdf3fb855804a9800866229bf016f71bd379a","_from":".","_npmVersion":"2.14.7","_nodeVersion":"4.2.0","_npmUser":{"name":"jasondavies","email":"jason@jasondavies.com"},"maintainers":[{"name":"jasondavies","email":"jason@jasondavies.com"}],"dist":{"shasum":"a9cfdf3fb855804a9800866229bf016f71bd379a","tarball":"http://registry-npm.ywwl.com/d3-cloud/download/d3-cloud-1.2.1.tgz","integrity":"sha512-iEDsMZF0SZHZn+dneNrgah774iY78Dso7cZpYz8L4v3+LPmGma27fCf4djxGyCaJ1W4Ia1H9WTum4LRLeOEZLw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGl5CRT9fTfm/dBN24rbvYeGJdQYWbCWU7zVJuzib9w2AiA+8a/erw3RbL4xLVg65kwANNQdnvCB3tyDzi7YKS0KVQ=="}],"size":8689,"noattachment":false,"key":"/d3-cloud/-/d3-cloud-1.2.1.tgz"},"directories":{},"publish_time":1444905020773,"_cnpm_publish_time":1444905020773},"1.2.0":{"name":"d3-cloud","version":"1.2.0","description":"Generate word clouds in JavaScript.","keywords":["word","cloud","tag","visualization","canvas"],"homepage":"http://www.jasondavies.com/wordcloud/","author":{"name":"Jason Davies","url":"http://www.jasondavies.com/"},"license":"BSD-3-Clause","repository":{"type":"git","url":"git+ssh://git@github.com/jasondavies/d3-cloud.git"},"main":"index.js","scripts":{"build":"mkdir -p build && browserify --standalone d3.layout.cloud index.js > build/d3.layout.cloud.js"},"dependencies":{"d3-dispatch":"0.2.x"},"devDependencies":{"browserify":"^11.2.0"},"gitHead":"85ff7b760be786c3e1d7b430c5c2b939b4e80897","bugs":{"url":"https://github.com/jasondavies/d3-cloud/issues"},"_id":"d3-cloud@1.2.0","_shasum":"5902fc1021075b2ac9a18409502178168506b4a4","_from":".","_npmVersion":"3.3.3","_nodeVersion":"4.1.0","_npmUser":{"name":"jasondavies","email":"jason@jasondavies.com"},"maintainers":[{"name":"jasondavies","email":"jason@jasondavies.com"}],"dist":{"shasum":"5902fc1021075b2ac9a18409502178168506b4a4","tarball":"http://registry-npm.ywwl.com/d3-cloud/download/d3-cloud-1.2.0.tgz","integrity":"sha512-gJ2X7TFivXHR0aURYinwXK9VES8z3U9agSeoDWhK9fRS7VwlIHsooFKgWy3Jy72nVmir2gqNh2UzHohodft3Hw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCMyXX91FY6B0nkxNSU7SbdJ4LD5wZvWIj3HY0y67/0BgIgKVxPLzjn0NX3aMfl9ohd6UHVl+4wOtjozGwDPmHOheY="}],"size":7219,"noattachment":false,"key":"/d3-cloud/-/d3-cloud-1.2.0.tgz"},"directories":{},"publish_time":1443131263986,"_cnpm_publish_time":1443131263986},"1.1.2":{"name":"d3-cloud","version":"1.1.2","description":"Generate word clouds in JavaScript.","keywords":["word","cloud","tag","visualization","canvas"],"homepage":"http://www.jasondavies.com/wordcloud/","author":{"name":"Jason Davies","url":"http://www.jasondavies.com/"},"repository":{"type":"git","url":"http://github.com/jasondavies/d3-cloud.git"},"main":"index.js","dependencies":{"d3":"3.x","canvas":"1.2.x"},"gitHead":"0e8c6ba8bb06fd13e03a568b5f3442ccfcc518ed","bugs":{"url":"https://github.com/jasondavies/d3-cloud/issues"},"_id":"d3-cloud@1.1.2","scripts":{},"_shasum":"11407b1eab6984a29564d37978d67044d30c59a7","_from":".","_npmVersion":"2.14.3","_nodeVersion":"4.1.0","_npmUser":{"name":"jasondavies","email":"jason@jasondavies.com"},"maintainers":[{"name":"jasondavies","email":"jason@jasondavies.com"}],"dist":{"shasum":"11407b1eab6984a29564d37978d67044d30c59a7","tarball":"http://registry-npm.ywwl.com/d3-cloud/download/d3-cloud-1.1.2.tgz","integrity":"sha512-nXzkvpD4dGaM66aD0BT3fzBkrf+qbe7hh8sUpySueLw0IMwdRfeu9Tor7Rc+mZFXzcA/V7MPjKWSc3noUZH65Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIF+FcYc98VOfdCjkVpOzbECXSwoSYkYrGdO7ofR8C28JAiAX4OoMM+pZE5VfgrTX94qVDfhx27FyTb0JZxol5CzBAg=="}],"size":81030,"noattachment":false,"key":"/d3-cloud/-/d3-cloud-1.1.2.tgz"},"directories":{},"publish_time":1443024494954,"_cnpm_publish_time":1443024494954}},"readme":"# Word Cloud Layout\n\nThis is a [Wordle](https://s3.amazonaws.com/static.mrfeinberg.com/bv_ch03.pdf)-inspired word cloud layout written\nin JavaScript. It uses HTML5 canvas and sprite masks to achieve\nnear-interactive speeds. The library prepares sprite masks and computes word\npositions; your application renders the results with canvas, SVG, or another\nrenderer.\n\nSee [here](https://www.jasondavies.com/wordcloud/) for an interactive\ndemonstration along with implementation details.\n\n![Example word cloud](https://www.jasondavies.com/wordcloud/readme.svg)\n\n## Install\n\n```sh\nnpm install d3-cloud\n```\n\nThe package is ESM-only. Node.js requires version 20 or newer and a canvas\nimplementation for rasterizing text and images:\n\n```sh\nnpm install canvas\n```\n\n## Quick Start\n\nIn Node.js, save this example as `cloud.mjs` and run `node cloud.mjs`:\n\n```js\nimport { createCanvas } from \"canvas\";\nimport CloudLayout from \"d3-cloud\";\n\nconst words = [\n  { text: \"Hello\", size: 64 },\n  { text: \"world\", size: 48 },\n  { text: \"cloud\", size: 32 }\n];\nconst layout = new CloudLayout()\n  .canvas(() => createCanvas(1, 1))\n  .size([640, 400])\n  .overflow(false);\nconst sprites = [...words]\n  .sort((a, b) => b.size - a.size)\n  .map(word => layout.getSprite(word.text, {\n    size: word.size,\n    datum: word,\n    font: \"sans-serif\",\n    padding: 1,\n    rotate: 0\n  }))\n  .filter(Boolean);\nconst placed = [];\n\nfor (const sprite of sprites) {\n  const word = layout.place(sprite);\n  if (word) {\n    placed.push(word);\n  }\n}\nconsole.log(placed);\n```\n\nIn a browser application with a bundler, use the same example but omit the\n`canvas` import and the `.canvas(...)` call. The default factory creates an\nHTML canvas. Load any custom fonts before calling `getSprite()`.\n\nPrepare sprites once, then call `place()` for each one, usually largest first.\nBoth methods can return `null`, so the example filters unsuccessful sprites\nand placements. `datum` carries the original input object onto each result.\n\nThe example uses `overflow(false)` to keep words inside a 640 × 400 layout\nrectangle centered at `[0, 0]`. The default, `overflow(true)`, allows the cloud\nto grow beyond that rectangle. `size()` also shapes the built-in search\nstrategies and sets their initial seed region; see [size](#size).\n\n## Rendering Placed Words\n\n### Canvas Rendering\n\nLayout coordinates are centered around zero, whereas a canvas starts at its\ntop-left corner. For the bounded quick-start example, translate the drawing\norigin to the canvas center before rendering the words:\n\n```js\nfunction drawText(context, word) {\n  context.save();\n  context.font = `${word.style} ${word.weight} ${word.size}px ${word.font}`;\n  context.textAlign = \"center\";\n  context.textBaseline = \"alphabetic\";\n  context.translate(word.x, word.y);\n  context.rotate(word.rotate * Math.PI / 180);\n  context.fillText(word.text, 0, 0);\n  context.restore();\n}\n\nconst canvas = createCanvas(640, 400);\nconst context = canvas.getContext(\"2d\");\ncontext.save();\ncontext.translate(canvas.width / 2, canvas.height / 2);\nfor (const word of placed) drawText(context, word);\ncontext.restore();\n```\n\nThis continues the Node.js example. In a browser, use an HTML canvas with\n`width=\"640\"` and `height=\"400\"` instead of `createCanvas(640, 400)`.\nUse the same font family, style, weight, and size used to prepare the sprites.\nText positions are the horizontal center of the text on its alphabetic baseline.\n\nFor an overflowing layout, fit the drawing surface to `bounds()` instead of\nassuming it fits inside `size()`. After placing the words, use this in place of\nthe centered rendering block above:\n\n```js\nconst bounds = layout.bounds();\nif (bounds) {\n  const [min, max] = bounds;\n  const margin = 16;\n  canvas.width = Math.ceil(max.x - min.x) + 2 * margin;\n  canvas.height = Math.ceil(max.y - min.y) + 2 * margin;\n  context.save();\n  context.translate(margin - min.x, margin - min.y);\n  for (const word of placed) drawText(context, word);\n  context.restore();\n}\n```\n\nImage positions are the center of the resized source image, which may differ\nfrom the center of its visible pixels when the source has transparent margins.\nWithin the same outer translation, render an image word with:\n\n```js\ncontext.save();\ncontext.translate(word.x, word.y);\ncontext.rotate(word.rotate * Math.PI / 180);\ncontext.drawImage(word.image,\n  -word.imageWidth / 2, -word.imageHeight / 2,\n  word.imageWidth, word.imageHeight);\ncontext.restore();\n```\n\n### SVG\n\nFor an existing SVG element, render the placed text words with a `viewBox`\nderived from the layout bounds, and copy\nthe font attributes as well as the position and rotation:\n\n```js\nconst svg = document.querySelector(\"svg\");\nconst bounds = layout.bounds();\nsvg.replaceChildren();\nif (bounds) {\n  const [min, max] = bounds;\n  const margin = 16;\n  svg.setAttribute(\"viewBox\",\n    `${min.x - margin} ${min.y - margin} ${max.x - min.x + 2 * margin} ${max.y - min.y + 2 * margin}`);\n  for (const word of placed) {\n    const text = document.createElementNS(\"http://www.w3.org/2000/svg\", \"text\");\n    text.setAttribute(\"text-anchor\", \"middle\");\n    text.setAttribute(\"font-family\", word.font);\n    text.setAttribute(\"font-size\", word.size);\n    text.setAttribute(\"font-style\", word.style);\n    text.setAttribute(\"font-weight\", word.weight);\n    text.setAttribute(\"transform\", `translate(${word.x},${word.y}) rotate(${word.rotate})`);\n    text.textContent = word.text;\n    svg.append(text);\n  }\n}\n```\n\n## Examples\n\nSee [examples/](./examples/) for SVG rendering, image sprites, live updates,\nfont loading, and Web Workers. To run these from a repository checkout, follow\n[Development](#development). The npm package already includes the browser ESM\nbundle at `build/d3-cloud.js`; consumers do not need to build it.\n\n## Using With React\n\nSee [examples/react/README.md](./examples/react/README.md) for a minimal\nVite + React sample that runs the layout on the client and renders each placed\nword as a clickable SVG link.\n\nIn frameworks that render on the server, create the layout only on the client,\nfor example inside `useEffect()` or inside a client-only component. The\ndefault canvas factory uses `document.createElement(\"canvas\")`.\n\n## Migrating From 1.x\n\nSee the [migration guide](./MIGRATING.md) for a before-and-after example,\nchanged defaults, scheduling, TypeScript, and browser script migration.\nExisting `^1.x` dependencies stay on v1; pin legacy CDN scripts to a 1.x\nversion before changing any unversioned URLs.\n\n- The package is now ESM-only. `require(\"d3-cloud\")` is no longer supported.\n- The old factory and event API is gone. Use `new CloudLayout()` together with\n  `getSprite()` and `place()` instead of `start()`, `stop()`, `on()`,\n  `words()`, and `timeInterval()`.\n- Input words are no longer annotated with layout fields. Pass your word as\n  `datum` and read it back from each placed word.\n- Text and image styling now lives on `getSprite(source, options)` rather than\n  layout-wide accessors such as `text()`, `font()`, `fontSize()`, `rotate()`,\n  and `padding()`.\n- `size([width, height])` now describes a centered layout box around `[0, 0]`.\n  Use `overflow(false)` to keep placement inside that box or `overflow(true)`\n  to allow the layout to grow beyond it.\n- `strategy()` replaces the old `spiral()` API. Built-in strategies are\n  `\"archimedean\"`, `\"rectangular\"`, and `\"none\"`, and custom strategies now receive an\n  initial `{x, y}` seed plus layout context.\n\n## API Reference\n\n<a name=\"cloudlayout\" href=\"#cloudlayout\">#</a> <b>new CloudLayout()</b>\n\nConstructs a new cloud layout instance.\n\n<a name=\"clear\" href=\"#clear\">#</a> <b>clear</b>()\n\nClears the current placement state and bounds so the instance can be reused for\na fresh layout. Words placed before clearing can no longer be erased. Calling\n`clear()` while `place()` is searching, for example from `random()` or a\nstrategy, throws an error.\n\n<a name=\"bounds\" href=\"#bounds\">#</a> <b>bounds</b>()\n\nReturns the current placement extent as `[{x, y}, {x, y}]`, or `null` if no\nwords have been placed yet. After `erase()`, these bounds are only reset when\nthe layout becomes completely empty; otherwise they may remain conservative.\n\n<a name=\"getsprite\" href=\"#getsprite\">#</a> <b>getSprite</b>(<i>source</i>[, <i>options</i>])\n\nRasterizes the specified text or image-like source and returns an immutable\n`CloudSprite`, or `null` if it could not be rasterized into the internal scratch\ncanvas.\n\nA sprite is a mask: it holds the source, its styling, its trimmed geometry\n(`width`, `height`, `x0`, `y0`, `x1`, `y1`) and its pixels, but no position.\nThe geometry describes the axis-aligned mask after rotation, relative to the\nplacement anchor. `x0` and `y0` are the inclusive left and top edges; `x1` and\n`y1` are the exclusive right and bottom edges. Thus `width = x1 - x0` and\n`height = y1 - y0`. A placed word's mask has a bounding rectangle from\n`[word.x + word.x0, word.y + word.y0]` to\n`[word.x + word.x1, word.y + word.y1]`.\nFor text the anchor is its horizontal center on the alphabetic baseline;\nfor images it is the center of the resized source image, before transparent\nmargins are trimmed. See [Rendering Placed Words](#rendering-placed-words).\n\nRasterization is the expensive step, so prepare a sprite once and place it as\nmany times as you like, in this or any other layout. Sprites are frozen and\ncan only be created by `getSprite()`. The `sprite` field is a copy of the\npacked mask, a `Uint32Array` of `height` rows of `spriteWidth` bits each, with\nthe leftmost pixel in the most significant bit. Placement uses a private copy,\nso changing it has no effect.\nSprites work with any layout from the same copy of d3-cloud, but the package\nentry point and `build/d3-cloud.js` are separate copies whose sprites and\nlayouts cannot be mixed.\n\nThe optional *options* object may include `font`, `style`, `weight`, `rotate`,\n`size`, `padding`, and `datum`. The defaults are `font: \"serif\"`,\n`style: \"normal\"`, `weight: \"normal\"`, `size: 1`, `rotate: 0`, and\n`padding: 1` (0 for images). `fontStyle`, `fontWeight`, and `fontSize` are\naccepted as aliases. `font` and `style` are converted to strings, as is\n`weight` unless it is a number.\nOther option fields are ignored, and `null` is the same as no options.\nNumeric options must be finite, and `padding` must not be negative. Text sizes\nare truncated to whole pixels, and text smaller than 1 pixel returns `null`.\nIf the canvas rejects the resulting CSS font, for example an unquoted family\nname starting with a digit or a weight above 1000, `getSprite()` throws rather\nthan rasterizing a mask in the canvas's previous font.\n\nUse `datum` to carry your own data, such as the input word, a link, or an ID.\nIt is stored by reference on the sprite and on every word placed from it, and\nis never read by the layout. If omitted, it is `undefined`. TypeScript preserves\nthat possibility when the options declare `datum` as optional; passing a\nrequired `datum` infers its type directly.\n\nImage sprites are extracted from the source alpha channel, so transparent\npixels are ignored automatically. For image sources, `options.width` and\n`options.height` may be used to resize the image before extraction; if only one\ndimension is provided, the other is derived from the source aspect ratio.\n`options.text` sets the sprite's text, which defaults to the image's `alt`.\nImages and videos use their intrinsic dimensions rather than their display size.\nA loaded image without intrinsic dimensions, such as an SVG with only a\n`viewBox`, is drawn at the given `width` and `height` if both are specified;\nif the browser cannot draw it, for example because it is broken, `getSprite()`\nreturns `null`.\n\n`padding` applies only to text. Image masks use the source alpha unchanged;\nadding transparent margins does not create occupied padding pixels.\n\nText and image bounds are trimmed to nontransparent pixels, including text\npadding. Packed rows are aligned internally without adding empty space to\nreported bounds or bounded placement checks.\n`null` can indicate empty text, an unloaded or empty image, or a raster exceeding\nthe 2048-pixel scratch dimensions. Load images and fonts before preparing sprites.\nIf drawing or reading the scratch canvas throws, for example because a\ncross-origin image tainted it, the error is rethrown and the layout requests a\nnew canvas from its factory for later sprites; see [canvas](#canvas).\n`getSprite()` throws if it is called while a sprite is being drawn to the same\ncanvas, for example from an image's property getter.\n\n<a name=\"place\" href=\"#place\">#</a> <b>place</b>(<i>sprite</i>[, <i>options</i>])\n\nAttempts to place *sprite* and returns a new placed word, or `null` if it could\nnot be placed. The sprite itself is not changed, so it can be placed again;\nfor example, this fills a fixed box with one word at decreasing sizes:\n\n```js\nlayout.overflow(false);\nfor (let size = 80; size >= 8; size -= 4) {\n  const sprite = layout.getSprite(\"fill\", { size, font: \"Impact\" });\n  while (sprite && layout.place(sprite)) {}\n}\n```\n\nWith the default `overflow(true)` the cloud can always grow, so a loop like\nthis would never end.\n\nThe placed word is a plain object with the sprite's `text`, `image`,\n`imageWidth`, `imageHeight`, `font`, `style`, `weight`, `rotate`, `size`,\n`padding`, `datum`, and trimmed geometry, plus the placed position `x` and `y`.\nIt is shallow and not a serialization format: an image word retains its\n`image` source, which may be a DOM element, and `datum` is whatever you passed.\nBefore posting or serializing a word, omit anything that cannot be cloned.\n\nIf specified, the optional *options* object may include `x` and `y` to control\nthe initial placement attempt before the strategy search begins. Any omitted axis\nstill uses the normal seeded position from the centered half-size seed box\nderived from `size()`. Explicit coordinates must be finite and within\n±16,777,216, and are rounded down to integer pixels.\n\nOnce the layout has placed words, a new sprite's search envelope must overlap\nthe existing cloud's bounds. This envelope extends the mask's rectangle with\nsome horizontal slack for text and a few pixels on each side for images, so\nwords can sit beside the cloud while their occupied pixels remain separate.\nWith `overflow(false)`, the mask must also fit inside the fixed layout rectangle\ndefined by `size()`; this is distinct from the existing cloud's bounds.\nIf the initial position fails, the search starts from the nearest position\nthat satisfies these rectangle constraints. Pixel collisions are checked at\neach candidate position.\n\nIf specified, `options.strategy` overrides the layout-level default strategy\nfor this placement only.\n\nThe returned `x` and `y` are the rendering anchor: the center of the resized\nsource image, or the horizontal center of text on its alphabetic baseline.\nSee [Rendering Placed Words](#rendering-placed-words) for canvas and SVG examples.\n\nTo place multiple sprites, call `place()` in your own loop.\n\n<a name=\"erase\" href=\"#erase\">#</a> <b>erase</b>(<i>word</i>)\n\nErases a placed word, freeing its pixels for later placements. *word* must be\nan object returned by `place()` on this layout since it was last cleared; it is\nmatched by identity, so changing its fields does not affect what is erased, and\ncopies are rejected. Each word can be erased once.\n\nThis does not shrink `bounds()` unless the layout becomes completely empty.\n\n<a name=\"size\" href=\"#size\">#</a> <b>size</b>([<i>size</i>])\n\nIf specified, sets the centered layout size as `[width, height]`. This size is\nused both for the aspect ratio of the built-in `\"archimedean\"` and\n`\"rectangular\"` strategies and for a centered initial seed box at half that\nwidth and height.\n\nEach dimension must be from 0 to 16,777,216. If not specified, returns the\ncurrent layout size, which defaults to `[256, 256]`. Use `[0, 0]` together\nwith `overflow(true)` to start every word exactly at the origin without any\nbounding box.\n\n<a name=\"overflow\" href=\"#overflow\">#</a> <b>overflow</b>([<i>overflow</i>])\n\nIf specified, enables or disables overflow beyond `size()`. When `true`, the\nlayout may expand beyond the centered `size()` box, which is then used only for\nseeding and built-in strategy shaping. When `false`, placement is bounded to\nthat centered box and `place()` returns `null` if no in-bounds position is\nfound.\n\nIf not specified, returns the current overflow mode, which defaults to `true`.\n\n<a name=\"strategy\" href=\"#strategy\">#</a> <b>strategy</b>([<i>strategy</i>])\n\nIf specified, sets the current placement strategy used after the initial seed\nposition fails. This can either be one of the built-in strategies,\n`\"archimedean\"`, `\"rectangular\"`, and `\"none\"`, or an arbitrary strategy\nfactory of the following form:\n\n```js\nfunction(initial, context) {\n  return function() {\n    return { x, y };\n  };\n}\n```\n\nThe `initial` argument is the `{x, y}` position the search starts from: the\nseed for this placement, moved if necessary to the nearest position where the\nsprite could be placed, as described under [place](#place).\n`context` includes `size`, `aspectRatio`, `bounds`, `overflow`, and `random`.\n\nEach generated candidate must be returned as `{x, y}` with finite coordinates,\nwhich are rounded down to integer pixels. Returning `null` stops the search.\nBuilt-in and custom strategies use the same bounded search. Candidates outside\nthe allowed anchor range are skipped without a collision check. Searches stop\nwhen they travel too far from that range or exhaust a candidate budget, so\n`null` does not prove that every free position has been tried. Custom generators\nshould return `null` when finished, and each call must return promptly: the\nlayout cannot interrupt a generator that never returns.\n\n<details>\n<summary>Search limits</summary>\n\nThe allowed anchor range is the inclusive integer rectangle computed from the\nfixed layout rectangle (if overflow is disabled) and the existing cloud's\nbounds, using the sprite's search envelope as described under [place](#place).\nLet `minX`, `minY`, `maxX`, and `maxY` be the edges of that anchor range,\nand `startX` and `startY` the clamped search origin. Using the search\nenvelope's width and height, define:\n\n```text\nreachX = max(startX - minX, maxX - startX)\nreachY = max(startY - minY, maxY - startY)\nlimitX = reachX + envelopeWidth + 1\nlimitY = reachY + envelopeHeight + 1\n```\n\nThe search ends when any of these occurs:\n\n- An outside candidate is at least `limitX` from `startX` and at least `limitY`\n  from `startY`.\n- It has checked `max(100000, (maxX - minX + 1) * (maxY - minY + 1))`\n  candidates inside the range without finding a placement.\n- It encounters `max(100000, 4 * limitX * limitY)` consecutive candidates\n  outside the range. An inside candidate resets this counter.\n\nRepeated candidates count toward these budgets. A generator that moves away\nalong only one axis may therefore take many calls to terminate.\n\n</details>\n\n`aspectRatio` is the width of `size()` divided by its height, or 1 if either\nis 0. The archimedean spiral is stretched to the aspect ratio, and the\nrectangular spiral visits every point of a 4-pixel grid in rings shaped to it,\nboth up to 64:1; beyond that they would barely move along the shorter axis.\n\nThe built-in strategies are also exported as `archimedeanStrategy`,\n`rectangularStrategy`, and `noneStrategy`, so callers do not need to use string\nnames. Use `noneStrategy` or `\"none\"` for a single-attempt placement that tries\nonly the seed position, not the nearest position where the sprite could be\nplaced.\n\nIf not specified, returns the current strategy factory, which defaults to the\nbuilt-in `archimedeanStrategy`.\n\n<a name=\"random\" href=\"#random\">#</a> <b>random</b>([<i>random</i>])\n\nIf specified, sets the internal random number generator, used for selecting the\ninitial position of each sprite inside `size()`, and the\nclockwise/counterclockwise direction of the built-in strategies during\nplacement. This must be a function returning a number in the range `[0, 1)`;\n`place()` throws a `RangeError` without changing the layout if a seed is\noutside it.\n\nIf not specified, returns the current random number generator, which defaults\nto `Math.random`.\n\n<a name=\"blocksize\" href=\"#blocksize\">#</a> <b>blockSize</b>([<i>size</i>])\n\nIf specified, sets the sparse block size used during placement, from 1 to\n4096 pixels. Block sizes are rounded up to the next multiple of 32 pixels so\nthey align with the packed sprite representation. Changing the size throws an\nerror once words have been placed, until `clear()` is called. If not\nspecified, returns the current size, which defaults to `512`.\n\n<a name=\"canvas\" href=\"#canvas\">#</a> <b>canvas</b>([<i>canvas</i>])\n\nIf specified, sets the **canvas** generator function, which is used internally\nto rasterize text and images. This must be a function that returns a\ncanvas-like object. If not specified, returns the current generator function,\nwhich defaults to:\n\n```js\nfunction() { return document.createElement(\"canvas\"); }\n```\n\nIn Node.js, supply a factory using a canvas implementation, as shown in\n[Quick Start](#quick-start).\n\nThe canvas must provide a 2d context; otherwise `getSprite()` throws a\n`TypeError`. The factory is called once, and again after a sprite fails to draw\nor read back. If it returns the same canvas, that canvas is reset before reuse\nby resizing it, which clears its pixels. Chrome and Safari also clear a\ncross-origin taint when a canvas is resized, but Firefox does not, so return a\nnew canvas to recover from tainting in every browser, as the default factory\ndoes. Layouts may share one canvas; a failure invalidates their\nshared state until the canvas is reset or replaced. Nothing else should draw\nto the scratch canvas.\n\n## Benchmarks\n\nSee [BENCHMARKS.md](./BENCHMARKS.md) for reproducible v1/v2 comparisons,\nplacement counts, and limitations. Run `node benchmark.js --compare-v1`\nafter installing development dependencies. The v1 alias is a development\ndependency and is not shipped as a runtime dependency.\n\n## Development\n\nFrom a repository checkout, install development dependencies and build the\nbrowser bundle:\n\n```sh\nnpm install\nnpm run build\n```\n\nServe the repository root with a static file server and open `examples/`.\nThe build writes `build/d3-cloud.js`, an ESM module. Run `npm test` for the\nregression and TypeScript checks, or `npm run check:package` for the full\npackaging checks. See [RELEASING.md](./RELEASING.md) for the release checklist.\n","_attachments":{},"homepage":"https://www.jasondavies.com/wordcloud/","bugs":{"url":"https://github.com/jasondavies/d3-cloud/issues"},"license":"BSD-3-Clause"}