This is the blog of Brian Long, Windows, Mac & mobile trainer, trouble-shooter and consultant.

Friday, 24 June 2011

“Project Cooper” Mandelbrot set calculation

I’ve had a couple of people ask me on separate occasions to show some “Project Cooper” code. I’ve not posted any thus far, as the product is quite early in its beta cycle and very few people have access to it. When it has matured and is in more hands I have plans to write lots more on the subject, but since I’ve been asked, I thought I’d post a simple project.

The ever-popular Mandelbrot set is the subject of this little demo, and it’s just a simple console application, completely bypassing the Android support, just building an app that runs on the Java VM.

Simple, huh? When built I get a Mandelbrot.jar file that weighs in at 1,754 bytes.

This is what it looks like running in a Windows command prompt:

And here is the same code (same binary, after all, it’s running on the cross-platform Java VM) running on Ubuntu Linux in a terminal window (note – this thumbnail looks pretty ghastly, but if you click it to see the original file, it looks a bit more presentable there):

Yeah, ok, so fair enough it’s not much of an example, but it is code!

Before signing off I’ll mention another demo, which I’ve got some screenshots of, but without any code to show from currently. Jim McKeeth from RemObjects has been playing around with jMonkeyEngine 3, a gaming platform supporting a rendering loop, all the graphics and object support you’d expect and the obligatory physics engine. It’s a set of Java libraries, so he followed one of the tutorials using “Project Cooper” and got the expected application out at the end. A wall, with a moveable camera point of you that allows you to fire a cannonball. All this is from a source file with around 250 lines in it, code and white space.

jMonkeyEngine has a goal to work on as many platforms as possible, and I’d read that they were planning Android support. At the time of writing, jMonkeyEngine 3 is at Alpha 4. The Android support is so preliminary that it isn’t in the main build yet, but I pulled it down from their nightly build area. The goal is to take the same source file as in the regular project above, and slip it into an Android harness with minimal code changes (preferably none). It worked out pretty well – here are a couple of screenshots from my phone: