3d in the era of J2me

Back in the deep dark past (2004-2007) I worked on a 3D game for phones of that era (before iphone, android). I recently found some of the test files for the engine, here are some videos.

Very low poly racetrack

The ubiquitous cube

Spacekid in the spacestation corridors

Our Maskot wanders the corridors .. you can’t look too far ahead, to keep things really low, which means popup is a little…severe.
Movement is a better in reality – the capture has made the movement a bit jerky.

Dire Straits

Obviously we didn’t make this, but it heavily inspired our 3D engine … textures were just too slow, so we aimed for this look.

Belated post on libregraphics meeting 2014

Here is my very late post on LGM 2014!

Back in April I went to Leipzig for my first in-the-flesh meeting of Shoebot devs ..

I met with Ricardo + to collaborate on a workshop on shoebot. To make it more fun we hadn’t decided what to do it on ! In the anarchic OSP (open source publishing) house we came with a plan to get people making examples for shoebot.

Luckily Ricardo had done a lot of this sort of thing before so did most of the talking, then I showed off some bots – evolution, spirals and also the livecoding work.

Overall the workshop seemed to go over well; we got a bunch of examples, and there was even a plugin for sublime text !

Things that came out of the workshop:

People want an integrated editor – this is OK, since the IDE still exists.
Differences between the Nodebox/Shoebot API and Cairo are not always intuitive.
Livecoding is cool!

Shoebot 2 … or something else ?
Going forward, it might be best to take the Nodebox approach and build something new based on these lessons, I’m not sure exactly what yet. What is the most intuitive API, how can we be close to standard APIs.

Non Shoebot Stuff

Outside of the workshops and talks there were plenty of time to drink and chat – apart from talking the head off of one of the mypaint guys I learned quite a lot about OSP off Sarah Magnan and Brendan Howell .. which made me regret missing many of their talks, including Brendans on the screenless office.

Leipzig was a really great city to visit, the venue for LGM was particularly impressive being inside an old church that the East Germans repurposed to a university.
Importantly for me I learned about the “kebab circle” – the ring of gentrification moving from the inside of the city outwards (beyond which you can still buy kebabs).

With any luck LGM will be able to make it next year and meet everyone again.

Shoebot experiment – perlin noise..

Perlin noise is pretty cool, you can use it to generate realistic looking clouds or mountains.

Here’s a bot for shoebot I made a while back that uses perlin noise to generate some nice circles.

You’ll need shoebot and the lib “noise” installed into your environment for it to work;

# pip install noise

Then to run;

sbot -w perlin-circlescape1.bot

Here’s a video of them in action –

See below the break for the code –
Continue reading

Cairo with python Ctypes

Uploaded some experiments with python and ctypes to here:



This is a really rough proof of concept that the pycairo API can be implemented with ctypes + metclasses.



So far only ImageSurface is supported on the SVG backend, along with Contexts.   The nice thing about this is that you can use a pycairo like API on pypy, where things should be faster (in theory).


There’s a test that can be run to show the outputs the same for pycairo and cairo ctypes.

Using PyCha with Django

A quick post on using Python Charts to generate nice SVG charts for your django website (I’ve had the code hanging around for ages – so should just post it). The code is based on the examples there, here I integrate it into Django.

To install you’ll need to do

pip install pycha

Heres the code for a simple view to output a chart directly to SVG:

# views.py

from StringIO import StringIO
from django.http import HttpResponse

import cairo

def colors(request):
    in_req = 1

    svg_buffer = StringIO()

    width, height = (500, 400)
    surface = cairo.SVGSurface(svg_buffer, width, height)

    dataSet = (
     ('dataSet 1', ((0, 1), (1, 3), (2, 2.5))),
     ('dataSet 2', ((0, 2), (1, 4), (2, 3))),
     ('dataSet 3', ((0, 5), (1, 1), (2, 0.5))),

    options = {
       'legend': {'hide': True},
       'background': {'color': '#f0f0f0'},

    #import pycha.bar
    #chart = pycha.bar.VerticalBarChart(surface, options)

    import pycha.line
    chart = pycha.line.LineChart(surface, options)

    del chart
    del surface

    response = ''
    response = HttpResponse(mimetype='image/svg+xml')
    response.write( svg_buffer.read() )
    return response

The basic idea is that – instead of the chart outputting to an svg file, the output goes to a buffer, this is triggered by calling the destructors of the chart and it’s cairo surface.  Once the data is in the buffer, it is rewound and played back to the Http Response.


Inline SVG

As is, this won’t work as inline svg, because outputting the XML preamble in the middle of the page will cause problems.  Below is an example that let’s you decide if you need the preamble (full SVG output), or not (SVG fragment for inclusion in a page or another SVG):

# Create your views here.

from StringIO import StringIO
from django.http import HttpResponse
from django.shortcuts import render_to_response

import cairo

XML_PREAMBLE = '<?xml version="1.0" encoding="UTF-8"?>'

def colors_chart(inline = False):
    Generate colours chart

    Set inline to True to disable the XML preamble
    in_req = 1

    svg_buffer = StringIO()

    width, height = (500, 400)
    surface = cairo.SVGSurface(svg_buffer, width, height)

    dataSet = (
     ('dataSet 1', ((0, 1), (1, 3), (2, 2.5))),
     ('dataSet 2', ((0, 2), (1, 4), (2, 3))),
     ('dataSet 3', ((0, 5), (1, 1), (2, 0.5))),

    options = {
       'legend': {'hide': True},
       'background': {'color': '#f0f0f0'},

    import pycha.bar
    chart = pycha.bar.VerticalBarChart(surface, options)

    #import pycha.line
    #chart = pycha.line.LineChart(surface, options)

    del chart
    del surface

    response = ''

    if inline:
    return svg_buffer.read()

def colors_svg(request):
    """ render a pure SVG chart """
    response = HttpResponse(mimetype='image/svg+xml')
    response.write(colors_chart(inline = False))
    return response

def index(request):
    """ render a chart into the template """
    chart_svg = colors_chart(inline = True)

    return render_to_response(
        { "chart" : chart_svg },

An example project with the above code is available here:


[EDIT 25/2/2011] Fixed PyCha URL

[EDIT: 2010/10/05]

Oops, I’ve been using TCC/LE by JPSoft as my shell… the following doesn’t work in the normal command prompt


I just had a look at SET and it lets you set user/system variables:

Display, create, modify, or delete environment variables.

SET [/A /D /E /P /R file... /S /U /V /X] [name[=][value ]]
        file:  One or more files containing variable definitions
        /A(rithmetic)           /S(ystem variables)
        /D(efault variables)    /U(ser variables)
        /E(nv vars)             /V(olatile variables)
        /R(ead from file)       /X override VariableExclude

So to set save a variables MYAPP_HOME as the current directory, just do


Wish I’d have looked that up a few years ago, it’ll save a few seconds next time I need to setup some dev sdk :)

Access files in a Linux virtual machine from Windows

I recently found a neat way of accessing files in a linux VMWare image.   This is really useful, as theres never really a good time to break your VMWare image, this is also handy if you don’t want to run the whole machine, but just access the files inside.

There is one caveat:

  • It only works if the filesystem is ext2 (ext3 works, and ext4 probably works).

Install VMWare DiskMount Utility

Accept the EULA, download and install the VMWare DiskMount utility.

For convenience add the utilities folder to the path:

C:\Program Files\VMware\VMware DiskMount Utility

Do this through the Windows Gui, or even use my addpath utility.

At this point you can mount Windows VMWare images.

The usage is:  vmware-mount drive-letter vmdk-image.

Heres how I mount my Ubuntu image to the j: drive

[C:\vmware\Ubuntu]vmware-mount j: ubuntu.vmdk

No output here indicates success.

At this point everything seems fine, but a crucial piece of the puzzle is still missing; try and view the files and you still can’t:

Failing to see files in an ext2 VMWare image

The next step is to make Windows understand the ext2 filesystem, using a special driver.

Install ext2ifs

Grab ext2ifs from www.fs-driver.org and install.

If the following steps don’t work then you may need to reboot.

Thats it!

You should be now able to access files inside your VMWare image (assuming it’s ext2 and not reiserfs), remount the image and have a go:

In my case I did:

[C:\vmware\Ubuntu]vmware-mount j: ubuntu.vmdk
[C:\vmware\Ubuntu] dir j:

Heres the output – hooray, I can copy my work out of the image !

Viewing files inside a VMWare image with ext2fs

This is very useful, especially if you do dist-upgrade in ubuntu and can’t access the network.

Bonus tip:

Newer versions of VMWare player let you install VMWare tools from inside the GUI, this is another way to fix the kind of catestrophic problems you can cause yourself by accidentally upgrading the kernel in an image.

Using Java2Python to port a JavaCairo tutorial

I recently came across Java2Python.  As I’m interested in Cairo I thought it would be interesting to try porting one of the example tutorials from ZetCode.

I’ll run through the steps involved in porting then try and reach some conclusions at the end :).

1. Get setup

This is easiest in Linux, I’m running Ubuntu (in vmware), and installed

antlr 2.x
sun java6

You can install them like this:

# sudo apt-get install antlr python2.5 sun-java6-bin libjava-gnome-java

Then install Python2Java with easy_install

# sudo easy_install-2.5 java2python

To test if it’s working run j2py -i.  It should complain there is no file:

# j2py -i
Usage: j2py [options]

j2py: error: -i option requires an argument

If you get any other errors your missing some packages.

2. Get the Java Code from the Simple Example.

Save the ‘simple.java’ example as ‘GSimple.java’

If java-gnome is running ok, compiling and running it you should see a window:

# javac GSimple.java
# java GSimple


Now we’ll run through the code, it’s important to understand what it does before we port it…

Continue reading