The past couple weeks I’ve been fascinated by the html5 canvas element. My interest in graphics goes decades back, yet only recent experimentation with CoffeeScript showed me how fun and addicting the peanut butter and jelly combination of client side scripting and html5 canvas are to work with.
Thanks to a helpful reminder I got the html5 chaos field working smoothly with client side file based coffeescript (.coffee) . I found the effect at Jonas Wagner’s site, and went through the practice of converting it to CoffeeScript. The process literally took an instant thanks to js2coffee. The mods took a couple of hours to determine what was too slow or just broken about my CoffeeScript modifications. The one tiny issue I have with js2coffee is replacing 2 spaces with tabs.
As my client side CoffeeScript hacks grow larger1, I’m finding the constraint of keeping all the code in html script tags wrapper on page to be awkward. One little project that I’m hoping to have time for this weekend requires combining several html5 canvas effects, they may share some common elements, and each is growing unwieldy for their separate html header tags.
If you have a definitive need for speed like myself, then standard tactics for random number generation simply won’t do. In the project I’m working on I don’t include or link to Boost (Mersenne Twister) because it’s a small delivery, so I went hunting for a fast, reliable, and well packaged random number generator. I remembered reading John D. Cook’s blog post sharing precisely what I was looking for. The fastest approach I could generate quickly is a cached version of a large number of normal calls accessed by a uniform call in the loop.
Bizarro World Weather
Last week I got a chance to go on a solid 21 mile walk that started with 100 degrees of humid heat, and ended with an abysmal thunderstorm and torrential down pour (kinda fun). This morning it’s 55F and chilly. I do believe it’s likely good ole mother nature forgot what the transition from summer to spring is supposed to be like. Gotta marvel at her unpredictability.
On my way into work this morning I waited for the transition between traffic signals just before the sun rose in the distance. Anxiety over a large project delivery was wrestling for my attention with anticipation of my usual pre-work stroll on this perfect spring morning.
Before digging into node.js servers with CoffeeScript, I branched off by mimicking a simple client example by Arbo von Monkiewitsch.
It attaches a callback function to a click event and updates the page. Note that I haven’t passed in an object by reference (return changes), otherwise I could have called a swap function, from within the show message function.