subscribe
Tags:
 
2010
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
2009-11-18
code dreams
Sometimes I dream code. To be a bit more specific, sometime I dream about a solution to a coding problem that I'm having. Upon waking, I will test the dreamed of code to see if it actually solves the problem. This scenario has played out a few times with much success.

the latest incarnation
Recently however, I had a dream that dealt with code that wasn't mine and I have never seen. The code was written by a fellow student in my programming class, and the dream contained a possible way to increase the speed at which the student's program would complete its task. Under normal circumstances, I would just contact the student and explain the possible fix.

like a song stuck in my head
Unfortunately, I have now forgotten the fix, it isn't possible for me to contact the student, and I have no idea what the actual code looks like. This has left me with a bit of "code on my mind" that I think about often enough that I have decided to write some similar code to help clear my mind.

in the beginning
Let me first define the problem: It takes a long time to draw a circle on the screen. Huh? How about a little more info.
The programming language is Apple BASIC, the machine is an APPLE IIe, and the year is 1989. Yea, I had a dream about 20 year old code.

In the programming class, we were creating animations and graphics, and the student needed to draw a circle.
What I think the student's program did was loop through each of the 360 degrees in a circle and determine the degrees circumference point relative to a set radius, and then "turn on" the pixel at that point. This took about a minute per circle on the Apple's 1Mhz processor.

back to the present
So I thought I would create some similar and highly pointless code in javascript. Why not?
Instead of pixels, my code creates HTML div elements, that are 2 pixel squares, and aligns the elements by setting the div's style.top and style.left properties.

The code can be run at jezra.net/code_examples/draw_circle.htm.

Now stop reading, and go do something pointless.
Comments
Name:
not required
Email:
not required (will not be displayed)
Website:
not required (will link your name to your site)
Comment:
required
Please do not post HTML code or bbcode unless you want it to show up as code in your post. (or if you are a blog spammer, in which case, you probably aren't reading this anyway).
Prove you are human by solving a math problem! I'm sorry, but due to an increase of blog spam, I've had to implement a CAPTCHA.
Problem:
2 minus 1
Answer:
required