davelog Wherein, I write.

code poetry

A few years ago in my early days of HTML and PHP and CSS and all the other acronyms I was learning, my mother got me a t-shirt that reads “code poet”. I know it’s trendy, but it really is true.

By days I am a aspiring young college student ready to go out and make my mark on the world, and – also by days, I suppose – I work in the graphic design studio at my university building standards-compliant, CSS based, accessible web sites. It’s funny that I am immersed in a world of layouts, press checks and color separations when my own world is one of pixels, the DOM, and strictly RGB. My co-workers wonder how I can sit in front of a bunch of gobbly-gook code for hours on end and be entertained and even inspired.

It all comes down to that t-shirt: to me, code is poetry. It truly is art. Take a glance at the source code for this very page and you will see that I have pored over every line to make sure everything, well… most everything, is pixel perfect down to the last bit.

Which brings me to why this is on my mind. I stayed up until 3 this morning getting this darned javascript to work correctly. Why? Because I can. It wont mean much to anyone, but the view comments button below this post triggers a new http request to my server which populates an inline div asynchronously via javascript.

But the thing I was working on last night was this little gem right here:

currTime += 10;
newCurrTime = currTime/duration;
if ((newCurrTime) < 1)
newHeight = -scrollH/2*newCurrTime*newCurrTime + scrollH;
else
newHeight = scrollH/2 * ((--newCurrTime)*(newCurrTime-2) - 1) + scrollH;
sDiv2.style.height = (newHeight + "px");
setTimeout("reScrollRe()","10");

Above is the code which tells that div how to make its entrance so to speak. Once the data is populated, I recursively un-hide the div a bit at a time every 10 milliseconds. The cool part is in the 2 lines up there after the if and else – that’s where the math is done. The div un-hides itself faster and faster, accelerating until it reaches the halfway mark, then slows down until it is completely there.

Again, I know that this means nothing to anyone, but this is my poetry; this is my art of self expression. Right here.


1 Comment

oh hey, really nice redesign. oh and i love recursion so much too ;)

Posted by Michael on 12 October 2006 @ 5am