Code and graphics by Nathan.