{"id":22945130,"url":"https://github.com/seregpie/almete.wordcloud","last_synced_at":"2025-08-12T22:33:23.653Z","repository":{"id":57176756,"uuid":"118970487","full_name":"SeregPie/almete.WordCloud","owner":"SeregPie","description":"Generates a cloud out of the words.","archived":false,"fork":false,"pushed_at":"2019-01-21T13:38:48.000Z","size":199,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-09-25T09:30:14.837Z","etag":null,"topics":["algorithm","array","cloud","draw","javascript","key","method","tag","technique","word"],"latest_commit_sha":null,"homepage":"https://seregpie.github.io/almete.WordCloud/","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/SeregPie.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":"2018-01-25T21:36:00.000Z","updated_at":"2020-12-25T10:23:31.000Z","dependencies_parsed_at":"2022-09-04T10:20:38.938Z","dependency_job_id":null,"html_url":"https://github.com/SeregPie/almete.WordCloud","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SeregPie%2Falmete.WordCloud","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SeregPie%2Falmete.WordCloud/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SeregPie%2Falmete.WordCloud/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SeregPie%2Falmete.WordCloud/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SeregPie","download_url":"https://codeload.github.com/SeregPie/almete.WordCloud/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229716028,"owners_count":18113032,"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","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":["algorithm","array","cloud","draw","javascript","key","method","tag","technique","word"],"created_at":"2024-12-14T14:29:48.612Z","updated_at":"2024-12-14T14:29:49.125Z","avatar_url":"https://github.com/SeregPie.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# almete.WordCloud\n\n```\nalmete.WordCloud(words, cloudWidth, cloudHeight, {\n  createCanvas = function() {\n    return document.createElement('canvas');\n  },\n  fontFamily = 'serif',\n  fontSizeRatio = 0,\n  fontStyle = 'normal',\n  fontVariant = 'normal',\n  fontWeight = 'normal',\n  gap = 0,\n  rotation = 0,\n  rotationUnit = 'turn',\n  text = '',\n  weight = 1,\n})\n```\n\nGenerates a cloud out of the words.\n\n| argument | description |\n| ---: | :--- |\n| `words` | An array of the words to place into the cloud. A word is an object which is resolved to `{text, weight, rotation, rotationUnit, fontFamily, fontStyle, fontVariant, fontWeight}`. |\n| `cloudWidth` | The width of the cloud, in pixels. |\n| `cloudHeight` | The height of the cloud, in pixels. |\n| `createCanvas` | Creates a new `Canvas` instance. |\n| `fontFamily` | The default font family for each word. |\n| `fontSizeRatio` | The font size ratio between the words. For example, if the value is `5`, then the largest word will be 5 times larger than the smallest one. The value `5` has the same effect as the value `1/5`. |\n| `fontStyle` | The default font style for each word. |\n| `fontVariant` | The default font variant for each word. |\n| `fontWeight` | The default font weight for each word. |\n| `gap` | The gap between the words. The value is relative to the font size. |\n| `rotation` | The default rotation for each word. |\n| `rotationUnit` | The default rotation unit for each word. Possible values are `'turn'`, `'deg'` and `'rad'`. |\n| `text` | The default text for each word. |\n| `weight` | The default weight for each word. |\n\nReturns bounded words as an array of objects.\n\n```\n[{\n  centerLeft,\n  centerTop,\n  font,\n  fontFamily,\n  fontSize,\n  fontStyle,\n  fontVariant,\n  fontWeight,\n  height,\n  left,\n  rotationDeg,\n  rotationRad,\n  rotationTurn,\n  text,\n  textWidth,\n  top,\n  weight,\n  width,\n}]\n```\n\n## demo\n\n[Try it out!](https://seregpie.github.io/almete.WordCloud/)\n\n## setup\n\n### npm\n\n```shell\nnpm install almete.wordcloud\n```\n\n### ES module\n\n```javascript\nimport WordCloud from 'almete.wordcloud';\n```\n\n### Node\n\n```javascript\nlet WordCloud = require('almete.wordcloud');\n```\n\n### browser\n\n```html\n\u003cscript src=\"https://unpkg.com/almete.wordcloud\"\u003e\u003c/script\u003e\n```\n\nThe function `WordCloud` will be available under the namespace `almete`.\n\n## usage\n\n```javascript\nlet canvas = document.getElementById('canvas');\nlet ctx = canvas.getContext('2d');\nctx.clearRect(0, 0, canvas.width, canvas.height);\nlet words = [\n  {text: 'romance', weight: 19, rotation: 45},\n  {text: 'horror', weight: 3, rotation: -45},\n  {text: 'fantasy', weight: 7, rotation: 45},\n  {text: 'adventure', weight: 3, rotation: -45},\n];\nlet boundedWords = almete.WordCloud(words, canvas.width, canvas.height, {\n  fontFamily: 'Roboto',\n  fontWeight: 'bold',\n  rotationUnit: 'deg',\n});\nboundedWords.forEach(({\n  centerLeft,\n  centerTop,\n  font,\n  rotationRad,\n  text,\n}) =\u003e {\n  ctx.save();\n  ctx.translate(centerLeft, centerTop);\n  ctx.rotate(rotationRad);\n  ctx.font = font;\n  ctx.textAlign = 'center';\n  ctx.textBaseline = 'middle';\n  ctx.fillStyle = 'LightCoral';\n  ctx.fillText(text, 0, 0);\n  ctx.restore();\n});\n```\n\n## see also\n\n- [VueWordCloud](https://github.com/SeregPie/VueWordCloud)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseregpie%2Falmete.wordcloud","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseregpie%2Falmete.wordcloud","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseregpie%2Falmete.wordcloud/lists"}