forked (sort of) from https://code.google.com/p/graphics-go/