{"id":315,"date":"2008-12-12T18:29:12","date_gmt":"2008-12-12T22:29:12","guid":{"rendered":"http:\/\/benjamin.smedbergs.us\/blog\/?p=315"},"modified":"2008-12-12T18:29:12","modified_gmt":"2008-12-12T22:29:12","slug":"wordmaps-without-java","status":"publish","type":"post","link":"http:\/\/benjamin.smedbergs.us\/blog\/2008-12-12\/wordmaps-without-java\/","title":{"rendered":"Wordmaps without Java"},"content":{"rendered":"<p>Word maps generated by <a href=\"http:\/\/www.wordle.net\/\">wordle.net<\/a> have been making the rounds. They are very cool representations of the frequency that various words appear in a hunk of text (such as a blog feed). Unfortunately, the code to generate these word maps is not open source, and it requires Java.<\/p>\n<p>So I decided to take on <a href=\"http:\/\/blog.johnath.com\/2008\/12\/11\/word-bubble-memery\/\">Johnath&#8217;s challenge<\/a> and produce something similar using HTML canvas and JavaScript:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/benjamin.smedbergs.us\/blog\/wp-content\/uploads\/2008\/12\/canvas.png\" alt=\"Wordmap of BSBlog\" title=\"bsblog-wordmap\" width=\"800\" height=\"800\" class=\"size-full wp-image-316\" srcset=\"http:\/\/benjamin.smedbergs.us\/blog\/wp-content\/uploads\/2008\/12\/canvas.png 800w, http:\/\/benjamin.smedbergs.us\/blog\/wp-content\/uploads\/2008\/12\/canvas-150x150.png 150w, http:\/\/benjamin.smedbergs.us\/blog\/wp-content\/uploads\/2008\/12\/canvas-300x300.png 300w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/p>\n<p>You can take it for a spin too, but only if you have Firefox 3.1. <a href=\"http:\/\/benjamin.smedbergs.us\/wordmap\/wordmap.html\">Try it out!<\/a>. I&#8217;m currently using some features that are specific to Firefox 3.1, such as JavaScript 1.8 and Canvas.measureText. I think I can backport this code to support Firefox 3 by checking for .mozMeasureText and .mozTextStyle. I don&#8217;t know whether Safari currently supports text drawing or measurement in their canvas implementation. If they do, this can probably be made to work there as well.<\/p>\n<p>If you&#8217;re interested in the code, a <a href=\"http:\/\/hg.mozilla.org\/users\/bsmedberg_mozilla.com\/wordmap\/\">Mercurial repository<\/a> is available on hg.mozilla.org. There are a couple improvement possibilities noted in the README file. Some other possibilities that I&#8217;m just thinking of now:<\/p>\n<ul>\n<li>Produce an image map to make all the terms link to the relevant post(s).\n<li>Produce SVG output to make the output scalable.\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Word maps generated by wordle.net have been making the rounds. They are very cool representations of the frequency that various words appear in a hunk of text (such as a blog feed). Unfortunately, the code to generate these word maps is not open source, and it requires Java. So I decided to take on Johnath&#8217;s [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,6],"tags":[94,39,184,185],"class_list":["post-315","post","type-post","status-publish","format-standard","hentry","category-mozilla","category-untagged","tag-canvas","tag-javascript","tag-wordlenet","tag-wordmap"],"_links":{"self":[{"href":"http:\/\/benjamin.smedbergs.us\/blog\/wp-json\/wp\/v2\/posts\/315","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/benjamin.smedbergs.us\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/benjamin.smedbergs.us\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/benjamin.smedbergs.us\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/benjamin.smedbergs.us\/blog\/wp-json\/wp\/v2\/comments?post=315"}],"version-history":[{"count":3,"href":"http:\/\/benjamin.smedbergs.us\/blog\/wp-json\/wp\/v2\/posts\/315\/revisions"}],"predecessor-version":[{"id":319,"href":"http:\/\/benjamin.smedbergs.us\/blog\/wp-json\/wp\/v2\/posts\/315\/revisions\/319"}],"wp:attachment":[{"href":"http:\/\/benjamin.smedbergs.us\/blog\/wp-json\/wp\/v2\/media?parent=315"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/benjamin.smedbergs.us\/blog\/wp-json\/wp\/v2\/categories?post=315"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/benjamin.smedbergs.us\/blog\/wp-json\/wp\/v2\/tags?post=315"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}