作為 Web Developer 的胡思亂想是，說不定可以把時間 vs 色溫這個概念放進 Responsive / Adaptive web design 的概念裡？這樣的話要讀一點色彩學的書了。
中文：HTML5 文字雲現在是開源專案，歡迎到 Github 索取程式碼。自從公開之後新增的功能有隨機旋轉文字、彩色文字、支援 IE9 與 iPhone/iPad（很慢，不建議使用）。
HTML5 Word Clouds is a HTML5 technical demo that generate a Java-based Wordle-like word cloud.
Under the hood, functions are devided into a library and two jQuery plug-ins:
- jQuery.getContent that fetch text remotely or locally using FileReader API
- WordFreq that run the text against Porter Stemming Algorithm (English) or N-gram analysis (Chinese) in Web Workers
- Finally, jQuery.wordCloud draws beautiful word cloud on <canvas>
For Mobile Safari and IE9 that doesn’t support Web Workers, I wrote Simulated Worker that put the worker script into an iframe scope (instead worker scope).
You are welcome to play around, grab the source code and run the testcases to see their capabilities.
So you put your complicated computation in Web Workers, but you just realized the computation is not that complicated at all. Also, you denied the browsers without web workers to ever running your hard work – Mobile Safari, all IEs up to version 9.
Here is the solution I took, something might be useful to you: Simulated Web Workers – a library that creates a pseudo-web worker (that runs at fore-ground), while expose the same interfaces. Well, almost.
By almost, I mean the following:
- Instead of calling
postMessage() to send the result, in IE you must call
workerPostMessage() – because IE doesn’t allow me to overwrite the aforementioned function.
while(true) example given by Wikipedia won’t work. The
setTimeout() trick however would make it work again (in a not-so-efficient way) – please check the library tests.
You could say Simulated Web Workers is like exCanvas for canvas, but of course the interfaces of web workers are not that many. Anyway, have fun with your next web workers project.