Saturday, October 31, 2009

Standing On Their Shoulders: A Short Processing.js Tale

So this semester's reading week has come and gone and once again, as is the familiar post-mortem assessment, I have discovered the ratio of “useful" to “superfluous" work done is heavily biased toward the latter.

On the Processing.js (Pjs) front we have more baby steps!

Don't mind if I do...

For pushStyle() and popStyle() I've come full circle. First I fiddled around with storing and retrieving variables in the library, then I moved onto storing and retrieving canvas variables, and have since returned to working on the Pjs library variables.

In my previous post, I discovered some code by Andrew Peace. As it turns out, not only did Peace's work handle the Pjs variables, he also did it in a more JavaScript savvy way then I would have done.

The example that sticks out in my mind was his handling of arrays. While I was busy incrementing and decrementing a counter to figure out how many states I had and which element to store and retrieve from, Peace simply used the push() and pop() functions that grace all JavaScript arrays.

I have incorporated Peace's code with only cosmetic changes, and JavaScript's push() and pop() functions for arrays has since entered my corpus of All Knowledge. My hat off to Mr. Peace!

But does it work?

In my previous post I also intimated that some work was going on with boolean(). There was some code but no testing. In the last little bit I've started cobbling together a few test cases, and even thought still incomplete they've already helped flush out a few bugs.

The nice test page layout was provided by classmate Daniel Hodgin. Thanks!

No comments:

Post a Comment