Quick and dirty port of http://djm.cc/constellation.js