HTML Canvas & Processing JS
I have been experimenting with the new HTML 5 Canvas and trying to get up to speed on the syntax. As a seasoned Actionscript 3 developer, I find JS easy to understand but difficult to write. I find myself thinking flash and trying to work a flash approach. Anyhow, I have tried canvas with js and canvas with Raphael and now canvas Processing JS.
They all have advantages and drawbacks. Processing js is giving me the most fun for now and I can’t wait till they finish implementing the entire set of methods, or at least what’s left that can be implemented into canvas.
I have read some eager articles saying that this can replace Flash and will be the end of flash. This may be so at some point in the future, but I can tell ya right now, it’s not even close. With no dedicated VM it craps out if you try anything with a couple hundred worthy sprites on screen. Also, objects are painted onto the canvas and no longer exist as objects you can have a pointer to. You basically have to paint the the canvas each time with your updates, example: Processing uses pushMatrix() and popMatrix() to store and restore stage translations. This is pissing me off and I am still trying to get my head around it. I just want to move stuff around dang it. On the other hand, when you paint, you can have an infinite amount of detail without worrying about overhead, like when you pipe MC’s into Bitmap object in Flash.
It’s all good though and a step in the right direction as far as I am concerned. No plugins, no 3rd party expensive IDE’s etc. It’s all free range and organic, yay. Can’t wait to start working in some div’s, copy etc and growing the graphics and UI for html pages.
As with all things animation and drawing, I like to start off with basic math and growing plants, trees, etc. Processing has no real shading, 3d or drop shadowing built in right now and it’s kind of refreshing going back to the old way of thinking where you have to fake it all.
Here is a screen shot of some alien plant thing I am writing. It takes about 20 mins to draw the entire 360 view. The depth and dimension is all fake like I said, drawing all the highlights, shadows etc in separate passes with slight offsets. Demo of my first processing attempt here.




Wow, that looks very, very cool. Can’t wait to see a live demo!
I’ll be working on some 3D functionality for PJS in the next week or so. Hopefully, we’ll can start seeing all the great 3D Processing demos run in the browser.
I just grabbed the latest and saw your demos, sweet! I am off to learn how to WebGL enable my browser.
Hey, just saw this work you did with Processing.js, and would love to know if you did anymore like it? I’m currently focused on performance work with Processing.js, and am scouring the web for very complex code to try and push the limits of our js/canvas stuff with a view to making it faster. We’re releasing version 0.8 this week, which has a lot of speed improvements already. Drop me an email if you have a moment and are still interested.
Hey David, thanks for stopping by. I am still experimenting with Processing js and trying to port my tree growth action script classes over, http://www.metanurb.com/?p=37. Will post it when it’s reasonably ready. Overall the speed is pretty good. I think the above example is just my bad implementation causing the slowness. Basically everything you see on my blog that’s done in Flash will be getting tested/ported to Processing js. I am almost done with my laser touch table, projector arrived today. Then I hope to get a Precessing example with touches. As you can see I am all over the place, but always willing to put the boots to anything. Next thing after the trees is http://www.metanurb.com/?p=311.