Something I often see missing in JS demos is fps-correct animations. Sure, the
drawInterval = setInterval(plot, 10);
and
angle += .05;
will work on default settings with no bottleneck, but put in "Manual Bresenham" and the animation slows down.
Back in the days of Flash, this was solved with tweening libraries that took in a curve (how to interpolate between the end values), and passing a variable reference that could be updated in an fps-agnostic fashion.
Here's my idea for a framerate-independent graphics library. Have a function pointer to the main draw( time T ) call, and one of the requirements would be that time T does not represent the current time and can be out of order ( draw(1), draw(3), draw(2) ). In other words, draw() would have to be pseudo-functional. This approach would allow for some neat tricks such as cashing, multithreaded and split-rendering, motion blur tricks, etc.
I doubt it will be any efficient compared to native implementation. Cool hack though, it reminds my when I played around with basic real 3D drawing with Quick Basic.
It actually uses libraries: one for DOM traversal and another which provides a canvas. It's just that they are typically readily available in modern browsers and you have to go somewhere else to see the sources in a programming language. Perhaps "software rendering" would be a better word combination. Would be interesting to see similar projects in other scripting languages (Lua, Python etc.).
If you like this, visit ctho's own site where all his toys are available. http://ctho.org/toys/
This particular one is the "3D engine" link. he later turned it into the Tie Fighter/Roller Coaster one. When looking for inspiration, I directed him to the xscreensaver module that he created Popsquares from.
Back in the days of Flash, this was solved with tweening libraries that took in a curve (how to interpolate between the end values), and passing a variable reference that could be updated in an fps-agnostic fashion.
Here's my idea for a framerate-independent graphics library. Have a function pointer to the main draw( time T ) call, and one of the requirements would be that time T does not represent the current time and can be out of order ( draw(1), draw(3), draw(2) ). In other words, draw() would have to be pseudo-functional. This approach would allow for some neat tricks such as cashing, multithreaded and split-rendering, motion blur tricks, etc.