Nav links

Thursday, 16 February 2012

Getting touchy feely with Android

When I have a new programming platform to explore I usually start by building a fractal renderer. It's a good task because a small amount of code can produce very interesting results, and the amount of work is very open-ended. You can explore graphics, user-interfaces, and pure algorithmical speed. This has led to:

  • JM's Mandelbrot Explorer, a 2-D fractal navigation application for Windows, incorporating an iteration engine written in assembler, colour-cycling, and user-definable fractal equations 
  • FractalPeaks, a 3-D fractal navigator using DirectX 9, fully utilising the video hardware acceleration of the time 
  • A Javascript fractal zoomer, testing the then new HTML canvas element of Firefox

Nowadays all the action is on smartphones, and as luck would have it an Android phone came into my possession on my last birthday. After getting the general feel for programming by following some of the great tutorials by Vogella I decided to move on to one of the really new elements of smartphone programming, the touch interface.

I found a concise, straightforward tutorial on Kellbot!, which showed a short program that displayed a circle wherever the screen was touched. This was enough to get me started on displaying a fractal on screen. I then used the Making Sense of Multitouch post on the Android developers blog to see how to handle dragging and pinch-zooming. That was all the outside help I needed, the rest was just working out the maths myself. I was delighted to find Android providing very comprehensive libraries, incorporating a bevy of matrix functions perfect for my needs.

I now have an interesting zoomable and scrollable fractal app on my phone. It's by far the best interface of any of my fractal programs. There are not many features in the app at present, and it's far from polished enough to distribute publicly. However, it is possible that I may feel the need to release it one day to learn how app store publishing works, in which case I'll have many more fun days enhancing this product.